Transcript
Page 1: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Network Layer (part 1)

CPSC 363 Computer Networks

Ellen Walker

Hiram College

(Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley 2002)

Page 2: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Network Layer

• Implements host-to-host communication• Distributed throughout hosts and routers

– No central routing mechanism!

• Network layer functions– Path determination (routing)– Forwarding (to appropriate output link)– Call setup (ATM, not IP)

Page 3: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Routing vs. Forwarding

• Routing is a network-wide process that determines end-to-end paths– Even though it is not done in a centralized way!

• Forwarding is a router-only algorithm that sends each packet out the “right” interface– Uses tables determined by routing algorithm– Reads addresses in datagram headers

Page 4: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Virtual Circuit

• Setup: Build routing information tables (including unique VC numbers) in each router

• Data transfer: look at each packet, determine output interface and VC number based on input interface and VC number

• Teardown: inform both ends and all internal routers that the VC is no longer needed; routers remove information from their tables

• Setup & teardown done by “signaling messages” that cause VC tables to be modified

• Used by ATM networks (basis in telephony) -- guaranteed bandwidth (constant or min) and ordering

Page 5: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Datagram

• Every packet contains entire address (sufficient information to be routed to destination)

• No signaling messages needed• Each router maintains a forwarding table to indicate

the “direction” to each destination– Forwarding tables can change at any time– Therefore no guarantee all packets in message take the

same route!

• Today’s Internet provides (only) Datagram service - also called “best effort”

Page 6: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Advantages of Internet Model

• We can build more reliable transfer models (e.g. TCP) on top of it

• Easy to interconnect networks with different link-layer technologies (satellite vs. copper vs. radio, etc.)

• Network doesn’t need to understand application packets to route them; new applications can always be added on hosts

Page 7: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Routing

• Each host attached directly to a “first-hop” router (e.g. in the network card)

• Goal is to find the “least cost” path from source (router) to destination (router)– Assume every link has a numerical cost– Add up all link costs to get a path cost

Page 8: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Find Least Cost Path from A to F

Page 9: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Routing Algorithms

• Dynamic– Results change as network connectivity changes

• Global– Works with complete information about all nodes and link

costs– Also called link state algorithms

• Decentralized– Each router makes its decisions based on partial information

about nodes and link costs– More complete routing information evolves by information

exchange between neighbors– Example: distance vector algorithm

Page 10: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Link State Algorithm

• Initialization: All nodes broadcast the identities and costs of their neighboring links until every node has an identical table, then every node can run its own copy of the algorithm

• Dijkstra’s Algorithm (all shortest paths)– Builds a list of shortest (known) distance to every

(other) node– When complete, all links have been considered

Page 11: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Dijkstra’s Algorithm Initialization

• N = {A} // the only node we know is the source

• For every node v – If v is adjacent to A, then– D(v) = link cost from A to v – Prev(v) = A– Else D(v) = infinity

Page 12: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Dijkstra’s Algorithm Loop

• Find a node w (not in N) such that D(w) is a minimum

• Add w to N• For each v adjacent to w and not in N

– //update distance to be distance through w if it’s less

– D(v) = min(D(v), D(w)+ link cost from w to v– If D(w)+link cost is shorter, set Prev(v)=w

• (This loop is repeated until all nodes are in N)

Page 13: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Dijkstra’s Algorithm Example

• Source node is A– A:0 B:3 C:x D:2 E:4 F:x

• Choose node D– A:0 B:3 C:x D:2 E:3 F:x

• Choose node B– A:0 B:3 C:4 D:2 E:3 F:7

• Choose node E– A:0 B:3 C:4 D:2 E:3 F:4

• Choose node C– A:0 B:3 C:4 D:2 E:3 F:4

• Choose node F– A:0 B:3 C:4 D:2 E:3 F:4

A

DE

B

C

F

3

42

1 1

4

1

3

Final “Previous” table

A:A B:A C:B D:A E:D F:E

(Node chosen when v got its final value to the left)

Page 14: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Result of Dijkstra’s Algorithm

• Each node knows its previous node along the least cost path from A

• Example– Previous table is [ A:A B:A C:B D:A E:D F:E ]

– Path from A to F• A … E F (prev of F is E)• A… D E F (prev of E is D) • A D E F (prev of D is A)

• Use this information to make a “next hop” table

Page 15: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Result of Dijkstra’s Algorithm Example

• Example– Previous table is [ A:A B:A C:B D:A E:D F:E ]

– Path from A to F• A … E F (prev of F is E)• A… D E F (prev of E is D) • A D E F (prev of D is A)

• In node A, next-hop(F) is D• In node D, next-hop(F) is E• In node E, next-hop(F) is F

Page 16: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Comments on Dijkstra’s Algorithm

• Time cost is O(N2)– Roughly N searches through N possible next nodes each

time– Note that the number of links is also O(N2) for most

networks!

• Traffic considerations can cause oscillation– Make costs not depend on traffic (not practical)– Avoid running algorithm simultaneously in all nodes (add

random delay)

Page 17: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Distance Vector Algorithm

• Each node…– Receives information from its neighbors– Calculates– Distributes new information to its neighbors

• … until no new information is received• This algorithm is..

– Asynchronous– Distributed– Iterative

Page 18: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Distance Table

• Each row represents a destination• Each column represents a “next hop”• Thus a cell indicates the current best

estimate cost from “me” to “row” via “column”• Example (in node A):

– Row B, col C = c(A,C)+ C’s estimate of (C,B)

Page 19: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Example Distance Table

• In A: B D E

B 3 7 9

C 4 7 8

D 9 2 5

E 8 3 4

F 7 4 5

• Red (minimum) indicates which next-hop to take

A

DE

B

C

F

3

42

1 1

4

1

3

Page 20: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Distance Algorithm

• Initialize all values where row=col to direct distance to that col. (e.g. B,B=3 and D,D=2)

• Initialize all other values to infinity• Send min distance for each destination to all

neighbors• Wait for a change (either message or link cost)

– If cost to neighbor v changes by d, add d to each value in column v

– If update from v (cost from v to Y has changed), recalculate distance to y (link to v + cost from v to Y)

– If change caused a new min, send new D value for that min to all neighbors

Page 21: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Example:

• Assuming no initial knowledge, generate distance table (and next hop)

• Set AD to 5 and let network re-adjust

• Set AB to 100 and try again

A

DE

B

C

F

3

42

1 1

4

1

3

Page 22: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Comments on Distance Vector Algorithm

• With no changes, settles fairly quickly– As soon as information propagates from one edge of the

network to the other (network diameter)

• “Good news” spreads quickly– Reduction in link distance

• “Bad news” takes longer (“count to infinity”)– When a link is broken– Because the higher entry in the table might reflect old info

• “Poisoned reverse”– If Z goes through Y to get to X, then Z tells Y that Z’s

distance to X is infinite– This prevents routes with short (but not long) loops

Page 23: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Link State vs. Distance Vector Routing Algorithms

• LS requires enough messages that every node knows the cost of every link, before the algorithm starts. DV sends messages as needed.

• When a link cost changes, LS informs every node, DV only sends messages where it matters (new least cost paths)

• LS is guaranteed to converge in O(N2) DV can be faster, but can also “count to infinity”

• Bad cost table in LS hurts only the node; bad cost table in DV can hurt the whole network (broadcasting incorrect information)

Page 24: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Networks Are Hierarchical

• Total number of nodes is too big to keep track of all of them

• Organizations like to keep track of their own networks, presenting only one gateway to the “outside world”

• Result:– Networks divided into Autonomous Systems (AS)– Gateway router responsible for routing all packets to/from

outside world– Most routing is Gateway to Gateway (think local roads &

interstates)

Page 25: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Inter and Intra-AS Routing

Host h2

a

b

b

aaC

A

Bd c

A.a

A.c

C.bB.a

cb

Hosth1

Intra-AS routingwithin AS A

Inter-AS routingbetween A and B

Intra-AS routingwithin AS B

Page 26: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Necessary Routing Information

• Non-gateway router (intra-AS only)– Holds complete routing information within AS– Sends all extra-AS packets to gateway router (as if

that were their address)– “Hot potato” routing – get packet to “closest”

gateway

• Gateway router (inter-AS and intra-AS)– Holds complete routing information within AS– Also hold routing information to other gateways– Routing protocols include BGP (later)

Page 27: Network Layer (part 1) CPSC 363 Computer Networks Ellen Walker Hiram College (Includes figures from Computer Networking by Kurose & Ross, © Addison Wesley

Summary so far (Sec. 4.5)

• Every router has a “next hop” table to route packets to the right interface (output)

• Routing algorithms determine these tables– Global– Distributed

• In the Internet, hosts are arranged hierarchically, and inter-gateway routing is separated from intra-gateway routing

• Next look at network-layer transmission units (datagrams) and their headers, then return to routing


Top Related