Network Layer
Lecture # 2
MAHS
4: Network Layer
4b-2
Hierarchical Routing
scale: with 200 milliondestinations:
rcan’t store all dest’s inrouting tables!
rrouting table exchangewould swamp links!
administrative autonomy
rinternet = network ofnetworks
reach network admin maywant to control routing (costmetrics, etc.) in its ownnetwork
Our routing study thus far - idealization
rall routers identical
rnetwork “flat”
… not true in practice… not true in practice
Why?Why?
4: Network Layer
4b-3
Hierarchical Routing
rOrganization:aggregate routers intoregions, called“autonomous systems”(AS)
rrouters in same AS runsame routing protocol
m“intra-AS” routing (i.e.,within an AS) protocol
mrouters in different AScan run different intra-AS routing protocol
rspecial routers in (onthe edge of) an AS
rrun intra-AS routingprotocol with all otherrouters in AS
ralso responsible forrouting to destinationsoutside AS
mrun inter-AS routing(i.e., between AS)protocol with othergateway routers
gateway routers
4: Network Layer
4b-4
Intra-AS and Inter-AS routing
C:\temp\gaterout.gif
Gateway routers:
perform inter-ASrouting amongstthemselves
perform intra-ASrouting with otherrouters in theirAS
inter-AS, intra-ASrouting in
gateway A.c
network layer
data link layer
physical layer
a
b
b
a
a
C
A
B
d
A.a
A.c
C.b
B.a
c
b
c
4: Network Layer
4b-5
Intra-AS and Inter-AS routing
Host
h2
a
b
b
a
a
C
A
B
d
c
A.a
A.c
C.b
B.a
c
b
Host
h1
Intra-AS routing
within AS A
Inter-AS
 routing
between
A and B
Intra-AS routing
within AS B
rWe’ll examine specific inter-AS and intra-ASInternet routing protocols shortly (section 4.5)
4: Network Layer
4b-6
IP datagram format
ver
length
32 bits
data
(variable length,
typically a TCP segment,
a UDP segment,
or an ICMP message)
16-bit identifier
Header
 checksum
time to
live
32 bit source IP address
IP protocol version
number
header length
 (4-byte multiples)
max number
remaining hops
(decremented at
each router)
for
fragmentation/
reassembly
total datagram
length (bytes)
upper layer protocol
to deliver payload to
(RFC 1700, 3232)
head.
len
type of
service
DS codepoint, ECN
flgs
fragment
 offset
upper
 layer
32 bit destination IP address
Options (if any)
E.g. timestamp,
record route
taken, specify
list of routers
to visit.
how much overheadwith TCP?
r20 bytes of TCP
r20 bytes of IP
r= 40 bytes + applayer overhead
4: Network Layer
4b-7
IP Fragmentation & Reassembly
rnetwork links have MTU (Max.Transfer Unit) size - largestpossible link-level frame.
mdifferent link types,different MTUs
rlarge IP datagram is divided(“fragmented”) within network
mone datagram becomesseveral datagrams
m“reassembled” only at thefinal destination
mIP header bits are used toidentify and order relatedfragments
fragmentation:
in: one large datagram
out: 3 smaller datagrams
reassembly
4: Network Layer
4b-8
IP Fragmentation and Reassembly
ID
=x
offset
=0
More bit
=0
bytes*
=3980
ID
=x
offset
=0
More bit
=1
bytes*
=1480
ID
=x
offset
=1480
More bit
=1
bytes*
=1480
ID
=x
offset
=2960
More bit
=0
bytes*
=1020
One large datagram becomes
several smaller datagrams
Note:  Offset is actually
specified as number of8-byte (64-bit) units.
Example
r4000 bytedatagram
rMTU = 1500 bytes
*  This is the number ofdata bytes in the IPdatagram.  The IP lengthfield would show this +20.  Why?
4: Network Layer
4b-9
DHCP: Dynamic Host Configuration Protocol
Goal: allow host to dynamically obtain its IP addressfrom network server when it joins a network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connectedan “on”
Support for mobile users who want to join network (moreshortly)
DHCP overview:
mhost broadcasts “DHCP discover” msg
mDHCP server responds with “DHCP offer” msg
mhost requests IP address: “DHCP request” msg
mDHCP server sends address: “DHCP ack” msg
4: Network Layer
4b-10
DHCP client-server scenario
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4
223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2
223.1.3.1
223.1.3.27
A
B
E
 
DHCP
 
server
 
 
arriving DHCP
client needs
address in this
network
4: Network Layer
4b-11
DHCP client-server scenario
DHCP server: 223.1.2.5
arriving
 client
time
DHCP discover
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr:    0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest:  255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
src:  0.0.0.0, 68
dest::  255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest:  255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
4: Network Layer
4b-12
NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
138.76.29.7
local network
(e.g., home network)
10.0.0/24
rest of
Internet
Datagrams with source or
destination in this network
have 10.0.0/24 address for
source, destination (as usual)
All datagrams leaving local
network have same single sourceNAT IP address: 138.76.29.7,
different source port numbers
4: Network Layer
4b-13
NAT: Network Address Translation
rMotivation: local network uses just one IP address asfar as outside word is concerned:
mno need to be allocated range of addresses from ISP:- just one IP address is used for all devices
mcan change addresses of devices in local networkwithout notifying outside world
mcan change ISP without changing addresses ofdevices in local network
mdevices inside local net not explicitly addressable,visible by outside world (a security plus).
4: Network Layer
4b-14
NAT: Network Address Translation
Implementation: NAT router must:
moutgoing datagrams: replace (source IP address, port #) ofevery outgoing datagram to (NAT IP address, new port #)
. . . remote clients/servers will respond using (NAT IP address,new port #) as destination addr.
mremember (in NAT translation table) every (source IP address,port #)  to (NAT IP address, new port #) translation pair
mincoming datagrams: replace (NAT IP address, new port #) indest fields of every incoming datagram with corresponding(source IP address, port #) stored in NAT table
4: Network Layer
4b-15
NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
1
10.0.0.4
138.76.29.7
1: host 10.0.0.1
sends datagram to
128.119.40, 80
NAT translation table
WAN side addr        LAN side addr
138.76.29.7, 5001   10.0.0.1, 3345
……                                         ……
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
2
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3
3: Reply arrives
 dest. address:
 138.76.29.7, 5001
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
4: Network Layer
4b-16
NAT: Network Address Translation
r16-bit port-number field:
m60,000 simultaneous connections with a singleLAN-side address!
rReserved address space (rfc 1918)
rNAT is controversial:
mrouters should only process up to layer 3
mviolates end-to-end argument
NAT possibility must be taken into account by appdesigners, eg, P2P applications
maddress shortage should instead be solved byIPv6
4: Network Layer
4b-17
Intra-AS Routing
rAlso known as Interior Gateway Protocols (IGP)
rMost common IGPs:
mRIP: Routing Information Protocol (legacy,RIPv2 still in use)
mOSPF: Open Shortest Path First (common)
mEIGRP: Enhanced Interior Gateway RoutingProtocol (proprietary – Cisco Systems)
4: Network Layer
4b-18
RIP ( Routing Information Protocol)
rDistance vector algorithm
rIncluded in BSD-UNIX Distribution in 1982
mRFC 1058 (version 1), RFC 2453 (version 2)
rDistance metric: # of hops (max = 15 hops)
mCan you guess why?
rDistance vectors: exchanged every 30 seconds viaResponse Message (also called advertisement)
rEach advertisement: routing info for maximum of 25destination nets within the AS
rUses UDP transport, port 520
4: Network Layer
4b-19
Problems/limitations with RIP
rGood for small systems, but doesn’t scalewell
rCount-to-infinity problem… poisonedreverse only
rComparatively slow convergence
r1979 – RIP version 1
r1988 – IETF initiates work on replacement
r1990 – OSPF became new standard
r1990’s – RIP version 2
4: Network Layer
4b-20
OSPF (Open Shortest Path First)
r“open”: publicly available
rUses Link State algorithm
mLS packet dissemination
mTopology map at each node
mRoute computation using Dijkstra’s algorithm
However….
rOSPF advertisement carries only one entry perneighbor router
rAdvertisements disseminated to entire AS (viaflooding)
rSent as payload in IP datagram
4: Network Layer
4b-21
EIGRP (Enhanced Interior GatewayRouting Protocol)
rCISCO proprietary; successor of RIP (mid 80’s)
ruses Distance Vector, like RIP
rseveral cost metrics (delay, bandwidth, reliability,load etc)
ruses TCP (!) to exchange routing updates
rLoop-free routing via a distributed update routingalgorithm (called DUAL) based on diffusedcomputation
4: Network Layer
4b-22
Inter-AS routing
D:\temp\hier.GIF