1 Network Layer 4-1 Network Layer: Routing Computer Networking: A Top Down Approach Featuring the Internet, 2 nd edition. Jim Kurose, Keith Ross Addison-Wesley, July 2002. A note on the use of these ppt slides: We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!) If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material. Thanks and enjoy! JFK/KWR All material copyright 1996-2002 J.F Kurose and K.W. Ross, All Rights Reserved Network Layer 4-2 Routing Graph abstraction for routing algorithms: ❒ graph nodes are routers ❒ graph edges are physical links ❍ link cost: delay, $ cost, or congestion level Goal: determine “good” path (sequence of routers) thru network from source to dest. Routing protocol A E D C B F 2 2 1 3 1 1 2 5 3 5 ❒ “good” path: ❍ typically means minimum cost path ❍ other def’s possible
29
Embed
Network Layer: Routingweb2.uwindsor.ca/.../ktepe/compnets/routing_08.pdfNetwork Layer 4-4 A Link-State Routing Algorithm Dijkstra’s algorithm net topology, link costs known to all
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Network Layer 4-1
Network Layer: Routing
Computer Networking: ATop Down ApproachFeaturing the Internet,2nd edition.Jim Kurose, Keith RossAddison-Wesley, July2002.
A note on the use of these ppt slides:We’re making these slides freely available to all (faculty, students, readers).They’re in PowerPoint form so you can add, modify, and delete slides(including this one) and slide content to suit your needs. They obviouslyrepresent a lot of work on our part. In return for use, we only ask thefollowing: If you use these slides (e.g., in a class) in substantially unaltered form,that you mention their source (after all, we’d like people to use our book!) If you post any slides in substantially unaltered form on a www site, thatyou note that they are adapted from (or perhaps identical to) our slides, andnote our copyright of this material.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2002J.F Kurose and K.W. Ross, All Rights Reserved
Network Layer 4-2
Routing
Graph abstraction forrouting algorithms:
❒ graph nodes are routers❒ graph edges are
physical links❍ link cost: delay, $ cost, or
congestion level
Goal: determine “good” path(sequence of routers) thru
network from source to dest.
Routing protocol
A
ED
CB
F2
21
3
1
1
2
53
5
❒ “good” path:❍ typically means minimum
cost path❍ other def’s possible
2
Network Layer 4-3
Routing Algorithm classificationGlobal or decentralized
information?Global:❒ all routers have complete
topology, link cost info❒ “link state” algorithmsDecentralized:❒ router knows physically-
connected neighbors, linkcosts to neighbors
❒ iterative process ofcomputation, exchange ofinfo with neighbors
❒ “distance vector” algorithms
Static or dynamic?Static:❒ routes change slowly
over timeDynamic:❒ routes change more
quickly❍ periodic update❍ in response to link
cost changes
Network Layer 4-4
A Link-State Routing Algorithm
Dijkstra’s algorithm❒ net topology, link costs
known to all nodes❍ accomplished via “link
state broadcast”❍ all nodes have same info
❒ computes least cost pathsfrom one node (‘source”) toall other nodes❍ gives routing table for
that node❒ iterative: after k iterations,
know least cost path to kdest.’s
Notation:❒ c(i,j): link cost from node i to
j. cost infinite if not directneighbors
❒ D(v): current value of costof path from source to dest.V
❒ p(v): predecessor nodealong path from source to v,that is next v
❒ N: set of nodes whose leastcost path definitively known
3
Network Layer 4-5
Dijsktra’s Algorithm
1 Initialization: 2 N = {A} 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A,v) 6 else D(v) = infinity 7 8 Loop 9 find w not in N such that D(w) is a minimum 10 add w to N 11 update D(v) for all v adjacent to w and not in N: 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N
Network Layer 4-6
Dijkstra’s algorithm: example
Step012345
start NA
ADADE
ADEBADEBC
ADEBCF
D(B),p(B)2,A2,A2,A
D(C),p(C)5,A4,D3,E3,E
D(D),p(D)1,A
D(E),p(E)infinity
2,D
D(F),p(F)infinityinfinity
4,E4,E4,E
A
ED
CB
F2
21
3
1
1
2
53
5
4
Network Layer 4-7
Dijkstra’s algorithm, discussionAlgorithm complexity: n nodes❒ each iteration: need to check all nodes, w, not in N❒ n*(n+1)/2 comparisons: O(n**2)❒ more efficient implementations possible: O(nlogn)Oscillations possible:❒ e.g., link cost = amount of carried traffic
AD
CB
1 1+e
e0
e1 1
0 0
Network Layer 4-8
Distance Vector Routing Algorithm
iterative:❒ continues until no nodes
exchange info.❒ self-terminating: no
“signal” to stopasynchronous:❒ nodes need not
exchange info/iterate inlock step!
distributed:❒ each node
communicates only withdirectly-attachedneighbors
Distance Table data structure❒ each node has its own❒ row for each possible destination❒ column for each directly-attached
neighbor to node❒ example: in node X, for dest. Y via
neighbor Z:
D (Y,Z)X
distance from X toY, via Z as next hop
c(X,Z) + min {D (Y,w)}Zw
=
=
5
Network Layer 4-9
Distance Table: example
A
E D
CB7
81
2
1
2D ()
A
B
C
D
A
1
7
6
4
B
14
8
9
11
D
5
5
4
2
E cost to destination via
dest
inat
ion
D (C,D)E
c(E,D) + min {D (C,w)}Dw=
= 2+2 = 4
D (A,D)E
c(E,D) + min {D (A,w)}Dw=
= 2+3 = 5
D (A,B)E
c(E,B) + min {D (A,w)}Bw=
= 8+6 = 14
loop!
loop!
Network Layer 4-10
Distance Vector Algorithm: example
X Z12
7
Y
6
Network Layer 4-11
Distance Vector Algorithm: example
X Z12
7
Y
D (Y,Z)X c(X,Z) + min {D (Y,w)}w== 7+1 = 8
Z
D (Z,Y)X c(X,Y) + min {D (Z,w)}w== 2+1 = 3
Y
Network Layer 4-12
Distance Vector: link cost changes
Link cost changes:❒ node detects local link cost change❒ updates distance table (line 15)❒ if cost change in least cost path, notify
neighbors (lines 23,24)
X Z14
50
Y1
algorithmterminates“good
news travelsfast”
7
Network Layer 4-13
Distance Vector: link cost changes
Link cost changes:❒ good news travels fast❒ bad news travels slow -
“count to infinity” problem!X Z
14
50
Y60
algorithmcontinues
on!
Network Layer 4-14
Distance Vector: poisoned reverse
If Z routes through Y to get to X :❒ Z tells Y its (Z’s) distance to X is infinite
(so Y won’t route to X via Z)❒ will this completely solve count to infinity
problem?
X Z14
50
Y60
algorithmterminates
8
Network Layer 4-15
Comparison of LS and DV algorithms
Message complexity❒ LS: with n nodes, E links,
O(nE) msgs sent each❒ DV: exchange between
neighbors only❍ convergence time varies
Speed of Convergence❒ LS: O(n2) algorithm requires
O(nE) msgs❍ may have oscillations
❒ DV: convergence time varies❍ may be routing loops❍ count-to-infinity problem
Robustness: what happensif router malfunctions?
LS:❍ node can advertise
incorrect link cost❍ each node computes only
its own tableDV:
❍ DV node can advertiseincorrect path cost
❍ each node’s table used byothers
• error propagate thrunetwork
Network Layer 4-16
Hierarchical Routing
scale: with 200 milliondestinations:
❒ can’t store all dest’s inrouting tables!
❒ routing table exchangewould swamp links!
administrative autonomy❒ internet = network of networks❒ each network admin may want
to control routing in its ownnetwork
Our routing study thus far - idealization❒ all routers identical❒ network “flat”… not true in practice
❒ Distance vector algorithm❒ Included in BSD-UNIX Distribution in 1982❒ Distance metric: # of hops (max = 15 hops)
❍ Can you guess why?
❒ Distance vectors: exchanged among neighbors every 30sec via Response Message (also called advertisement)
❒ Each advertisement: list of up to 25 destination netswithin AS
Network Layer 4-24
RIP: Example
Destination Network Next Router Num. of hops to dest. w A 2
y B 2 z B 7
x -- 1…. …. ....
w x y
z
A
C
D B
Routing table in D
13
Network Layer 4-25
RIP: Example
Destination Network Next Router Num. of hops to dest. w A 2
y B 2 z B A 7 5
x -- 1…. …. ....
Routing table in D
w x y
z
A
C
D B
Dest Next hops w - - x - - z C 4 …. … ...
Advertisementfrom A to D
Network Layer 4-26
RIP: Link Failure and RecoveryIf no advertisement heard after 180 sec --> neighbor/link
declared dead❍ routes via neighbor invalidated❍ new advertisements sent to neighbors❍ neighbors in turn send out new advertisements (if
tables changed)❍ link failure info quickly propagates to entire net❍ poison reverse used to prevent ping-pong loops
(infinite distance = 16 hops)
14
Network Layer 4-27
RIP Table processing
❒ RIP routing tables managed by application-levelprocess called route-d (daemon)
❒ advertisements sent in UDP packets, periodicallyrepeated
physicallink
network forwarding (IP) table
Transprt (UDP)
routed
physicallink
network (IP)
Transprt (UDP)
routed
forwardingtable
Network Layer 4-28
RIP Table example (continued)Router: giroflee.eurocom.fr
❒ Three attached class C networks (LANs)❒ Router only knows routes to attached LANs❒ Default router used to “go up”❒ Route multicast address: 224.0.0.0❒ Loopback interface (for debugging)
Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ------ --------- 127.0.0.1 127.0.0.1 UH 0 26492 lo0 192.168.2. 192.168.2.5 U 2 13 fa0 193.55.114. 193.55.114.6 U 3 58503 le0 192.168.3. 192.168.3.5 U 2 25 qaa0 224.0.0.0 193.55.114.6 U 3 0 le0 default 193.55.114.129 UG 0 143454
15
Network Layer 4-29
OSPF (Open Shortest Path First)
❒ “open”: publicly available❒ Uses Link State algorithm
❍ LS packet dissemination❍ Topology map at each node❍ Route computation using Dijkstra’s algorithm
❒ OSPF advertisement carries one entry per neighborrouter
❒ Advertisements disseminated to entire AS (via flooding)❍ Carried in OSPF messages directly over IP (rather than TCP or
UDP
Network Layer 4-30
OSPF “advanced” features (not in RIP)
❒ Security: all OSPF messages authenticated (to preventmalicious intrusion)
❒ Multiple same-cost paths allowed (only one path in RIP)❒ For each link, multiple cost metrics for different TOS
(e.g., satellite link cost set “low” for best effort; high forreal time)
❒ Integrated uni- and multicast support:❍ Multicast OSPF (MOSPF) uses same topology data
base as OSPF❒ Hierarchical OSPF in large domains.
16
Network Layer 4-31
Hierarchical OSPF
Network Layer 4-32
Hierarchical OSPF
❒ Two-level hierarchy: local area, backbone.❍ Link-state advertisements only in area❍ each nodes has detailed area topology; only know
direction (shortest path) to nets in other areas.❒ Area border routers: “summarize” distances to nets in
own area, advertise to other Area Border routers.❒ Backbone routers: run OSPF routing limited to
backbone.❒ Boundary routers: connect to other AS’s.
17
Network Layer 4-33
Inter-AS routing in the Internet: BGP
Figure 4.5.2-new2: BGP use for inter-domain routing
AS2 (OSPF
intra-AS
routing)
AS1 (RIP intra-AS
routing) BGP
AS3 (OSPF intra-AS
routing)
BGP
R1 R2
R3
R4
R5
Network Layer 4-34
Internet inter-AS routing: BGP
❒ BGP (Border Gateway Protocol): the de factostandard
❒ Path Vector protocol:❍ similar to Distance Vector protocol❍ each Border Gateway broadcast to neighbors
(peers) entire path (i.e., sequence of AS’s) todestination
❍ BGP routes to networks (ASs), not individual hosts❍ E.g., Gateway X may send its path to dest. Z:
Path (X,Z) = X,Y1,Y2,Y3,…,Z
18
Network Layer 4-35
Internet inter-AS routing: BGP
Suppose: gateway X send its path to peer gateway W❒ W may or may not select path offered by X
❍ cost, policy (don’t route via competitors AS), loopprevention reasons.
❒ If W selects path advertised by X, then:Path (W,Z) = w, Path (X,Z)
❒ Note: X can control incoming traffic by controlling it routeadvertisements to peers:❍ e.g., don’t want to route traffic to Z -> don’t advertise
any routes to Z
Network Layer 4-36
BGP: controlling who routes to you
Figure 4.5-BGPnew: a simple BGP scenario
A
B
C
W X
Y
legend:
customer
network:
provider
network
❒ A,B,C are provider networks❒ X,W,Y are customer (of provider networks)❒ X is dual-homed: attached to two networks
❍ X does not want to route from B via X to C❍ .. so X will not advertise to B a route to C
19
Network Layer 4-37
BGP: controlling who routes to you
Figure 4.5-BGPnew: a simple BGP scenario
A
B
C
W X
Y
legend:
customer
network:
provider
network
❒ A advertises to B the path AW❒ B advertises to X the path BAW❒ Should B advertise to C the path BAW?
❍ No way! B gets no “revenue” for routing CBAW since neither Wnor C are B’s customers
❍ B wants to force C to route to w via A❍ B wants to route only to/from its customers!
Network Layer 4-38
BGP operation
Q: What does a BGP router do?❒ Receiving and filtering route advertisements from
directly attached neighbor(s).❒ Route selection.
❍ To route to destination X, which path )of severaladvertised) will be taken?
❒ Sending route advertisements to neighbors.
20
Network Layer 4-39
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 ofInternet
Datagrams with source or destination in this networkhave 10.0.0/24 address for source, destination (as usual)
All datagrams leaving localnetwork have same single source
NAT IP address: 138.76.29.7,different source port numbers
Network Layer 4-40
NAT: Network Address Translation
❒ Motivation: local network uses just one IP address as far asoutside word is concerned:❍ no need to be allocated range of addresses from ISP: -
just one IP address is used for all devices❍ can change addresses of devices in local network
without notifying outside world❍ can change ISP without changing addresses of devices
in local network❍ devices inside local net not explicitly addressable, visible
❍ outgoing datagrams: replace (source IP address, port #) of everyoutgoing datagram to (NAT IP address, new port #)
. . . remote clients/servers will respond using (NAT IP address,new port #) as destination addr.
❍ remember (in NAT translation table) every (source IP address, port#) to (NAT IP address, new port #) translation pair
❍ incoming datagrams: replace (NAT IP address, new port #) in destfields of every incoming datagram with corresponding (source IPaddress, port #) stored in NAT table
Network Layer 4-42
NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
S: 10.0.0.1, 3345D: 128.119.40.186, 80
110.0.0.4
138.76.29.7
1: host 10.0.0.1 sends datagram to 128.119.40, 80
NAT translation tableWAN side addr LAN side addr138.76.29.7, 5001 10.0.0.1, 3345…… ……
4: NAT routerchanges datagramdest addr from138.76.29.7, 5001 to 10.0.0.1, 3345
22
Network Layer 4-43
NAT: Network Address Translation
❒ 16-bit port-number field:❍ 60,000 simultaneous connections with a single
LAN-side address!❒ NAT is controversial:
❍ routers should only process up to layer 3❍ violates end-to-end argument
• NAT possibility must be taken into account by appdesigners, e.g., P2P applications
❍ address shortage should instead be solved byIPv6
Network Layer 4-44
Mobility: approaches
❒ Let routing handle it: routers advertise permanentaddress of mobile-nodes-in-residence via usual routingtable exchange.❍ routing tables indicate where each mobile located❍ no changes to end-systems
❒ Let end-systems handle it:❍ indirect routing: communication from correspondent
to mobile goes through home agent, then forwardedto remote
❍ direct routing: correspondent gets foreign address ofmobile, sends directly to mobile
23
Network Layer 4-45
Mobility: approaches
❒ Let routing handle it: routers advertise permanentaddress of mobile-nodes-in-residence via usual routingtable exchange.❍ routing tables indicate where each mobile located❍ no changes to end-systems
❒ let end-systems handle it:❍ indirect routing: communication from correspondent
to mobile goes through home agent, then forwardedto remote
❍ direct routing: correspondent gets foreign address ofmobile, sends directly to mobile
notscalable
to millions of mobiles
Network Layer 4-46
Mobility: registration
End result:❒ Foreign agent knows about mobile❒ Home agent knows location of mobile
wide areanetwork
home networkvisited network
1
mobile contactsforeign agent onentering visitednetwork
2
foreign agent contacts homeagent home: “this mobile isresident in my network”
24
Network Layer 4-47
Mobility via Indirect Routing
wide areanetwork
homenetwork
visitednetwork
3
24
1correspondentaddresses packetsusing home addressof mobile
home agent interceptspackets, forwards toforeign agent
foreign agentreceives packets,forwards to mobile
mobile repliesdirectly tocorrespondent
Network Layer 4-48
Indirect Routing: comments❒ Mobile uses two addresses:
❍ permanent address: used by correspondent (hencemobile location is transparent to correspondent)
❍ care-of-address: used by home agent to forwarddatagrams to mobile
❒ foreign agent functions may be done by mobile itself❒ triangle routing: correspondent-home-network-mobile
❍ inefficient whencorrespondent, mobileare in same network
25
Network Layer 4-49
Forwarding datagrams to remote mobile
Permanent address:128.119.40.186
Care-of address:79.129.13.2
dest: 128.119.40.186
packet sent bycorrespondent
dest: 79.129.13.2 dest: 128.119.40.186
packet sent by home agent to foreignagent: a packet within a packet
dest: 128.119.40.186
foreign-agent-to-mobile packet
Network Layer 4-50
Indirect Routing: moving between networks
❒ suppose mobile user moves to another network❍ registers with new foreign agent❍ new foreign agent registers with home agent❍ home agent update care-of-address for mobile❍ packets continue to be forwarded to mobile (but with
new care-of-address)❒ Mobility, changing foreign networks transparent:
Lifetime: 9999 identification: 714 encapsulation format ….
registration reply
HA: 128.119.40.7
MA: 128.119.40.186 Lifetime: 4999 Identification: 714 encapsulation format
….
registration reply
HA: 128.119.40.7 MA: 128.119.40.186
Lifetime: 4999 Identification: 714 ….
time
Network Layer 4-56
DHCP: Dynamic Host Configuration Protocol
Goal: allow host to dynamically obtain its IP address from networkserver when it joins networkCan renew its lease on address in useAllows reuse of addresses (only hold address while connected an “on”Support for mobile users who want to join network (more shortly)
DHCP overview:❍ host broadcasts “DHCP discover” msg❍ DHCP server responds with “DHCP offer” msg❍ host requests IP address: “DHCP request” msg❍ DHCP server sends address: “DHCP ack” msg