Network PDF
Network PDF
Chapter goals:
Network Layer • Understand principles behind network layer
services:
– network layer service models
CS 3516 – Computer Networks
– forwarding versus routing
– how a router works
– routing (path selection)
– dealing with scale
• Instantiation, implementation in the Internet
Network Layer
Chapter 4: Network Layer
• Transport segment from
application
transport
• •
data link
•
data link data link
encapsulates segments
physical physical
data link
physical
• •
physical physical
– Hierarchical routing
4.3 What’s inside a On rcving side,
side delivers
router • 4.6 Routing in the segments to transport
network
t k
data link
network
t k
data link
physical
•
physical
Internet
network
– RIP
•
application
Protocol Network layer protocols network transport
– OSPF
data link network
network
– Datagram format in every host and router
physical data link
network data link
physical
– BGP
•
data link physical
– IPv4 addressing
physical
Router examines header
– ICMP • 4.7 Broadcast and
fields in all IP datagrams
– IPv6 multicast routing
passing through it
analogy:
packets from local forwarding table
source to destination
1001 1
output
to destination
– routing algorithms
1
Connection Setup Network Service Model
Q: What service model for “channel” transporting
• 3rd important function in some network architectures:
datagrams from sender to receiver?
– ATM, frame relay, X.25
• Before datagrams flow, two end hosts and intervening Example services for Example services for a flow
routers establish virtual connection individual datagrams: of datagrams:
– routers get involved
l • Guaranteed delivery • In-order
In order datagram
• Network vs Transport Layer connection service: • Guaranteed delivery delivery
with less than 40 • Guaranteed minimum
– network: between two hosts (may also involve msec delay bandwidth to flow
intervening routers in case of Virtual Circuits
(VCs))
• Restrictions on changes
in inter-packet spacing
– transport: between two processes
connection service
• Call setup, teardown for each call before data can flow
• Analogous to the transport-layer services, • Each packet carries VC identifier (not destination host
but: address)
– service: host-to-host
• Every router on source-dest path maintains “state” for
each passing connection
– no choice: network provides one or the other • Link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable service)
– implementation: in network core
2
Forwarding Table
VC Implementation VC number
A VC consists of: 12 22 32
1 3
1. Path from source to destination 2
(Forwarding table in
2. VC numbers, one number for each link along interface
northwest router)
path number
•
1 97 3 87
VC number can be changed on each link. … … … …
– New VC number comes from forwarding
Routers maintain connection state information!
table
Datagram Networks
Virtual Circuits: Signaling Protocols • Must do call setup at network layer
application
transport 5. Data flow begins 6. Receive data application application
3. Accept call transport application
network 4. Call connected transport
2. incoming call network transport
data link 1. Initiate call network 1. Send data 2. Receive data network
data link data link
physical
physical data link
physical
physical
4 billion
Forwarding Table possible entries
Longest Prefix Matching
Destination Address Range Link Interface Prefix Match Link Interface
11001000 00010111 00010000 00000000 11001000 00010111 00010 0
through 0 11001000 00010111 00011000 1
11001000 00010111 00010111 11111111 11001000 00010111 00011 2
otherwise 3
11001000 00010111 00011000 00000000
through 1 Examples
11001000 00010111 00011000 11111111
DA: 11001000 00010111 00010110 10100001 Which interface?
11001000 00010111 00011001 00000000
through 2
DA: 11001000 00010111 00011000 10101010 Which interface?
11001000 00010111 00011111 11111111
otherwise 3
3
Datagram or VC network: Why?
Chapter 4: Network Layer
Internet (datagram) ATM (VC)
• Data exchange among • Evolved from telephony • 4. 1 Introduction • 4.5 Routing algorithms
computers
• Human conversation: • 4.2 Virtual circuit and – Link state
– “Elastic” service, no datagram networks – Distance Vector
– strict timing, reliability
strict timing req.
•
requirements • 4.3 What’s inside a – Hierarchical routing
“Smart”
Smart end systems
(computers)
– need for guaranteed router • 4.6 Routing in the
service
– Can adapt, perform
• “Dumb” end systems • 4.4 IP: Internet Internet
control, error recovery – RIP
– telephones Protocol
– Simple inside network, – OSPF
– complexity inside – Datagram format
complexity at “edge” – BGP
network – IPv4 addressing
• Many link types
– ICMP • 4.7 Broadcast and
– Different characteristics multicast routing
– IPv6
– Uniform service difficult
Physical layer:
bit-level
b l l reception
Data link layer: Decentralized switching:
e.g., Ethernet • Given datagram destination, lookup
(see chapter 5) output port using forwarding table in
input port memory
• Goal: complete input port processing at
‘line speed’
• Queuing: if datagrams arrive faster than
forwarding rate into switch fabric
4
Input Port Queuing
How Much Buffering?
• Fabric slower than input ports combined Æ queueing
may occur at input queues
• RFC 3439 rule of thumb: average buffering • Head-of-the-Line (HOL) blocking: queued datagram at
equal to “typical” RTT (say 250 msec) times front of queue prevents others in queue from moving
link capacity C (so, RTT•C) forward
– e.g.,
e g C = 10 Gps link Æ 2.5
2 5 Gbit buffer • Queueing delay and loss due to input buffer overflow!
• Recent recommendation: with N flows,
buffering equal to
RTT .C
N
• – Hierarchical routing
•addressing conventions
4.3 What’s inside a
•path selection
•
•datagram format
4.6 Routing in the Network
N t k •RIP
RIP, OSPF
OSPF, BGP
router •packet handling conventions
Layer
• 4.4 IP: Internet Internet forwarding
ICMP protocol
– RIP table
Protocol •error reporting
– OSPF
•router “signaling”
– Datagram format
– BGP
– IPv4 addressing Link layer
– ICMP • 4.7 Broadcast and
Physical layer
– IPv6 multicast routing
IP Datagram Format
Chapter 4: Network Layer IP protocol version
number
32 bits
total datagram
length (bytes)
header length head. type of
ver
• •
(bytes) len service length
4. 1 Introduction 4.5 Routing algorithms
for
“type” of data fragment
•
flgs fragmentation/
16-bit identifier offset
4.2 Virtual circuit and – Link state max number time to upper
reassembly
header
datagram networks – Distance Vector remaining hops live layer checksum
•
(decremented at
– Hierarchical routing
4.3 What’s inside a each router)
•
32 bit source IP address
• Internet
upper layer protocol
4.4 IP: Internet to deliver payload to
Options (if any) E.g. timestamp,
– RIP
Protocol
record route
5
IP Fragmentation & Reassembly IP Fragmentation and Reassembly
• Network links have MTU (max. length ID fragflag offset
transfer size) - largest =4000 =x =0 =0
possible link-level frame. fragmentation: Example
in: one large datagram
– different link types, • 4000 byte datagram One large datagram becomes
out: 3 smaller
different MTUs • MTU = 1500 bytes several smaller datagrams
•
datagrams
large IP datagram divided
((“fragmented”)
g ) within net length ID fragflag offset
– One datagram becomes =1500 =x =1 =0
several datagrams reassembly 1480 bytes in
– “Reassembled” only at final data field length ID fragflag offset
destination =1500 =x =1 =185
offset =
– IP header bits used to
1480/8
identify, order related length ID fragflag offset
fragments =1040 =x =0 =370
IP Addressing: Introduction
Chapter 4: Network Layer
• IP address: 32-bit 223.1.1.1
• IP address: 223.1.1.1
Recipe
– subnet part (high
• To determine subnets,
223.1.2.1
223.1.1.2
order bits) 223.1.1.4 223.1.2.9
– host part (low order detach each interface
bits) 223.1.2.2 from its host or
•
223.1.1.3 223.1.3.27
What’ss a subnet ?
What router,, creating
g
– device interfaces with subnet islands of isolated
same subnet part of IP 223.1.3.2 networks
• Each isolated network
223.1.3.1
address
– can physically reach
is called a subnet
223.1.3.0/24
each other without
intervening router network consisting of 3 subnets Subnet mask: /24
6
Subnets 223.1.1.2
IP addressing: CIDR
How many? 223.1.1.1 223.1.1.4
Network Layer
7
DHCP: Example
DHCP: more than IP address DHCP DHCP • Connecting laptop needs
DHCP UDP its IP address, addr of
IP
first-hop router, addr of
DHCP
• Ethernet demux’ed to IP
demux’ed, UDP demux’ed to
DHCP
Phy router for client, name & Hops: 0 request Next server IP address: 192.168.1.1 (192.168.1.1)
Relay agent IP address: 0.0.0.0 (0.0.0.0)
IP address of DNS server
Transaction ID: 0x6b3a11b7
Seconds elapsed: 0 Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
Bootp flags: 0x0000 (Unicast) Server host name not given
Client IP address: 0.0.0.0 (0.0.0.0) Boot file name not given
• Encapsulation of DHCP Your (client) IP address: 0.0.0.0 (0.0.0.0) Magic cookie: (OK)
server, frame forwarded Next server IP address: 0.0.0.0 (0.0.0.0) Option: (t=53,l=1) DHCP Message Type = DHCP ACK
DHCP Relay agent IP address: 0.0.0.0 (0.0.0.0) Option: (t=54,l=4) Server Identifier = 192.168.1.1
to client,
client demux ing up to
demux’ing
DHCP
Client MAC address: Wistron_23:68:8a
Wistron 23:68:8a (00:16:d3:23:68:8a) Option: (t=1,l=4)
(t=1 l=4) Subnet Mask = 255.255.255.0
255 255 255 0
DHCP UDP
DHCP IP DHCP at client Server host name not given
Boot file name not given
Option: (t=3,l=4) Router = 192.168.1.1
Option: (6) Domain Name Server
DHCP Eth router • Client now knows its IP Magic cookie: (OK)
Option: (t=53,l=1) DHCP Message Type = DHCP Request
Length: 12; Value: 445747E2445749F244574092;
IP Address: 68.87.71.226;
Phy
(runs DHCP) address, name and IP Option: (61) Client identifier IP Address: 68.87.73.242;
address of DSN server, IP
DHCP IP Address: 68.87.64.146
Length: 7; Value: 010016D323688A;
Hardware type: Ethernet Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net."
address of its first-hop Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
router Option: (t=50,l=4) Requested IP Address = 192.168.1.101
Option: (t=12,l=5) Host Name = "nomad"
Option: (55) Parameter Request List
Length: 11; Value: 010F03062C2E2F1F21F92B
1 = Subnet Mask; 15 = Domain Name
3 = Router; 6 = Domain Name Server
44 = NetBIOS over TCP/IP Name Server
……
– allocates
ll t addresses
dd 138.76.29.7
– assigns domain names, resolves disputes All datagrams leaving local Datagrams with source or
network have same single source NAT destination in this network
IP address: 138.76.29.7, have 10.0.0/24 address for
different source port numbers source, destination (as usual)
8
NAT: Network Address Translation NAT: Network Address Translation
• Implementation: NAT router must:
• Motivation: local network uses just one IP
address as far as outside world is concerned: – outgoing datagrams: replace (source IP address, port #)
of every outgoing datagram to (NAT IP address, new
– Range of addresses not needed from ISP: just one port #)
IP address for all devices • (remote clients/servers will respond using (NAT IP
address new port #) as destination addr)
address,
– Can change addresses of devices in local network – remember (in NAT translation table) every (source IP
without notifying outside world address, port #) to (NAT IP address, new port #)
translation pair
– Can change ISP without changing addresses of
– incoming datagrams: replace (NAT IP address, new port
devices in local network #) in dest fields of every incoming datagram with
– Devices inside local net not explicitly addressable, corresponding (source IP address, port #) stored in
NAT table
visible by outside world (a security plus)
2
S: 138.76.29.7, 5001
1
– Routers should only process up to layer 3
D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
– Violates “end-to-end” argument (complexity
138.76.29.7 S: 128.119.40.186, 80
4 in ends)
• NAT possibility must be taken into account by
D: 10.0.0.1, 3345
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: Reply arrives
dest. address:
changes datagram app designers, e.g., P2P applications
dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345 – Address shortage should instead be solved by
IPv6
9
NAT Traversal Problem Chapter 4: Network Layer
• Solution 3: relaying (used in Skype)
1. NATed client establishes connection to relay • 4. 1 Introduction • 4.5 Routing algorithms
2. External client connects to relay • 4.2 Virtual circuit and – Link state
datagram networks – Distance Vector
3. Relay bridges packets between to connections
• 4.3 What’s inside a – Hierarchical routing
router • 4.6 Routing in the
•
2. connection to
relay initiated 1. connection to 4.4 IP: Internet Internet
– RIP
Protocol
by client relay initiated
10.0.0.1
by NATted host
– OSPF
Client
3. relaying – Datagram format
established – BGP
– IPv4 addressing
•
138.76.29.7 NAT
router – ICMP 4.7 Broadcast and
– IPv6 multicast routing
• Used by hosts & routers to Type Code description • Source sends series of • When ICMP message
communicate network-level 0 0 echo reply (ping) UDP segments to dest arrives, source
calculates RTT
3 0 dest. network unreachable
information – First has TTL =1
•
3 1 dest host unreachable
– error reporting: – Second has TTL=2, etc.
3 2 dest protocol unreachable Traceroute does this 3
unreachable host, network, y port
– Unlikely p number
3 3 dest p
port unreachable
times for each router
port, protocol
– echo request/reply (used
3
3
6
7
dest network unknown
dest host unknown
• When nth datagram Stopping criterion
by ping) 4 0 source quench (congestion arrives to nth router: • UDP segment eventually
• Network-layer “above” IP: control - not used) – Router discards datagram arrives at destination host
– ICMP msgs carried in IP
8
9
0
0
echo request (ping)
route advertisement
– And sends to source ICMP
message (type 11, code 0)
• Destination returns ICMP
datagrams “host unreachable” packet
•
10 0 router discovery
ICMP message: type, code plus – Message includes name of
11 0 TTL expired (type 3, code 3)
router & IP address
first 8 bytes of IP datagram
causing error
12 0 bad IP header • When source gets this
ICMP, stops
10
IPv6 Header Other Changes from IPv4
Priority: identify priority among datagrams in flow
Flow Label: identify datagrams in same “flow” • Checksum: removed entirely to reduce
(concept of “flow” not well defined). processing time at each hop
Next header: identify upper layer protocol for data • Options: allowed, but outside of header,
indicated by “Next Header” field
• ICMPv6: new version of ICMP
– additional message types, e.g. “Packet Too
Big”
– multicast group management functions
• To help transition Æ Tunneling: IPv6
carried as payload in IPv4 datagram among
IPv4 routers
• •
routing algorithm
4. 1 Introduction 4.5 Routing algorithms
• 4.2 Virtual circuit and – Link state local forwarding table
•
0100 3
– Hierarchical routing
4.3 What’s inside a
0101 2
•
0111 2
Remark: Graph abstraction is useful in other network Question: What’s the least-cost path between u and z ?
contexts
Example: P2P, where N is set of peers and E is set of Routing algorithm: algorithm that finds least-cost path
TCP connections
11
Routing Algorithm Classification Chapter 4: Network Layer
Global or decentralized Static or dynamic?
information? Static: • 4. 1 Introduction • 4.5 Routing algorithms
Global: • Routes change slowly over • 4.2 Virtual circuit and – Link state
• All routers have complete time
datagram networks – Distance Vector
topology, link cost info Dynamic:
• “link • Routes change more quickly • 4.3 What’s inside a – Hierarchical routing
link state
state” algorithms
Decentralized: – Periodic update router • 4.6 Routing in the
• Router knows physically- – In response to link cost • 4.4 IP: Internet Internet
connected neighbors, link – RIP
changes Protocol
costs to neighbors – OSPF
– Datagram format
• Iterative process of – IPv4 addressing
– BGP
computation, exchange of
info with neighbors – ICMP • 4.7 Broadcast and
multicast routing
• “distance vector” algorithms – IPv6
•
destination link
Compute least cost paths from one node (“source”) to v (u,v)
all other nodes x (u,x)
– Gives forwarding table for that node Resulting forwarding table in u: y (u,x)
• Can be efficient (O(nlogn), n = # nodes) w
z
(u,x)
(u,x)
• Send link information (cost, connection) to neighbors • 4. 1 Introduction • 4.5 Routing algorithms
• For each incoming packet, send to every outgoing link • 4.2 Virtual circuit and – Link state
datagram networks – Distance vector
– Problems?
Æ Vast numbers of duplicate packets • 4.3 What’s inside a – Hierarchical routing
12
Distance Vector Algorithm Bellman-Ford Example
Bellman-Ford equation 5 Neighbors of u:
dv(z) = 5, dx(z) = 3, dw(z) = 3
Define v 3 w
5
2
dx(y) := cost of least-cost path from x to y u 2 3 1 z B-F equation says:
1 2du(z) = min {c(u,v) + dv(z),
x y
1 c(u,x)
( ) + dx(z),
( )
Then c(u,w) + dw(z)}
= min {2 + 5,
1 + 3,
dx(y) = min {c(x,v) + dv(y)} 5 + 3} = 4 (via x)
v Node that achieves minimum is
next hop in shortest path (via x
where min{} is taken over all neighbors v of x above)
➜ that goes in forwarding table
13
Distance Vector Algorithm - Link Cost Comparison of LS and DV algorithms
Changes
Message complexity Robustness: what happens
Link cost changes: 60 • LS: with n nodes, E links, if router malfunctions?
y
• Good news travels fast 4 1 O(nE) msgs sent LS:
• Bad news travels
x
50
z • DV: exchange between – node can advertise
slowly neighbors only incorrect link cost
• Right, 44 iterations
Right Speed of Convergence – each node computes only
“Poisoned” reverse: its own table
before algorithm
If Z routes through Y to
• LS: O(n2) algorithm requires
• Somewhat limits damage
stabilizes (see text) •
O(nE) msgs
get to X : DV:
• “Count to infinity” – may have oscillations
Z tells Y its (Z’s) distance
• – DV node can advertise
•
problem! to X is infinite (so Y won’t DV: convergence time varies
incorrect path cost
route to X via Z) – may be routing loops
– Each node’s table used by
• (Will not always completely – count-to-infinity problem others
solve count to infinity
problem )
• errors propagate thru
network
14
Chapter 4: Network Layer Intra-AS Routing
• 4. 1 Introduction • 4.5 Routing algorithms • Also known as Interior Gateway Protocols (IGP)
• 4.2 Virtual circuit and – Link state • Most common Intra-AS routing protocols:
datagram networks – Distance Vector
• 4.3 What’s inside a – Hierarchical routing – RIP: Routing Information Protocol
router • 4.6 Routing in the
– OSPF: Open Shortest Path First
• 4.4 IP: Internet Internet
– RIP – IGRP: Interior Gateway Routing Protocol
Protocol
– OSPF
– Datagram format (Cisco proprietary)
– BGP
– IPv4 addressing
– ICMP • 4.7 Broadcast and
– IPv6 multicast routing
Routing/Forwarding table in D
15
RIP: Example
Dest Next hops
Advertisement
RIP: Link Failure and Recovery
w - 1
x - 1 from A to D If no advertisement heard after 180 sec
Æneighbor/link declared dead
z C 4
…. … ...
z
– routes via neighbor invalidated
w x y – new advertisements sent to neighbors
A D B
– neighbors in turn send out new advertisements
C (if tables changed)
Destination Network Next Router Num. of hops to dest. – link failure info quickly propagates to entire
w A 2 net
y B 2
– poison reverse used to prevent ping-pong loops
z BA 75
x -- 1 (infinite distance = 16 hops)
…. …. ....
OSPF (Open Shortest Path First) OSPF “Advanced” Features (not in RIP)
• “Open” means publicly available, in this context
• Uses Link State algorithm
• security: all OSPF messages authenticated (to
prevent malicious intrusion)
– LS packet dissemination
– Topology map at each node
• multiple same-cost paths allowed (only one path in
– Route computation using Dijkstra’s algorithm
RIP)
• OSPF advertisement carries one entry per neighbor • F each
For h li
link,
k multiple
lti l costt metrics
t i ffor diff
differentt
router TOS (e.g., satellite link cost set “low” for best effort;
high for real time)
• Advertisements disseminated to entire AS (via
• integrated uni- and multicast support:
flooding)
– Carried in OSPF messages directly over IP (rather than TCP • hierarchical OSPF in large domains
or UDP)
16
Chapter 4: Network Layer Internet Inter-AS routing: BGP
17
Why Different Intra- and Inter-AS
BGP messages Routing?
• BGP messages exchanged using TCP Policy:
• BGP messages: • Inter-AS: admin wants control over how its traffic
routed, who routes through its net
– OPEN: opens TCP connection to peer and
authenticates sender • Intra-AS: single admin, so no policy decisions needed
– UPDATE:
UPDATE advertises
d ti new path
th ((or withdraws
ithd Scale:
old) • hierarchical routing saves table size, reduces update
traffic
– KEEPALIVE keeps connection alive in absence
of UPDATES; also ACKs OPEN request Performance:
– NOTIFICATION: reports errors in previous • Intra-AS: can focus on performance
msg; also used to close connection • Inter-AS: policy may dominate over performance
18