Title: CS 352 Network Layer
1CS 352-Network Layer
- Dept. of Computer Science
- Rutgers University
2Chapter 4 Network Layer
- 4. 1 Introduction
- 4.2 Virtual circuit and datagram networks
- 4.3 Whats inside a router
- 4.4 IP Internet Protocol
- Datagram format
- IPv4 addressing
- ICMP
- IPv6
- 4.5 Routing algorithms
- Link state
- Distance Vector
- Hierarchical routing
- 4.6 Routing in the Internet
- RIP
- OSPF
- BGP
- 4.7 Broadcast and multicast routing
3Network layer
- transport segment from sending to receiving host
- on sending side encapsulates segments into
datagrams - on receiving side, delivers segments to transport
layer - network layer protocols in every host, router
- Router examines header fields in all IP datagrams
passing through it
4Key Network-Layer Functions
- analogy
- routing process of planning trip from source to
destination - forwarding process of getting through single
interchange
- forwarding move packets from routers input to
appropriate router output - routing determine route taken by packets from
source to dest. - Routing algorithms
5Forwarding vs Routing (cont)
- Routing is deciding which entire path to take
- E.g. From Rutgers to Manhattan
- Route 1 Hoes ln north, Centennial Ave, 287,
GSP, Rt. 78, Route 1/9, Holland tunnel - Route 2 Rt. 18 south, Turnpike north, Lincoln
tunnel - Factors Length, cost, congestion
- Forwarding is the route lookup once the routing
decision has been made - Youre at the intersection of Rt. 18 the
Turnpike. Which ramp to take? - Routing and Forwarding functions are typically
decoupled in real systems
6 Forwarding
- A forwarding algorithm performs the lookup of
address to output port - In connection-oriented service, the forwarding
algorithm is performed by switches and only
during connection setup - In connectionless service, the forwarding
algorithm is performed by routers every time a
packet arrives
7The Internet Protocol (IP)
- Provides delivery of packets from one host in the
Internet to any other host in the Internet, even
if the hosts are on different networks - It is layer-3 in the OSI model.
- Internet packets are called datagrams and may
be up to 64 kilobytes in length - although they are typically much smaller
8 IP Packet Format
32 bits
Ver.
IHL
Type of Serv.
Total Length
Identification
Fragment Offset
D F
M F
Time to Live
Protocol
Header checksum
Source address
Destination address
Options (0 or more 32-bit words)
Data (0 to 65,515 bytes)
9IP Packet Fields
- Version
- The IP version number (currently 4)
- IHL
- IP Header Length in 32-bit words
- Type of Service
- Contains priority information, rarely used
- Total Length
- The total length of the datagram in bytes
- Includes header
10IP Packet Fields (contd)
- Identification
- When an IP packet is segmented into multiple
fragments, each fragment is given the same
identification - This field is used to reassembly fragments
- DF
- Dont Fragment
- MF
- More Fragments
- When a packet is fragmented, all fragments except
the last one have this bit set
11IP Packet Fields (contd)
- Fragment offset
- The fragments position within the original
packet - Time to Live
- Hop count, decremented each time the packet
reaches a new router - When hop count 0, packet is discarded
- Protocol
- Identifies which transport layer protocol is
being used for this packet - Header Checksum
- Verifies the contents of the IP header
- Not polynomial-based
12IP Packet Fields (contd)
- Source and Destination Addresses
- Uniquely identify sender and receiver of the
packet - Options
- Up to 40 bytes in length
- Used to extend functionality of IP
- Examples source routing, security, record route
13IP Addresses
- 32 bits long
- Notation
- Each byte is written in decimal in MSB order,
separated by decimals - Example 128.195.1.80
- Special Address
- Loopback (to self) address is 127.0.0.1
- Broadcast is all 1s (255.255.255.255)
14IP Address Classes (old)
Class
32 bits
0
Net
Type of Serv.
Host
A
10
Net
Host
B
110
Net
Host
C
1110
Multicast address
D
11110
Reserved
E
15IP Address Classes
- Class A
- For very large organizations
- 16 million hosts allowed
- Class B
- For large organizations
- 65 thousand hosts allowed
- Class C
- For small organizations
- 255 hosts allowed
- Class D
- Multicast addresses
- No network/host hierarchy
16IP Address Hierarchy
- Note that Class A, Class B, and Class C addresses
only support two levels of hierarchy - Each address contains a network and a host
portion, meaning two levels of hierarchy - However, the host portion can be further split
into subnets by the address class owner - This allows for more than 2 levels of hierarchy
17Subnetting
Example Class B address with 8-bit subnetting
16 bits
8 bits
8 bits
Host id
Subnet id
Network id
Example Address
165.230
.24
.8
18Subnet Masks
Subnet masks allow hosts to determine if another
IP address is on the same subnet or the same
network
16 bits
8 bits
8 bits
Host id
Subnet id
Network id
1111111111111111
11111111
00000000
Mask
255.255
.255
.0
19Subnet Masks (contd)
Assume IP addresses A and B share subnet mask M.
Are IP addresses A and B on the same subnet?
1. Compute (A and M). 2. Compute (B and M). 3. If
(A and M) (B and M) then A and B are on
the same subnet.
Example A and B are class B addresses A
165.230.82.52 B 165.230.24.93 M
255.255.255.0
Same network? Same subnet?
20IP Forwarding
How do you get a packet from one network to
another?
?
21IP Forwarding (contd)
Answer with a series of routers
Network Cloud
R
R
22IP Forwarding
- Single-hop case
- Assumes hosts are connected by a local area
network supporting broadcast at layer-2 - Solution Use the layer-2 protocols broadcast
function to find the layer-2 address of the
destination (ARP) - Multi-hop case
- Find the IP address of the next hop
- Using routing tables
- Use ARP to find the layer-2 address of the next
hop
23ARP
- Address Resolution Protocol
- Returns a MAC sublayer (layer-2) address when
given an Internet address - ARP assumes the Layer-2 network (LAN) supports
broadcast - Commonly used so that two hosts can communicate
using IP addresses instead of Layer-2 (MAC
sublayer) addresses
24ARP (contd)
ARP packet containing 128.195.1.38? broadcast
to all hosts
ARP
Ethernet Address 0523f43de104 IP
Address 128.195.1.20
Ethernet Address 9822eef1901a IP
Address 128.195.1.38
Ethernet Address 12042c6e119c IP
Address 128.195.1.122
Wants to transmit to 128.195.1.38
Ignored
Answered
25ARP (contd)
ARP response packet containing 9822eef1901a
Repl
Ethernet Address 0523f43de104 IP
Address 128.195.1.20
Ethernet Address 9822eef1901a IP
Address 128.195.1.38
Ethernet Address 12042c6e119c IP
Address 128.195.1.122
26RARP
- Reverse Address Resolution Protocol
- RARP performs the inverse action of ARP
- RARP returns an IP address for a given MAC layer
address - Operationally, RARP is the same as ARP
27Multi-Hop Forwarding Example
R1
R2
R3
N1
N2
N3
N4
Dest
Next hop
Routing table _at_ R2
Actual routing table contains IP addresses, Flags
indicating type of entries, net mask etc.
28Searching the IP routing table
- First, search for a matching host address
- Flag H is set
- Second, search for a matching network address
- Need to know the number of bits to use for
network ID - Third, search for a default entry
- Execute netstat -rn on your machine and find the
contents of the routing table - Default entry allows for a single entry for a
list of entries that have the same next-hop value
29Sample routing table
- Destination Gateway Flags
Refs Use Netif Expire - default 165.230.198.65 UGSc
21 31 en0 - 127.0.0.1 127.0.0.1 UH
11 11630 lo0 - 165.230.198.64/26 link4 UCS
2 0 en0 - 165.230.198.65 link4 UHLW
1 0 en0 - 165.230.198.118 127.0.0.1 UHS
0 0 lo0 - 169.254 link4 UCS
0 0 en0 - 192.168.0/23 link5 UCS
1 0 en1 - 192.168.0.1 045a8d8cc9 UHLW
1 2 en1 1200 - 192.168.0.247 127.0.0.1 UHS
0 0 lo0 - Uup, Hhost, Ggateway, Sstatic, Luse link
Layer
30Problems with Class-based Routing
- Too many small networks requiring multiple class
C addresses - Running out of class B addresses, not enough nets
in class A - Hack is to assign blocks of class Cs
- Addressing strategy must allow for greater
diversity of network sizes
31IP addressing CIDR
- CIDR Classless InterDomain Routing
- subnet portion of address of arbitrary length
- address format a.b.c.d/x, where x is bits in
subnet portion of address
32Reducing Routing Table Size
Without CIDR
With CIDR
200.71.0.0 200.71.1.0 200.71.2.0 .. 200.71.255.0
200.71.0.0/16
33CIDR
- Address format . The prefix
denotes the upper P bits of the IP address. - Can be used to specify arbitrary blocks of
addresses - Say an ISP has 192.5.48.0, 192,5.49.0,192.5.50.0,1
92, 51.0 then the IP address advertised will be
192.5.48.0/22 - An ISP can obtain a block of addresses and
partition this further to its customers - Say an ISP has 200.8.4.24/24 address (256
addresses). He has another customer who needs
only 4 addresses from 200.8.4.24 then that
block can be specified as 200.8.4.24/30
34Hierarchical addressing route aggregation
Hierarchical addressing allows efficient
advertisement of routing information
Organization 0
Organization 1
Send me anything with addresses beginning
200.23.16.0/20
Organization 2
Fly-By-Night-ISP
Internet
Organization 7
Send me anything with addresses beginning
199.31.0.0/16
ISPs-R-Us
35Hierarchical addressing more specific routes
ISPs-R-Us has a more specific route to
Organization 1
Organization 0
Send me anything with addresses beginning
200.23.16.0/20
Organization 2
Fly-By-Night-ISP
Internet
Organization 7
Send me anything with addresses beginning
199.31.0.0/16 or 200.23.18.0/23
ISPs-R-Us
Organization 1
36What do routers look like?
Access routers e.g. ISDN, ADSL
Core ATM switch
Core router e.g. OC48c POS
37Basic Components
Control Plane
Datapath per-packet processing
38Per-packet processing in an IP Router
- 1. Accept packet arriving on an incoming link.
- 2. Lookup packet destination address in the
forwarding table, to identify outgoing port(s). - 3. Manipulate packet header e.g., decrement TTL,
update header checksum. - 4. Send packet to the outgoing port(s).
- 5. Buffer packet in the queue.
- 6. Transmit packet onto outgoing link.
39General Switch Model
Interconnect
40IP Switch Model
2. Interconnect
1. Ingress
3. Egress
Forwarding Table
Forwarding Decision
Forwarding Table
Forwarding Decision
Forwarding Table
Forwarding Decision
41Forwarding 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
42The Search Operation is not a Direct Lookup
(Outgoing port, label)
(Incoming port, label)
Address
Memory
Data
IP addresses 32 bits long ? 4G entries
43The Search Operation is also not an Exact Match
Search
Exact match search search for a key in a
collection of keys of the same length.
Relatively well studied data structures
- Hashing
- Balanced binary search trees
44Example 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
45Prefixes 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
(the most specific route) among all prefixes that
match the destination address.
46Difficulty of Longest Prefix Match
128.9.176.0/24
128.9.172.0/21
128.9.16.0/21
142.12.0.0/19
128.9.0.0/16
65.0.0.0/8
47Lookup Rate Required
40B packets (Mpps)
Line-rate (Gbps)
Line
Year
1.94
0.622
OC12c
1998-99
7.81
2.5
OC48c
1999-00
31.25
10.0
OC192c
2000-01
125
40.0
OC768c
2002-03
48Size of the Forwarding Table
Number of Prefixes
95
96
97
98
99
00
Year
- Source http//www.telstra.net/ops/bgptable.html
49Internal Interconnects
1. Multiplexers
2. Tri-State Devices
3. Shared Memory
50InterconnectsTwo basic techniques
Input Queueing
Output Queueing
Usually a non-blocking switch fabric (e.g.
crossbar)
Usually a fast bus
51Input buffered swtich
Internconnect
- Independent routing logic per input
- FSM
- Scheduler logic arbitrates each output
- priority, FIFO, random
- Head-of-line blocking problem
52Input QueueingHead of Line Blocking
Delay
Load
100
53Head of Line Blocking
54(Virtual) Output Buffered Switch
N buffers per input
55Virtual output queues
56Input QueueingVirtual Output Queues
Delay
Load
100
57ICMP
- Protocol for error detection and reporting
- tightly coupled with IP, unreliable
- ICMP messages delivered in IP packets
- ICMP functions
- Announce network errors
- Announce network congestion
- Assist trouble shooting
- Announce timeouts
58ICMP MSG
IP header Source, Destination Address, TTL, ...
ICMP MSG Message type, Code, Checksum, Data
Message type examples (Figure 6.3 in Stevens
book)
0 (8) echo request (reply) 3 destination
unreachable 4 source quench 11 time exceeded
59Specific uses of ICMP
- Echo request reply
- Can be used to check if a host is alive
- Address mask request/reply
- Learn the subnet mask
- Destination unreachable
- Invalid address and/or port
- TTL expired
- Routing loops, or too far away
60Ping
- Uses ICMP echo request/reply
- Source sends ICMP echo request message to the
destination address - Echo request packet contains sequence number and
timestamp - Destination replies with an ICMP echo reply
message containing the data in the original echo
request message - Source can calculate round trip time (RTT) of
packets - If no echo reply comes back then the destination
is unreachable
61Ping (contd)
R1
R2
R3
A
B
Echo request
Time
Echo reply
62Traceroute
- Traceroute records the route that packets take
- A clever use of the TTL field
- When a router receives a packet, it decrements
TTL - If TTL0, it sends an ICMP time exceeded message
back to the sender - To determine the route, progressively increase
TTL - Every time an ICMP time exceeded message is
received, record the senders (routers) address - Repeat until the destination host is reached or
an error message occurs
63Traceroute (contd)
Te Time exceeded Pu Port unreachable
R1
R2
R3
A
B
TTL1, Dest B, port invalid
Te (R1)
TTL2, Dest B
Te (R2)
Time
TTL3, Dest B
Te (R3)
TTL4, Dest B
Pu (B)
64Traceroute Examle
- 1 lcsr-gw (128.6.13.21) 1.206 ms 0.973 ms
0.782 ms - 2 rucs-gw (165.230.212.129) 0.697 ms 0.569 ms
0.571 ms - 3 transition2-gw (165.230.12.145) 2.786 ms
0.994 ms 0.769 ms - 4 rutgers-gw.Rutgers.EDU (198.151.130.209)
1.726 ms 2.048 ms Vl1000-sr02-hil - l012-svcs.Rutgers.EDU (198.151.130.14) 1.278 ms
- 5 rutgers-gw.Rutgers.EDU (198.151.130.209)
1.755 ms 1.241 ms 1.828 ms - 6 198.151.130.226 (198.151.130.226) 2.748 ms
3.070 ms 2.640 ms - 7 clev-nycm.abilene.ucaid.edu (198.32.8.29)
15.162 ms 14.619 ms 14.663 ms - 8 ipls-clev.abilene.ucaid.edu (198.32.8.25)
21.220 ms 22.497 ms 21.450 ms - 9 kscy-ipls.abilene.ucaid.edu (198.32.8.5)
30.257 ms 30.604 ms 30.969 ms - 10 dnvr-kscy.abilene.ucaid.edu (198.32.8.13)
40.823 ms 41.181 ms 41.076 ms - 11 snva-dnvr.abilene.ucaid.edu (198.32.8.1)
65.436 ms 66.068 ms 65.569 ms - 12 198.32.249.161 (198.32.249.161) 65.673 ms
65.771 ms 66.006 ms - 13 BERK--SUNV.POS.calren2.net (198.32.249.13)
67.183 ms 67.131 ms 66.858 ms - 14 pos1-0.inr-000-eva.Berkeley.EDU (128.32.0.89)
67.192 ms 66.749 ms 67.720 - ms
- 15 vlan198.inr-201-eva.Berkeley.EDU
(128.32.0.194) 67.373 ms 67.067 ms 67.82 - 1 ms
- 16 fast8-0-0.inr-210-cory.Berkeley.EDU
(128.32.255.122) 67.634 ms 68.735 ms