10 · Generalized forwarding, OpenFlow, middleboxes, the hourglass, end-to-end ★
Slides 4-69 → 4-85 · HW5 P8, P9 · Book 4.4 – 4.5
Match plus action (4-70)
- Each router has a forwarding table, also called a flow table.
- "Match plus action": match bits in the arriving packet, then take an action.
- Destination-based forwarding (the old way): forward based only on the destination IP address.
- Generalized forwarding: many header fields can decide the action, and many actions are possible: drop, copy, modify, log.
Flow table abstraction (4-71)
- Flow: defined by header field values.
- Match: pattern values in packet header fields.
*is a wildcard (matches anything). - Actions for a matched packet: drop, forward, modify, or send to the controller.
- Priority: breaks ties when patterns overlap.
- Counters: number of bytes and packets matched.
- The tables are computed and installed by a remote controller (SDN), not by each switch.
Slide example (4-71):
| Match | Action |
|---|---|
| src = *.*.*.*, dest = 3.4.*.* | forward(2) |
| src = 1.2.*.*, dest = *.*.*.* | drop |
| src = 10.1.2.3, dest = *.*.*.* | send to controller |
OpenFlow flow table entries (4-72)
Each entry = Match + Action + Stats (packet and byte counters).
Actions
- Forward the packet to port(s).
- Drop the packet.
- Modify fields in the header(s).
- Encapsulate and forward to the controller.
Header fields you can match
| Layer | Fields |
|---|---|
| (switch) | Ingress port |
| Link | Src MAC, Dst MAC, Eth type, VLAN ID, VLAN priority |
| Network | IP src, IP dst, IP protocol, IP ToS |
| Transport | TCP/UDP src port, TCP/UDP dst port |
One table matches across three layers. That's what makes it "generalized".
OpenFlow examples (4-73, 4-74)
| Behaviour | Non-wildcard field(s) | Action |
|---|---|---|
| Destination-based forwarding: datagrams to 51.6.0.8 go out port 6 | IP Dst = 51.6.0.8 | port6 |
| Firewall: block everything to TCP port 22 (ssh) | TCP d-port = 22 | drop |
| Firewall: block everything sent by host 128.119.1.1 | IP Src = 128.119.1.1 | drop |
| Layer-2 forwarding: frames to MAC 22:A7:23:11:E1:02 go out port 3 | MAC dst = 22:A7:23:11:E1:02 | port3 |
Every other field in those rows is *.
One abstraction, many devices (4-75)
| Device | Match | Action |
|---|---|---|
| Router | longest destination IP prefix | forward out a link |
| Switch | destination MAC address | forward or flood |
| Firewall | IP addresses and TCP/UDP port numbers | permit or deny |
| NAT | IP address and port | rewrite address and port |
The OpenFlow network (4-76, 4-77; book Figure 4.30)
Memorise this topology. HW5 P8, P9 and the scenarios below all use it.
| Switch | Port 1 | Port 2 | Port 3 | Port 4 |
|---|---|---|---|---|
| s1 | s3 | h1 10.1.0.1 | h2 10.1.0.2 | s2 |
| s2 | s3 | s1 | h3 10.2.0.3 | h4 10.2.0.4 |
| s3 | h6 10.3.0.6 | h5 10.3.0.5 | s1 | s2 |
Hosts on s1 are 10.1.*.*, on s2 10.2.*.*, on s3 10.3.*.*. A controller programs all three tables, so orchestrated tables create network-wide behaviour.
Scenario 1: h5, h6 → h3, h4 via s1, then s2 (slide 4-77)
| Switch | Match | Action |
|---|---|---|
| s3 | IP Src = 10.3.*.*; IP Dst = 10.2.*.* | forward(3) (to s1, not the direct link to s2) |
| s1 | ingress port = 1; IP Src = 10.3.*.*; IP Dst = 10.2.*.* | forward(4) (to s2) |
| s2 | ingress port = 2; IP Dst = 10.2.0.3 | forward(3) (to h3) |
| s2 | ingress port = 2; IP Dst = 10.2.0.4 | forward(4) (to h4) |
Scenario 2: load balancing (book 4.4.3)
h3's traffic to 10.1.*.* takes the direct s2→s1 link. h4's traffic to 10.1.*.* goes s2→s3→s1.
| Switch | Match | Action |
|---|---|---|
| s2 | ingress port = 3; IP Dst = 10.1.*.* | forward(2) |
| s2 | ingress port = 4; IP Dst = 10.1.*.* | forward(1) |
| s3 | ingress port = 4; IP Dst = 10.1.*.* | forward(3) |
Ordinary destination-based forwarding can't do this: both flows have the same destination, so the ingress port has to be part of the match.
Scenario 3: firewalling (book 4.4.3)
s2 accepts traffic only from hosts on s3.
| Switch | Match | Action |
|---|---|---|
| s2 | IP Src = 10.3.*.*; IP Dst = 10.2.0.3 | forward(3) |
| s2 | IP Src = 10.3.*.*; IP Dst = 10.2.0.4 | forward(4) |
With no other entries, anything else arriving at s2 matches nothing and is not delivered.
How to solve: write a flow table
- Label the ports of the switch you're programming (table above).
- Split the requirement into one rule per (where it comes from, where it goes).
- For each rule pick the fewest match fields that pin it down: ingress port for "arriving on port k", IP Src for "from host X", IP Dst for "to host Y", IP Proto (TCP = 6, UDP = 17) or a port number for the protocol/app. Use
10.x.*.*wildcards for "either host on switch x". - Action: forward(port of the next hop or host), or drop.
- If a specific "allow" rule overlaps a broad "drop" rule, give the allow rule higher priority.
- Check by tracing each case in the problem through your table.
Worked example: HW5 P8 (official)
Q (HW5 P8): Consider the SDN OpenFlow network in Figure 4.30 (s2 ports: 1 to s3, 2 to s1, 3 to h3, 4 to h4; see the table above). The desired forwarding behavior for datagrams arriving at s2 is:
- (i) any datagrams arriving on input port 1 from hosts h5 or h6 that are destined to hosts h1 or h2 should be forwarded over output port 2;
- (ii) any datagrams arriving on input port 2 from hosts h1 or h2 that are destined to hosts h5 or h6 should be forwarded over output port 1;
- (iii) any arriving datagrams on input ports 1 or 2 and destined to hosts h3 or h4 should be delivered to the host specified;
- (iv) hosts h3 and h4 should be able to send datagrams to each other.
Specify the flow table entries in s2 that implement this forwarding behavior.
| # | Match | Action | Why |
|---|---|---|---|
| 1 | Ingress Port = 1; IP Src = 10.3.*.*; IP Dst = 10.1.*.* | Forward (2) | (i): from s3, h5/h6 → h1/h2, send toward s1 |
| 2 | Ingress Port = 2; IP Src = 10.1.*.*; IP Dst = 10.3.*.* | Forward (1) | (ii): from s1, h1/h2 → h5/h6, send toward s3 |
| 3 | Ingress Port = 1; IP Dst = 10.2.0.3 | Forward (3) | (iii): from s3 to h3 |
| 4 | Ingress Port = 2; IP Dst = 10.2.0.3 | Forward (3) | (iii): from s1 to h3 |
| 5 | Ingress Port = 1; IP Dst = 10.2.0.4 | Forward (4) | (iii): from s3 to h4 |
| 6 | Ingress Port = 2; IP Dst = 10.2.0.4 | Forward (4) | (iii): from s1 to h4 |
| 7 | Ingress Port = 4; IP Dst = 10.2.0.3 | Forward (3) | (iv): h4 → h3 |
| 8 | Ingress Port = 3; IP Dst = 10.2.0.4 | Forward (4) | (iv): h3 → h4 |
Trace: h6 (10.3.0.6) → h2 (10.1.0.2) arrives at s2 on port 1 row 1: port 1 ✓, src 10.3.* ✓, dst 10.1.* ✓ → forward(2) to s1 ✓ Trace: h1 → h4 arrives on port 2 → row 6 → forward(4) ✓ Trace: h3 → h4 arrives on port 3 → row 8 → forward(4) ✓
HW5 P9: s2 as a firewall (unofficial answer)
Q (HW5 P9): Consider again the SDN OpenFlow network in Figure 4.30. Suppose we want switch s2 to function as a firewall. Specify the flow table in s2 that implements each of the following firewall behaviors (a different flow table for each) for delivery of datagrams destined to h3 and h4. You do not need to specify the forwarding behavior in s2 that forwards traffic to other routers.
- (a) Only traffic arriving from hosts h1 and h6 should be delivered to hosts h3 or h4 (i.e., arriving traffic from hosts h2 and h5 is blocked).
- (b) Only TCP traffic is allowed to be delivered to hosts h3 or h4 (i.e., UDP traffic is blocked).
- (c) Only traffic destined to h3 is to be delivered (i.e., all traffic to h4 is blocked).
- (d) Only UDP traffic from h1 and destined to h3 is to be delivered. All other traffic is blocked.
(a) Only from h1 (10.1.0.1) and h6 (10.3.0.6)
| Prio | Match | Action |
|---|---|---|
| high | IP Src = 10.1.0.1; IP Dst = 10.2.0.3 | Forward (3) |
| high | IP Src = 10.1.0.1; IP Dst = 10.2.0.4 | Forward (4) |
| high | IP Src = 10.3.0.6; IP Dst = 10.2.0.3 | Forward (3) |
| high | IP Src = 10.3.0.6; IP Dst = 10.2.0.4 | Forward (4) |
| low | IP Dst = 10.2.0.3 (anything else) | Drop |
| low | IP Dst = 10.2.0.4 (anything else) | Drop |
(b) Only TCP (IP Proto = 6)
| Prio | Match | Action |
|---|---|---|
| high | IP Proto = TCP; IP Dst = 10.2.0.3 | Forward (3) |
| high | IP Proto = TCP; IP Dst = 10.2.0.4 | Forward (4) |
| low | IP Dst = 10.2.0.3 | Drop |
| low | IP Dst = 10.2.0.4 | Drop |
(Equivalent: two rows IP Proto = UDP; IP Dst = 10.2.0.3/10.2.0.4 → Drop plus the two TCP forward rows.)
(c) Only to h3
| Match | Action |
|---|---|
| IP Dst = 10.2.0.3 | Forward (3) |
| IP Dst = 10.2.0.4 | Drop |
(d) Only UDP from h1 to h3
| Prio | Match | Action |
|---|---|---|
| high | IP Src = 10.1.0.1; IP Dst = 10.2.0.3; IP Proto = UDP | Forward (3) |
| low | IP Dst = 10.2.0.3 | Drop |
| low | IP Dst = 10.2.0.4 | Drop |
The allow row must outrank the drop row for 10.2.0.3, since both match h1's UDP datagrams.
Middleboxes (4-78, 4-79)
- Definition (RFC 3234): "any intermediary box performing functions apart from normal, standard functions of an IP router on the data path between a source host and destination host".
- NAT: home, cellular, institutional.
- Firewalls, IDS: corporate, institutional, service providers, ISPs.
- Load balancers: corporate, service provider, data center, mobile nets.
- Caches: service provider, mobile, CDNs.
- Application-specific boxes: service providers, institutional, CDN.
- Old middleboxes were closed, proprietary hardware. The trend is toward whitebox hardware with open APIs and network functions virtualization, programmed with SDN-style match+action.
The IP hourglass (4-80, 4-81)
- Thin waist: exactly one network-layer protocol, IP, which must be implemented by every one of the billions of Internet-connected devices.
- Above the waist, many protocols: TCP, UDP, QUIC, HTTP, SMTP, RTP, DASH, …
- Below the waist, many protocols: Ethernet, WiFi, PPP, PDCP, Bluetooth, over copper, radio, fiber.
- At middle age the hourglass grew "love handles": middleboxes (caching, firewalls, NAT) operating inside the network around the IP layer.
Architectural principles of the Internet (4-82, RFC 1958)
- "The goal is connectivity, the tool is the Internet Protocol, and the intelligence is end to end rather than hidden in the network."
- Three cornerstone beliefs: simple connectivity; IP as the narrow waist; intelligence and complexity at the network edge.
The end-to-end argument (4-83)
- Some functions (e.g. reliable data transfer, congestion control) can be done in the network (hop-by-hop) or at the edge (end-end).
- The argument (Saltzer, Reed, Clark): such a function can be implemented completely and correctly only with the knowledge and help of the application at the end points. So the network itself can't fully provide it.
- An incomplete version in the network can still be useful as a performance enhancement (e.g. link-layer retransmission on a lossy wireless link).
- Why hop-by-hop isn't enough: even if every link is reliable, a router can corrupt or drop data in its memory, so the ends still need their own check (TCP).
Where's the intelligence? (4-84)
| Era | Intelligence/computing lives in |
|---|---|
| 20th-century phone net | the network switches (the phone itself is dumb) |
| Internet (pre-2005) | the edge (end hosts); the core just forwards |
| Internet (post-2005) | programmable network devices (SDN), plus intelligence, computing and massive application-level infrastructure at the edge (data centers, CDNs) |
Chapter 4 wrap-up (4-85): forwarding tables and flow tables are computed by the control plane (Chapter 5).
• Read the port numbers from the figure. s2: 1 = s3, 2 = s1, 3 = h3, 4 = h4. Mixing up s2's ports is the most common way to lose points.
• "Arriving on port k" means Ingress Port = k in the match. It is not the action.
• "Delivered to h3" means forward(3) at s2, the port h3 is attached to.
• Use
10.1.*.* for "h1 or h2", not two separate rows (both are accepted, but wildcards are shorter).• HW5 P8 needs both directions and both ingress ports for each local host. The h3↔h4 case adds rows 7–8.
• Firewall tables with an allow row and a drop row that overlap need a priority, or the drop could win.
• Actions are forward, drop, modify, send to controller. Don't forget the last one.
• A middlebox is anything on the path doing more than normal IP router work. A plain router is not a middlebox; a NAT router is.
• End-to-end: in-network functions are allowed as a performance enhancement. They just can't replace the end-to-end check.
Quick check
1. What four things make up a generalized-forwarding flow table entry?
Match (header field patterns with wildcards), actions, priority (for overlapping patterns), counters (bytes and packets).2. List the four OpenFlow actions.
Forward to port(s), drop, modify header fields, encapsulate and send to the controller.3. Name the OpenFlow match fields by layer.
Ingress port; link: src MAC, dst MAC, Eth type, VLAN ID, VLAN priority; network: IP src, IP dst, IP protocol, IP ToS; transport: TCP/UDP src port, TCP/UDP dst port.4. Using the slide 4-71 table, a packet arrives with src 1.2.0.5, dst 3.4.0.9. Which rows match, and what decides the action?
Row 1 (dest 3.4.*.* → forward(2)) and row 2 (src 1.2.*.* → drop) both match. The priority field decides. Whichever row has the higher priority wins.5. Write single OpenFlow entries for: (a) send all traffic for 10.2.0.0/16 out port 2; (b) drop all UDP traffic sent by 10.1.0.7; (c) drop HTTP requests (TCP dst port 80).
(a)IP Dst = 10.2.*.* → forward(2), all else *.(b)
IP Src = 10.1.0.7; IP Proto = 17 (UDP) → drop.(c)
IP Proto = 6 (TCP); TCP d-port = 80 → drop.6. New flow-table problem (Figure 4.30). Program s1 so that: datagrams from h1 or h2 to h5 or h6 go via s2 (not the direct link to s3); datagrams arriving from s3 or s2 for h1 or h2 are delivered; h1 and h2 can send to each other.
s1 ports: 1 = s3, 2 = h1, 3 = h2, 4 = s2.| # | Match | Action |
|---|---|---|
| 1 | Ingress Port = 2; IP Src = 10.1.*.*; IP Dst = 10.3.*.* | Forward (4) |
| 2 | Ingress Port = 3; IP Src = 10.1.*.*; IP Dst = 10.3.*.* | Forward (4) |
| 3 | Ingress Port = 1; IP Dst = 10.1.0.1 | Forward (2) |
| 4 | Ingress Port = 4; IP Dst = 10.1.0.1 | Forward (2) |
| 5 | Ingress Port = 1; IP Dst = 10.1.0.2 | Forward (3) |
| 6 | Ingress Port = 4; IP Dst = 10.1.0.2 | Forward (3) |
| 7 | Ingress Port = 3; IP Dst = 10.1.0.1 | Forward (2) |
| 8 | Ingress Port = 2; IP Dst = 10.1.0.2 | Forward (3) |
Trace h2 → h6: arrives port 3, src 10.1.0.2, dst 10.3.0.6 → row 2 → port 4 (s2) ✓ Trace h5 → h1 via s3: arrives port 1, dst 10.1.0.1 → row 3 → port 2 ✓ Trace h1 → h2: arrives port 2, dst 10.1.0.2 → row 8 → port 3 ✓(For the path to finish, s2 would also need
Ingress Port = 2; IP Dst = 10.3.*.* → Forward(1).)7. New firewall variant: at s2, deliver to h4 only TCP traffic from h5 with destination port 80; block everything else to h4.
| Prio | Match | Action |
|---|---|---|
| high | IP Src = 10.3.0.5; IP Dst = 10.2.0.4; IP Proto = 6 (TCP); TCP d-port = 80 | Forward (4) |
| low | IP Dst = 10.2.0.4 | Drop |
8. What do a router, a switch, a firewall and a NAT each match on and do, in match+action terms?
Router: longest dest IP prefix → forward. Switch: dest MAC → forward or flood. Firewall: IP addresses + TCP/UDP ports → permit or deny. NAT: IP address + port → rewrite address and port.9. Define a middlebox and give four examples.
"Any intermediary box performing functions apart from normal, standard functions of an IP router on the data path between a source host and destination host" (RFC 3234). Examples: NAT, firewall/IDS, load balancer, cache.10. What is the "thin waist" of the IP hourglass, and what are its "love handles"?
The waist is IP: the single network-layer protocol every Internet device must run, with many protocols above (TCP, UDP, QUIC, HTTP…) and below (Ethernet, WiFi, fiber…). The love handles are middleboxes (firewalls, caches, NAT) working inside the network at middle age.11. State the end-to-end argument and apply it to reliable transfer.
A function can be implemented completely and correctly only at the end points, with the application's knowledge, so the network can only do an incomplete job. In-network versions are allowed as a performance enhancement. Even with reliable links on every hop, data can be corrupted inside a router, so TCP still checks end to end.12. Where is the intelligence in the 20th-century phone net, the pre-2005 Internet, and the post-2005 Internet?
Phone net: in the network switches. Pre-2005 Internet: at the edge. Post-2005: programmable network devices (SDN) plus massive computing and application infrastructure at the edge.13. What are the three cornerstone beliefs in RFC 1958?
Simple connectivity, IP as the narrow waist, intelligence and complexity at the network edge.← prev · all topics · next →