240 likes | 414 Views
Computer Networking Inside a Router. How a Router Forwards Datagrams. 128.17.20.1. e.g. 128.9.16.14 => Port 2. R2. Prefix. Next-hop. Port. 3. 65/8. 128.17.16.1. R1. R3. 1. 2. 128.9/16. 128.17.14.1. 2. 2. 128.9.16/20. 128.17.14.1. 3. 7. 128.9.19/24. 128.17.10.1. 128.9.25/24.
E N D
How a Router Forwards Datagrams 128.17.20.1 e.g. 128.9.16.14 => Port 2 R2 Prefix Next-hop Port 3 65/8 128.17.16.1 R1 R3 1 2 128.9/16 128.17.14.1 2 2 128.9.16/20 128.17.14.1 3 7 128.9.19/24 128.17.10.1 128.9.25/24 128.17.14.1 2 R4 128.9.176/20 128.17.20.1 1 142.12/19 128.17.16.1 3 128.17.16.1 Forwarding/routing table
How a Router Forwards Datagrams • Every datagram contains a destination address. • The router determines the prefix to which the address belongs, and routes it to the“Network ID” uniquely identifies a physical network. • All hosts and routers sharing a Network ID share same physical network.
Forwarding Datagrams • Is the datagram for a host on directly attached network? • If no, consult forwarding table to find next-hop.
What a High Performance Router Looks Like 19” 19” Capacity: 160Gb/sPower: 4.2kW Capacity: 80Gb/sPower: 2.6kW 6ft 3ft 2ft 2.5ft Juniper M160 Cisco GSR 12416
Inside a Router 3. 1. Output Scheduling 2. Forwarding Table Interconnect Forwarding Decision Forwarding Table Forwarding Decision Forwarding Table Forwarding Decision
Forwarding in an IP Router • Lookup packet DA in forwarding table. • If known, forward to correct port. • If unknown, drop packet. • Decrement TTL, update header Checksum. • Forward packet to outgoing interface. • Transmit packet onto link. Question: How is the address looked up in a real router?
Making a Forwarding DecisionClass-based addressing IP Address Space Class A Class B Class C D Class A Routing Table: Class B 212.17.9.4 Exact Match Class C 212.17.9.0 Port 4 212.17.9.0 Exact Match: There are many well-known ways to find an exact match in a table.
Forwarding Engine Packet header payload Router Destination Address Routing Lookup Data Structure Outgoing Port Forwarding Table Dest-network Port 65.0.0.0/8 3 128.9.0.0/16 1 149.12.0.0/19 7
The Search Operation is not a Direct Lookup (Outgoing port, label) (Incoming port, label) Memory Address Data IP addresses: 32 bits long 4G entries
Associative Lookups“Contents addressable memory” (CAM) • Advantages: • Simple • Disadvantages • Slow • High Power • Small • Expensive Associative Memory or CAM Port Number Network Address Port Number Search Data Hit? 32
The Search Operation is also not an Exact Match Search • Hashing • Balanced binary search trees Exact match search:search for a key in a collection of keys of the same length. Relatively well studied data structures:
Associated Data { Hit? Address log2N Hashed Lookups Search Data Hashing Function 16 32 Data Address Memory
Lookups Using HashingAn example Memory #1 #2 #3 #4 Search Data Associated Data #1 #2 16 Hashing Function Hit? 32 #1 #2 #3 Linked list of entrieswith same hash key.
Lookups Using Hashing • Advantages: • Simple • Expected lookup time can be small • Disadvantages • Non-deterministic lookup time • Inefficient use of memory
Binary Search Trie: (“reTRIEval”) 0 1 log2N 0 1 0 1 010 111 N entries Requires 32 memory references, regardless of number of addresses. Trees and Tries Binary Search Tree: < > < > < >
Search TriesMultiway tries reduce the number of memory references 16-ary Search Trie 0000, ptr 1111, ptr 1111, ptr 0000, 0 1111, ptr 0000, 0 000011110000 111111111111 Question: Why not keep increasing the degree of the trie?
128.9.19/24 128.9.25/24 128.9.16/20 128.9.176/20 Classless AddressingCIDR 128.9/16 0 232-1 128.9.16.14 Most specific route = “longest matching prefix” Question: How can we look up addresses if they are not an exact match?
128.9.16.14 Example Forwarding Table Prefix length IP prefix: 0-32 bits 142.12.0.0/19 128.9.0.0/16 65.0.0.0/8 0 232-1 224 65.0.0.0 65.255.255.255
128.9.16.14 Prefixes can Overlap Longest matching prefix 128.9.176.0/24 128.9.16.0/21 128.9.172.0/21 142.12.0.0/19 65.0.0.0/8 128.9.0.0/16 0 232-1 Routing lookup:Find the longest matching prefix (aka the most specific route) among all prefixes that match the destination address.
Ternary CAMs Associative Memory Value Mask Port 10.1.1.32 255.255.255.255 1 255.255.255.0 Port 10.1.1.0 2 255.255.255.0 10.1.3.0 3 10.1.0.0 255.255.0.0 4 10.0.0.0 255.0.0.0 4 Priority Encoder Note: Most specific routes appear closest to top of table
Longest prefix matches using Binary Tries Example Prefixes: 0 1 a) 00001 b) 00010 c) 00011 d) 001 e) 0101 g f d f) 011 g) 100 h i h) 1010 e i) 1100 j) 11110000 a b c j
Patricia Tries Example Prefixes: 0 1 a) 00001 b) 00010 c) 00011 Skip 5 j d) 001 e) 0101 g f d f) 011 g) 100 h i h) 1010 e i) 1100 j) 11110000 a b c
Lookup Performance Required Line Line Rate Pktsize=40B Pktsize=240B T1 1.5Mbps 4.68 Kpps 0.78 Kpps OC3 155Mbps 480 Kpps 80 Kpps OC12 622Mbps 1.94 Mpps 323 Kpps OC48 2.5Gbps 7.81 Mpps 1.3 Mpps OC192 10 Gbps 31.25 Mpps 5.21 Mpps