Unit 3: The Network Layer
Unit 3: The Network Layer
1
Network Layer Design Issues
• Store-and-Forward Packet Switching
• Services Provided to the Transport Layer
• Implementation of Connectionless Service
• Implementation of Connection-Oriented Service
• Comparison of Virtual-Circuit and Datagram
Subnets
2
Network Layer Design Issues
• Network layer provides point-to-point connectivity
between any two hosts.
• The network layer services have the following goals:
– The services should be independent of the router technology.
– The transport layer should be shielded from the number,
type, and topology of the routers present.
– The network addresses made available to the transport layer
should use a uniform numbering plan, even across LANS
and WANS.
• The network layer defines the service provided by the
subnet. A subnet (short for "subnetwork") is an
identifiably separate part of an organization's network.
3
Store-and-Forward Packet Switching
fig 5-1
5
Services Provided to Transport Layer
• The freedom in writing detailed specifications of the
services to be offered to the transport layer cause
battles between connection-oriented and
connectionless services.
• Internet community - connectionless
– With 30 year experience with the Internet, the subnet is
inherently unreliable.
– The host should accept this fact and do error control and
flow control themselves.
• Telephone companies – connection-oriented
– With more than 100 years’ experience, QoS is important.
• QoS is important and the Internet is starting to
associate with connection-oriented service. 6
Implementation of Services
• Connectionless service
– No advance setup is needed.
– The packets are frequently called datagrams.
– The subnet is called a datagram subnet.
– The routing algorithm is the algorithm that manages the
tables and makes the routing decision.
• Connection-oriented service
– A path from the source router to the destination router must
be established before any data packets can be sent.
– The connection is called a VC (virtual circuit).
– The subnet is called a virtual-circuit subnet.
– To distinguish packets from different hosts, replacing
connection identifiers in outgoing packets is called label
switching. 7
Implementation of Connectionless Service
5-4
10
Routing Algorithms
• The Optimality Principle
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State Routing
• Hierarchical Routing
• Broadcast Routing
• Multicast Routing
11
Routing Algorithms
12
Routing Algorithms
• Non-adaptive algorithms
– They do not base their routing decisions on
measurements or estimates of the current traffic and
topology.
– This procedure is sometimes called static routing.
• Adaptive algorithms
– They change their routing decisions to reflect
changes in the topology.
– This procedure is sometimes called dynamic
routing.
13
The Optimality Principle
• If the router J is on the optimal path from the router I
to the router K, then the optimal path from J to K also
falls along the same route.
– Construct a sink tree with the destination to be root.
– The goal of all routing algorithms is to discover and use the
sink tree for all routers.
– Since it is a tree, there is no loops.
– A real network is complex. Routers and links may be down
at any time.
14
Sink Tree
17
Shortest Path Routing
• An example: find the shortest path from A to D
– We start out by making node A permanent indicated
by a filled-in circle.
– Then we examine each node adjacent to A,
relabeling each one.
– Scan all the tentatively labeled nodes in the whole
graph and make the one with the smallest distance
to A permanent.
– This node becomes the new working node. Repeat
the steps till the destination becomes permanent.
18
Shortest Path Routing
19
Flooding
• Flooding is a static routing algorithm.
• Every incoming packet is sent out on every outgoing
line except the one it arrived on.
• Flooding generates a large number of duplicated
packets. To reduce overhead,
– Use a hop counter (TTL, Time To Live), which is
decremented at each hop. The packet is discarded with the
counter reaches zero.
– Keep track of the packets and avoid to send them out the
second time in case there is a loop.
– Selective flooding in which the routers send the incoming
packet to only those outgoing lines in the right direction.
• Flooding has tremendous reliability and always choose
the shortest delay used in applications such as military,
distributed database, wireless network.
20
Distance Vector Routing
• Distance Vector Routing algorithm – Dynamic routing
– Each router maintains a table (vector), giving the best known
distance to each destination and the outgoing line to get there.
– These tables are updated by exchanging information with the
neighbors.
– The metric used might be the number of hops, the time delay,
or the number of queued packets.
– The router is assumed to know the “distance” to each of its
neighbors.
21
22
(a) A subnet. (b) Input from A, I, H, K, and the new routing table for J.
Distance Vector Routing
• Distance vector works in theory but has a serious
drawback in practice.
– React rapidly to good news when a router comes up.
– Though it finally converge to correct result, it takes long time
when where is a bad news.
– There are several attempts to solve the problem, but none is
perfect.
• Distance vector routing was used in ARPANET until
1979 when it is replaced by link state routing.
• Two problems of distance vector routing:
– It does not take line bandwidth into account.
– It took too long to converge. 23
The count-to-infinity problem.
24
Link State Routing
• Link State Routing is a dynamic routing.
• Each router must do the following:
1. Discover its neighbors, learn their network
address.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router.
25
Learning about the Neighbors
• Learning about the neighbors: When a router is
booted, it first learns its immediate neighbors.
– Send a HELLO packet on each point-to-point line.
The router on the other end will send a reply telling
who it is.
– Each router has a global unique name.
– If two or more routers are connected by a LAN, we
can model the LAN as a node.
26
Learning about the Neighbors
A subnet in which the East and West parts are connected by two lines.
29
Building Link State Packets
• Build the link state packet containing: node ID,
sequence number, age, a list of neighbors and the delay
to the neighbor.
• Building the state packet is easy. The hard part is to
determine when to build them.
– Periodically or event-driven
(a) A subnet. (b) The link state packets for this subnet. 30
Distributing the Link State Packets
• The trickiest part is to distribute link state packet.
• Basic idea:
– Use flooding to distribute the link state packets.
– To keep the flood in check, each packet contains a
sequence number that is increased by one for each new
packet.
– When the link state packet arrives, the router check if
it is new.
• Yes forward it to all outgoing lines except the one it
arrived.
• No (duplicated or with low sequence number) discard it.
31
Distributing the Link State Packets
• Potential problems:
– The sequence number wrap around use the 32-bit
sequence number. It takes 137 years to wrap around.
– The router crashes. Its sequence number starts again
from 0, it is rejected.
– The sequence number is corrupt (e.g., 65540 is
received instead of 4, then packets from 5 to 65540
will be rejected.)
• Use “age” to solve the problems:
– The age decreases by one per second. The packet is
discarded when age = 0.
– Problem packets won’t last for a long time. 32
Distributing the Link State Packets
• Each router uses a table to maintain the link state packets.
• Each row is a recently received but not processed packet.
• Each entry includes the source address, sequence number, age,
and send/ACK flags.
33
The packet buffer for router B in the previous slide (Fig. 5-13).
Computing Routes
• Once a router has accumulated a full set of link state
packets, it knows all nodes and links, thus can construct
the subnet graph.
• Run Dijkstra algorithm to find the shortest paths from
the source to all other nodes.
• For a network with n routers, each with k neighbors, the
memory required in nk.
– Memory and computational time may be a problem for large
subnets.
– But it works fine for many practical situations.
• The OSPF (Open Shortest Path First) protocol is used in
the Internet.
• IS-IS (Intermediate System-Intermediate System) is used
in some the Internet backbone (NSFNET).
34
Hierarchical Routing
• With the increase of network/routers, it is infeasible to
have an entry for each router. The hierarchical routing is
required.
– Divide the routers into regions.
– The router only knows details to route packets to the
destination within the same region.
– For Huge Networks a two level hierarchy may be insufficient
– It may be necessary to group Regions to Clusters, Clusters
to Zones and Zones into Groups.
35
Hierarchical Routing
36
Broadcast Routing
• Broadcasting: send a packet to all destinations.
– Distributing weather reports, stock, radio programs, etc.
• Broadcast routing algorithm
– Send a distinct packet to each destination (waste bandwidth)
– Flooding (generate too many packets)
– Multi-destination routing
• The packet includes a list of destinations
• The router sends the packet on an outgoing line if it is the
best route for at least one of destinations (according to
routing table).
37
Broadcast Routing
• Broadcast routing algorithm
– A spanning tree is a subset of the subnet that includes all the
routers but contains no loops.
• Copy an incoming broadcast packet onto all the spanning
tree lines except the one it arrived on.
• excellent use of bandwidth
• But each router is required to know some spanning tree.
38
Multicast Routing
• Sending a packet to a group of nodes (a subset of the
nodes in the network) is called multicasting.
– Multiple unicast or broadcast are too expensive
– Build spanning tree
– Upon receiving a packet, prune the spanning tree (cut off the
routers/lines that do not lead to any member in the group)
– Not scalable
39
Multicast Routing