Module 3 Part 1
Module 3 Part 1
Network Layer
PREVIOUS LAYERS
2
The Network Layer
3
• To achieve its goals, the network layer must know
about the topology of the communication subset
(i.e., the set of all routers) and choose appropriate
paths through it.
• It must also take care to choose routes to avoid
overloading some of the communication lines and
routers while leaving others idle.
• Finally, when the source and destination are in
different networks, new problems occur. It is up to
the network layer to deal with them.
4
Network Layer Design Issues
• Some of the issues that the designers of the
network layer must grapple with
1. Store-and-forward packet switching
2. Services provided to transport layer
3. Implementation of connectionless service
4. Implementation of connection-oriented service
5. Comparison of virtual-circuit and datagram
networks
1. Store-and-Forward Packet Switching
ISP’s equipment
10
3. Implementation of Connectionless Service
•If connectionless service is offered, packets are
injected into the subnet individually and routed
independently of each other.
•In this context, the packets are frequently called
datagrams and the subnet is called a datagram
subnet.
•When a packet comes into a router, the frame
header and trailer are stripped off and the packet
located in the frame’s payload field is passed to the
routing software.
11
Routing within a diagram subnet. 12
•Each router has an internal table telling it where
to send packets for each possible destination.
•The algorithm that manages the tables and makes
the routing decisions is called the routing
algorithm.
•Routing algorithms are one of the main things to
focus on.
13
4. Implementation of Connection-Oriented Service
To use a connection-oriented service, first we establishes a
connection, use it and then release it. In connection-oriented
services, the data packets are delivered to the receiver in the
same order in which they have been sent by the sender.
.
ROUTING ALGORITHMS
• The main function of NL (Network Layer) is routing packets
from the source machine to the destination machine.
• The algorithms that choose the routes and the data structures
that they use are a major area of network layer design.
• The routing algorithm is that part of the NL software
responsible for deciding which output line an incoming
packet should be transmitted on.
• There are two processes inside router:
a) One of them handles each packet as it arrives, looking up the
outgoing line to use for it in the routing table. This process is
forwarding.
b) The other process is responsible for filling in and updating the
routing tables. That is where the routing algorithm comes into
play. This process is routing.
• Routing algorithms can be grouped into two major classes:
– Non adaptive(static) and adaptive(dynamic).
• Non adaptive algorithms
– do not base their routing decisions on
measurements or estimates of the current traffic
and topology.
– Instead, the choice of the route to use to get from I to J
(for all I and J) is computed in advance, off-line, and
downloaded to the routers when the network is booted.
– This procedure is sometimes called static routing.
• Adaptive algorithms,
– change their routing decisions to reflect changes
in the topology, and usually the traffic as well.
– Stability is also an important goal for the routing
algorithm.
Static Routing Dynamic Routing
Static routing does not use complex Dynamic routing uses complex routing
2.
routing algorithms. algorithms.
In static routing, failure of the link In dynamic routing, failure of the link
7.
disrupts the rerouting. does not interrupt the rerouting.
• In the general case, the labels on the edges could be computed as a function of:
– Distance,
– Bandwidth,
– Average traffic,
– Communication cost,
– Measured delay, and other factors.
• By changing the weighting function, the algorithm would then compute the ‘‘shortest’’
path measured according to any one of a number of criteria or to a combination of
criteria
• Several algorithms for computing the shortest path
between two nodes of a graph are known.
• This one is due to Dijkstra and finds the shortest
paths between a source and all destinations in the
network
• step by step process of algorithm implementation;
1. The very first step is to mark all nodes as unvisited,
2. Mark the picked starting node with a current distance of 0
and the rest nodes with infinity,
3. Now, fix the starting node as the current node,
4. For the current node, analyse all of its unvisited
neighbours and measure their distances by adding the
current distance of the current node to the weight of the
edge that connects the neighbour node and current node,
5. Compare the recently measured distance with the current
distance assigned to the neighbouring node and make it
as the new current distance of the neighbouring node,
6. After that, consider all of the unvisited
neighbours of the current node, mark the current
node as visited,
7. If the destination node has been marked visited
then stop, an algorithm has ended, and
8. Else, choose the unvisited node that is marked
with the least distance, fix it as the new current
node, and repeat the process again from step 4.
We will calculate the shortest path from C to all
other nodes
• We will calculate the shortest path between
node C and the other nodes in the graph.
•
d(u)+c(u,v)<d(v) update d(v) by d(u)+c(u,v)
https://www.analyticssteps.com/blogs/dijkstras-algorithm-shortest-path-
algorithm
The Optimality Principle
• The purpose of a routing algorithm at a router is to
decide which output line an incoming packet should go.
The optimal path from a particular router to another may
be the least cost path, the least distance path, the least
time path, the least hops path or a combination of any of
the above.
• It states that if router J is on the optimal path from
router I to router K, then the optimal path from J to K
also falls along the same route.
•
The optimality principle can be logically proved as
follows −
•If a better route could be found between router J
and router K, the path from router I to router K via
J would be updated via this route. Thus, the
optimal path from J to K will again lie on the
optimal path from I to K.
Example
Consider a network of routers, {G, H, I, J, K, L, M, N}
as shown in the figure. Let the optimal route from I
to K be as shown via the green path, i.e. via the
route I-G-J-L-K. According to the optimality
principle, the optimal path from J to K with be along
the same route, i.e. J-L-K.
Now, suppose we find a better route from J to K is
found, say along J-M-N-K. Consequently, we will also
need to update the optimal route from I to K as I-GJ-
M-N-K, since the previous route ceases to be optimal
in this situation. This new optimal path is shown line
orange lines in the following figure −
•The set of optimal routes from all sources to a given
destination form a tree rooted at the destination.
• Such a tree is called a sink tree.
•The goal of all routing algorithms is to discover and use
the sink trees for all routers
▪ Static algorithm
▪ Every incoming packet is sent out on every outgoing line except
the one it arrived on.
▪ Flooding is a non-adaptive routing technique
following this simple method: when a data packet
arrives at a router, it is sent to all the outgoing links
except the one it has arrived on.
46
• In the example
• Using flooding technique −
• An incoming packet to A, will be sent to B, C and
D.
• B will send the packet to C and E.
• C will send the packet to B, D and F.
• D will send the packet to C and F.
• E will send the packet to F.
• F will send the packet to C and E.
▪ Flooding obviously generates vast (infinite) numbers of
duplicate packets
▪ some measures are taken to damp the process.
▪ One such measure is
▪ to have a hop counter contained in the header of each
packet, which is decremented at each hop, with the
packet being discarded when the counter reaches zero.
▪ Ideally, the hop counter should be initialized to the length
of the path from source to destination.
▪ If the sender does not know how long the path is, it can
initialize the counter to the worst case, namely, the full
diameter of the subnet.
▪ An alternative technique is
▪ to keep track of which packets have been flooded, to
avoid sending them out a second time.
▪ This is achieved by having the source router put a
sequence number in each packet it receives from its
hosts.
▪ Each router then needs a list per source router telling
which sequence numbers originating at that source have
already been seen.
▪ If an incoming packet is on the list, it is not flooded.
50
▪ Flooding:
▪ When a packet comes in, it is easy to check if the packet is a
duplicate;
▪ if so, it is discarded.
▪ Variant: Selective flooding:
▪ routers do not send every incoming packet out on every line,
▪ It will send only on those lines that are going approximately in
the right direction. (Remember about sink tree)
51
▪ Flooding is not practical in most applications, but it does
have some uses.
▪ For example,
▪ In military applications, where large numbers of routers may be
blown to bits at any instant, the tremendous robustness of
flooding is highly desirable.
▪ In distributed database applications, it is sometimes necessary to
update all the databases concurrently, in which case flooding can
be useful.
▪ In wireless networks, all messages transmitted by a station can be
received by all other stations within its radio range.
▪ Used in metric against which other routing algorithms can be
compared. 52
Distance Vector Routing
◻ Dynamic routing
◻ Modern CN Generally use dynamic routing than Static
◻ This algorithm operates by having each router maintain a table giving the best
known distance to each destination and which link to use to get there.
◻ These tables are updated by exchanging information with the neighbors.
◻ Eventually, every router knows the best link to reach each destination.
◻ It was the original ARPANET routing algorithm and was also used in the Internet
under the name RIP
◻ In distance vector routing, each router maintains a routing table indexed by, and
containing one entry for each router in the network.
◻ This entry has two parts: the preferred outgoing line to use for that destination
and an estimate of the distance to that destination
◻ The distance might be measured as the number of hops or using another metric,
as in computing shortest paths
🞑 If the metric is propagation delay, the router can measure it directly with
special ECHO packets that the receiver just timestamps and sends back as fast
as it can
◻ As an example, assume that delay is used as a metric and that the router knows
the delay to each of its neighbors.
◻ Once every T msec, each router sends to each neighbor a list of its estimated
delays to each destination.
◻ It also receives a similar list from each neighbor. Imagine that one of these tables
has just come in from neighbor X, with Xi being X’s estimate of how long it takes to
get to router i.
◻ If the router knows that the delay to X is m msec, it also knows that it can reach
router i via X in:
🞑 Xi + m msec.
◻ By performing this calculation for each neighbor, a router can find out which
estimate seems the best and use that estimate and the corresponding link in its
new routing table.
◻ Shows a network
🞑 18 (6 + 12), and
◻ The best of these values is 18, so it makes an entry in its routing table that the
delay to G is 18 msec and that the route to use is via H.
• Before it can send any updates it’s possible that it will receive an update from A
which will be advertising that it can get to C at a cost of 2
• B can get to A at a cost of 1, so it will update a route to C via A at a cost of 3
• A will then receive updates from B later and update its cost to 4
• They will then go on feeding each other bad information toward infinity which is
called as Count to Infinity problem.
Solution:
• Route Poisoning:
When a route fails, distance vector protocols spread the bad news about a route
failure by poisoning the route
• Route poisoning refers to the practice of advertising a route, but with a special
metric value called Infinity
• Each distance vector routing protocol uses the concept of an actual metric value
that represents infinity
• RIP defines infinity as 16
• But according to Split horizon Rule, Node A does not advertise its route for C
(namely A to B to C) back to B
• On the surface, this seems redundant since B will never route via node A because
the route costs more than the direct route from B to C
Link State Routing
• Dynamic Routing Algorithm
• Distance vector routing algorithm used in ARPANET is later replaced by an entirely
new algorithm, now called → Link state routing
• The idea behind link state routing is fairly simple and can be stated as five parts.
• Each router must do the following things to make it work:
❖The most direct way to determine this delay is to send over the
line a special ECHO packet that the other side is required to
send back immediately.
❖By measuring the round-trip time and dividing it by two, the
sending router can get a reasonable estimate of the delay.
❖For even better results → Test conducted in several times
→ Take average
75
Routing Algorithms - LSR
3. Building Link State Packets (LSP)
❖Once the information needed for the exchange has been collected,
the next step is for each router to build a packet containing all the
data.
❖The packet starts with the identity of the sender, followed by a
sequence number and age and a list of neighbors.
❖For each neighbor, the delay to that neighbor is given.
76
(a) A subnet. (b) The link state packets for this subnet.
Routing Algorithms - LSR
• If it is a duplicate, it is discarded.
Computing the shortest Routes
• Once a router has accumulated a full set of link state packets, it can
construct the entire network graph because every link is
represented.
• Every link is, in fact, represented twice, once for each direction.
• The results of this algorithm tell the router which link to use to
reach each destination.
81
• Link state routing is widely used in actual networks like
(a) A network. (b) A spanning tree for the leftmost router. (c) A
multicast tree for group 1. (d) A multicast tree for group 2.
• Fig. (c), all the links that do not lead to hosts that are members
of group 1 have been removed.
• The result is the multicast spanning tree for the leftmost router
to send to group 1.
• Packets are forwarded only along this spanning tree, which is
more efficient than the broadcast tree because there are 7 links
instead of 10.
• Fig. (d) shows the multicast spanning tree after pruning for
group 2.
• It is efficient too, with only five links this time. It also shows
that different multicast groups have different spanning trees.
• An alternative design uses core-based trees to compute a single
spanning tree for the group.
• All of the routers agree on a root (called the core or rendezvous
point) and build the tree by sending a packet from each
• member to the root.
• The tree is the union of the paths traced by these packets.
• Fig. (a) shows a core-based tree for group 1. To send to this
group, a sender sends a packet to the core.
• When the packet reaches the core, it is forwarded down the tree.
This is shown in Fig. (b) for the sender on the righthand side of
the network.
• As a performance optimization, packets destined for the group
do not need to reach the core before they are multicast.
• As soon as a packet reaches the tree, it can be forwarded up
toward the root, as well as down all the other branches. This is
the case for the sender at the top of Fig. (b).
Multicast Routing
Fig: A WAN to which LANs, MANs, and wireless cells are attached.
88
Routing Algorithms – Mobile Host
• Hosts that never move are said to be stationary.
• They are connected to the network by copper wires
or fiber optics.
• Migratory hosts are basically stationary hosts who
move from one fixed site to another from time to time
• but use the network only when they are physically
connected to it.
• Roaming hosts actually compute on the run and want to
maintain their connections as they move around.
• Mobile hosts are all hosts that are away from home and
still want to be connected. (both Migratory hosts &
Roaming hosts)
89
Routing Algorithms – Mobile Host
92
Routing Algorithms – Mobile Host
• Step 5:
✓ When the foreign agent gets the acknowledgement from the home agent,
it makes an entry in its tables and informs the mobile host that it is now
registered.