← all topics

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)

Flow table abstraction (4-71)

Slide example (4-71):

MatchAction
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

  1. Forward the packet to port(s).
  2. Drop the packet.
  3. Modify fields in the header(s).
  4. Encapsulate and forward to the controller.

Header fields you can match

LayerFields
(switch)Ingress port
LinkSrc MAC, Dst MAC, Eth type, VLAN ID, VLAN priority
NetworkIP src, IP dst, IP protocol, IP ToS
TransportTCP/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)

BehaviourNon-wildcard field(s)Action
Destination-based forwarding: datagrams to 51.6.0.8 go out port 6IP Dst = 51.6.0.8port6
Firewall: block everything to TCP port 22 (ssh)TCP d-port = 22drop
Firewall: block everything sent by host 128.119.1.1IP Src = 128.119.1.1drop
Layer-2 forwarding: frames to MAC 22:A7:23:11:E1:02 go out port 3MAC dst = 22:A7:23:11:E1:02port3

Every other field in those rows is *.

One abstraction, many devices (4-75)

DeviceMatchAction
Routerlongest destination IP prefixforward out a link
Switchdestination MAC addressforward or flood
FirewallIP addresses and TCP/UDP port numberspermit or deny
NATIP address and portrewrite 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.

SwitchPort 1Port 2Port 3Port 4
s1s3h1 10.1.0.1h2 10.1.0.2s2
s2s3s1h3 10.2.0.3h4 10.2.0.4
s3h6 10.3.0.6h5 10.3.0.5s1s2

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)

SwitchMatchAction
s3IP Src = 10.3.*.*; IP Dst = 10.2.*.*forward(3) (to s1, not the direct link to s2)
s1ingress port = 1; IP Src = 10.3.*.*; IP Dst = 10.2.*.*forward(4) (to s2)
s2ingress port = 2; IP Dst = 10.2.0.3forward(3) (to h3)
s2ingress port = 2; IP Dst = 10.2.0.4forward(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.

SwitchMatchAction
s2ingress port = 3; IP Dst = 10.1.*.*forward(2)
s2ingress port = 4; IP Dst = 10.1.*.*forward(1)
s3ingress 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.

SwitchMatchAction
s2IP Src = 10.3.*.*; IP Dst = 10.2.0.3forward(3)
s2IP Src = 10.3.*.*; IP Dst = 10.2.0.4forward(4)

With no other entries, anything else arriving at s2 matches nothing and is not delivered.

How to solve: write a flow table

  1. Label the ports of the switch you're programming (table above).
  2. Split the requirement into one rule per (where it comes from, where it goes).
  3. 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".
  4. Action: forward(port of the next hop or host), or drop.
  5. If a specific "allow" rule overlaps a broad "drop" rule, give the allow rule higher priority.
  6. 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:

  1. (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;
  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;
  3. (iii) any arriving datagrams on input ports 1 or 2 and destined to hosts h3 or h4 should be delivered to the host specified;
  4. (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.

#MatchActionWhy
1Ingress Port = 1; IP Src = 10.3.*.*; IP Dst = 10.1.*.*Forward (2)(i): from s3, h5/h6 → h1/h2, send toward s1
2Ingress Port = 2; IP Src = 10.1.*.*; IP Dst = 10.3.*.*Forward (1)(ii): from s1, h1/h2 → h5/h6, send toward s3
3Ingress Port = 1; IP Dst = 10.2.0.3Forward (3)(iii): from s3 to h3
4Ingress Port = 2; IP Dst = 10.2.0.3Forward (3)(iii): from s1 to h3
5Ingress Port = 1; IP Dst = 10.2.0.4Forward (4)(iii): from s3 to h4
6Ingress Port = 2; IP Dst = 10.2.0.4Forward (4)(iii): from s1 to h4
7Ingress Port = 4; IP Dst = 10.2.0.3Forward (3)(iv): h4 → h3
8Ingress Port = 3; IP Dst = 10.2.0.4Forward (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.

  1. (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).
  2. (b) Only TCP traffic is allowed to be delivered to hosts h3 or h4 (i.e., UDP traffic is blocked).
  3. (c) Only traffic destined to h3 is to be delivered (i.e., all traffic to h4 is blocked).
  4. (d) Only UDP traffic from h1 and destined to h3 is to be delivered. All other traffic is blocked.
The official solution file shows "Problem 9" with no content. The tables below are worked out here, not given by the course. Drop rows are written out explicitly. In OpenFlow, a packet that matches no entry isn't delivered anyway, so the drop rows mainly make the intent clear.

(a) Only from h1 (10.1.0.1) and h6 (10.3.0.6)

PrioMatchAction
highIP Src = 10.1.0.1; IP Dst = 10.2.0.3Forward (3)
highIP Src = 10.1.0.1; IP Dst = 10.2.0.4Forward (4)
highIP Src = 10.3.0.6; IP Dst = 10.2.0.3Forward (3)
highIP Src = 10.3.0.6; IP Dst = 10.2.0.4Forward (4)
lowIP Dst = 10.2.0.3 (anything else)Drop
lowIP Dst = 10.2.0.4 (anything else)Drop

(b) Only TCP (IP Proto = 6)

PrioMatchAction
highIP Proto = TCP; IP Dst = 10.2.0.3Forward (3)
highIP Proto = TCP; IP Dst = 10.2.0.4Forward (4)
lowIP Dst = 10.2.0.3Drop
lowIP Dst = 10.2.0.4Drop

(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

MatchAction
IP Dst = 10.2.0.3Forward (3)
IP Dst = 10.2.0.4Drop

(d) Only UDP from h1 to h3

PrioMatchAction
highIP Src = 10.1.0.1; IP Dst = 10.2.0.3; IP Proto = UDPForward (3)
lowIP Dst = 10.2.0.3Drop
lowIP Dst = 10.2.0.4Drop

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)

The IP hourglass (4-80, 4-81)

Architectural principles of the Internet (4-82, RFC 1958)

The end-to-end argument (4-83)

Where's the intelligence? (4-84)

EraIntelligence/computing lives in
20th-century phone netthe 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).

Traps
• 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.
#MatchAction
1Ingress Port = 2; IP Src = 10.1.*.*; IP Dst = 10.3.*.*Forward (4)
2Ingress Port = 3; IP Src = 10.1.*.*; IP Dst = 10.3.*.*Forward (4)
3Ingress Port = 1; IP Dst = 10.1.0.1Forward (2)
4Ingress Port = 4; IP Dst = 10.1.0.1Forward (2)
5Ingress Port = 1; IP Dst = 10.1.0.2Forward (3)
6Ingress Port = 4; IP Dst = 10.1.0.2Forward (3)
7Ingress Port = 3; IP Dst = 10.1.0.1Forward (2)
8Ingress Port = 2; IP Dst = 10.1.0.2Forward (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.
PrioMatchAction
highIP Src = 10.3.0.5; IP Dst = 10.2.0.4; IP Proto = 6 (TCP); TCP d-port = 80Forward (4)
lowIP Dst = 10.2.0.4Drop
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 →