d - FSU Computer Science Department
Download
Report
Transcript d - FSU Computer Science Department
Network Layer (2)
Review
• Physical layer: move bits between physically
connected stations
• Data link layer: move frames between
physically connected stations
• Network layer: move packets from source A to
destination B
Datagram
• Packet carries the complete destination
information
• The job of a router is to
B
– Find the output link to send the packet
– Forward the packet to that output link
• Routing table for a node
Destination Next Hop
B
B
C
C
D
B
E
C
F
C
D
A
F
C
H
E
Forwarding
• A fast switch is used
to forward the
packet to the
destination
H
H
B
B
C
C
Virtual Circuit
• Destination information is large and the table
is large
– Consider 32 bit IP address. A full table will have 1G
entries.
• If an IP packet is 1250 byte long and the link speed is
10Gbps, how much time do you have for this lookup?
• (1. You don’t have to implement the full table. 2. You
can also use pipeline.)
Virtual Circuit
• Circuit means a path between the source and the
destination.
• Real circuit switching has a physical path set up between
the source and the destination, like telephone network
– When you dial, a request is sent to the network, network finds if
there are free links on the path and reserve that link for you.
• Virtual circuit is different – used in packet switching
networks.
– No real path set up, because it is packet switching (although link
bandwidth can be reserved).
– But still has the connection phase. The purpose is to let the
routers know how to route the packets of this virtual circuit.
Virtual Circuits
•
•
•
•
When setting up the virtual
circuit, a VC identifier is picked.
The router knows where to
forward a packet with a certain
VC identifier.
Each packet will carry the VC
identifier, which is much
shorter than the full destination
address, so allows more
efficient table lookup.
Resources can also be reserved.
QoS.
A practical problem in a
distributed environment –
different stations may pick the
same VC identifier.
•
Labels can be swapped without
causing confusion.
H2
B
D
A
F
C
H1
A’s Table
In
Out
H1, 1 C, 1
H2, 1 C, 2
E
C’s Table
In
Out
A, 1 E, 1
A, 2 D, 1
H3
Shortest Path
• find the shortest path from the source to all other nodes.
•
Dijkstra algorithm: finding the shortest paths from the source s to all
other nodes in the network.
1) Initial set = empty,
2) maintain the distance from s to all other nodes
(distance(s, s) = 0, distance(s, t) = infinite)
3) repeat until all nodes are included in the set
4) find a node d currently no in the set with shortest distance
5) include d in the set
6) update the distance from s to all other nodes using
7)
if distance(s, m) > distance(s, d) + dist(d, m) then
8)
distance(s, m) = distance(s, d) + dist (d, m)
Dijkstra’s algorithm: example
Step
0
1
2
3
4
5
start N
A
AD
ADE
ADEB
ADEBC
ADEBCF
D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E) D(F),p(F)
2,A
1,A
5,A
infinity
infinity
2,A
4,D
2,D
infinity
2,A
3,E
4,E
3,E
4,E
4,E
5
2
A
B
2
1
D
3
C
3
1
5
F
1
E
2
Shortest Path
• Why this gives the shortest path?
• Node added to the set has found its minimum
distance to the source. Suppose this is not
true. At a step, we add node W to the set. If
there is another path s---Z---W with distance
shorter than d(W), where Z is the first node in
the path currently not in the set. d(Z) must be
less than d(W) (why?) and we would have
added Z to the set at this step rather than W.
Link State Algorithm
• Each router independently computes optimal
paths
– From itself to every destination
– Routes are guaranteed to be loop free if
• Each router sees the same cost for each link
• Uses the same algorithm (shortest path algorithm for
OSPF) to compute the best path
Topology Dissemination
• Each router creates a set of link state packets
– Describing its links to neighbors
– LSP contains
• Router id, neighbor’s id, and cost to its neighbor
• Copies of LSPs are distributed to all routers
– Using controlled flooding
• Each router maintains a topology database
– Database containing all LSPs
Distance Vector Routing Algorithm
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:
X
D (Y,Z)
distance from X to
= Y, via Z as next hop
Z
= c(X,Z) + minw{D (Y,w)}
Distance Table of E
cost to destination via
A
B
D
7
A
B
1
2
8
1
E
C
2
D
A
1
14
5
B
7
8
5
C
6
9
4
D
4
11
2
Routing Table of E
cost to destination via
A
B
D
A
1
14
5
B
7
8
5
C
6
9
4
D
4
11
2
Distance table
Outgoing link
to use, cost
A
A,1
B
D,5
C
D,4
D
D,2
Routing table
Distance Vector Algorithm
Iterative, asynchronous: each
iteration caused by:
• local link cost change
• message from neighbor: its
least cost path change from
neighbor
Distributed:
• each node notifies neighbors
only when its least cost path to
any destination changes
– neighbors then notify their
neighbors if necessary
Each node:
wait for (change in local link
cost or msg from neighbor)
recompute distance table
if least cost path to any dest
has changed, notify neighbors
Example
X
2
Y
7
1
Z
Z
X
D (Y,Z) = c(X,Z) + minw{D (Y,w)}
= 7+1 = 8
Y
X
D (Z,Y) = c(X,Y) + minw {D (Z,w)}
= 2+1 = 3
Example
X
2
Y
7
1
Z
Convergence of the algorithm
router detects local link cost change
updates distance table
if cost change in least cost path, notify neighbors
“good
news
travels
fast”
1
X
4
Y
50
1
Z
algorithm
terminates
Problems with DV Routing
Link cost changes:
good news travels fast
bad news travels slow
“count to infinity” problem!
60
X
4
Y
50
1
Z
algorithm
continues
on!
21
Count-to-Infinity Problem
1
X
1
Y
Z
2
Zhenhai Duan
Computer Science, FSU
22
Link State vs Distance Vector
• Tells everyone about neighbors
• Controlled flooding to exchange
link state
• Dijkstra’s algorithm
• Each router computes its own
table
• May have oscillations
• Open Shortest Path First (OSPF)
• Tells neighbors about everyone
• Exchanges distance vectors
with neighbors
• Bellman-Ford algorithm
• Each router’s table is used by
others
• May have routing loops
• Routing Information Protocol
(RIP)
23