0% found this document useful (0 votes)
5 views

Module-5_Part-2

The document discusses the network layer's role in packet delivery, emphasizing connectionless communication and the independent treatment of packets. It covers forwarding techniques, routing tables, and the importance of routing protocols for maintaining network connectivity and optimizing paths. Additionally, it contrasts distance vector and link state routing, detailing their mechanisms and advantages in dynamic network environments.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Module-5_Part-2

The document discusses the network layer's role in packet delivery, emphasizing connectionless communication and the independent treatment of packets. It covers forwarding techniques, routing tables, and the importance of routing protocols for maintaining network connectivity and optimizing paths. Additionally, it contrasts distance vector and link state routing, detailing their mechanisms and advantages in dynamic network environments.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 96

Module 5

Network Layer
Network Layer
The network layer supervises the handling of the
packets by the underlying physical networks. We define
this handling as the delivery of a packet.
Internet – Connectionless Packet
Switching Inter-Network
• Packets in IPv4 called Datagrams
• Communication at network layer
connectionless
– Resource allocation on demand
– No reserved bandwidth on links, no scheduled
processing time for each packet. Ex : Restaurant
• N/W Layer protocol treats each packet
independently
• No relationship between packets
• May/May not travel same path to destination
• Datagrams could arrive out of order
N/W Layer : Direct vs Indirect Delivery

• N/W Layer
– supervises handling of packets by underlying physical
networks
– Data Delivery to final destination
– Direct
• Same physical network (SA & DA) (or)
• Delivery between Last router and destination host
• Sender extracts Network Address of Destination Address using
mask and compares with directly connected network address
– Indirect
• Not on same network as deliverer
• Packet goes from Router to Router until reaches destination
network
Figure 22.1 Direct and indirect delivery

22.5
FORWARDING
Forwarding means to place the packet in its route to its
destination. Forwarding requires a host or a router to
have a routing table. When a host has a packet to send
or when a router has received a packet to be forwarded,
it looks at this table to find the route to the final
destination.

Topics discussed in this section:


Forwarding Techniques
Forwarding Process
Routing Table
22.6
N/W Layer : Forwarding Techniques

• Forwarding requires
– Host or Router to have routing table
– Look for a route to destination
– Table lookup vs number of entries
• Techniques
– Next Hop Method vs Route Method
• Only Next Hop Address vs Complete Route
– Network-specific vs Host Specific
• Reduce Routing table
• One single entity for same physical network
– Default Method
• Simplify routing
Figure 22.2 Route method versus next-hop method

22.8
Figure 22.3 Host-specific versus network-specific method

22.9
Figure 22.4 Default method

22.10
Figure 22.5 Simplified forwarding module in classless address

22.11
Fundamentals of Routes, Next Hop Addresses and Packet
Forwarding
Figure 22.6 Configuration for Example 22.1

Make a routing table for router R1, using the


configuration in Figure 22.6.

22.13
Table 22.1 Routing table for router R1 in Figure 22.6

22.14
Example 22.2

Show the forwarding process if a packet arrives at R1 in


Figure 22.6 with the destination address 180.70.65.140.
Solution
The router performs the following steps:
1. The first mask (/26) is applied to the destination address.
The result is 180.70.65.128, which does not match the
corresponding network address.
2. The second mask (/25) is applied to the destination
address. The result is 180.70.65.128, which matches the
corresponding network address. The next-hop address
and the interface number m0 are passed to ARP for
further processing.
22.15
Figure 22.7 Address aggregation

Obtain Network Address from


Destination Address using Mask

22.16
Figure 18.34: Address aggregation

18.17
Figure 22.8 Longest mask matching

22.18
Routing Table

• Routing Table
– Static
• Administrator – manual entries
– Dynamic
• Updated automatically when change somewhere in
internet.
• Table updated as soon as there is change
• Ex : Router is down/ better route/ link failure
Why Does Routing Matter?
• Routing provides connectivity!
– Without routing, the network doesn’t function
• Routing finds “good” paths
– Propagation delay, throughput, packet loss
• Routing allows network to tolerate failures
– Limits packet loss during disruptions
• Routing can also provide “Traffic Engineering”
– Balance traffic over the routers and links
– Avoid congestion by directing traffic to lightly-
20 loaded links
Routing Protocols

• Routing Protocols
– Due to demand for dynamic routing tables
– Combination of rules/procedures
– Routers inform each other of changes
– Share whatever they know about neighborhood
or internet
– Combine information received from other
routers
Unicast Routing Protocols : Optimization

• Router receives a packet


– Which network should it pass?
– Which of the available pathway is optimum?
– Optimization Decision
• Cost assigned for passing through network

• METRIC
• Depends on type of routing protocol
• RIP, OSPF, BGP etc…
Metrics

• Hop count
– The number of times that a packet passes through the output
port of one router
• Bandwidth
– The data capacity of a link; for instance, normally, a 10-Mbps
Ethernet link is preferable to a 64-kbps leased line
• Delay
– The length of time that is required to move a packet from
source to destination
• Load
– The amount of activity on a network resource, such as a router
or link
• Reliability
– Usually refers to the bit error rate of each network link
Intra and InterDomain Routing

• Difficult for one routing protocol to handle


the task of updating routing tables of all
routers
• Divide internet into
– Autonomous Systems (AS)
• Group of networks and routers
under authority of single
administration
Figure 22.12 Autonomous systems

Routing inside AS

Routing between AS

22.25
Figure 22.13 Popular routing protocols

22.26
Distance Vector Routing

• Least cost route between 2 nodes


– Route with minimum distance
– Ex : Cities – Roads
– Next-Hop Routing (Vector)
– Phases
• Initialization
• Sharing
• Updating
• When to Share?
Key features of Distance Vector Routing

• The routers share the knowledge of the


entire autonomous system

• Sharing of information takes place only


with the neighbors

• Sharing of information takes place at


fixed regular intervals
Figure 22.14 Distance vector routing tables

22.29
Figure 22.15 Initialization of tables in distance vector routing

Phase1 : Initialization

Immediate neighbors directly connected. Others Unreachable (infinity)

22.30
Phase2 : Sharing

Share the entire table to neighbor?


Ans : next node is sender, 2 columns only
Note

In distance vector routing, each node


shares its routing table with its
immediate neighbors periodically and
when there is a change.

22.31
Figure 22.16 Updating in distance vector routing
Phase3 : Updating

Add sending node as next-hop

Next hop for same destination Tie?


• different, take smaller cost
• same, Choose old entry
22.32
Phase 3 : Updating

• Next-hop entry is same,


– Ex : node C previously advertised route
to node X (Distance 3) (Old route)
– Link fails, Node C --- Node X (Distance
∞ ) (new route).
– Node C advertises this new route now.
– Which one to take?
When to Share?

– Periodic Update
• 30 seconds
• Depends on the Distance vector Routing Protocol

– Triggered Update
• Any time if change in routing table
• Receives table from neighbor and changes in own
table after updating
• Failure in neighboring links results in distance ∞
Two Node Loop Instability

– Network Becomes Unstable?

– Suddenly link failure between A & X


– What if B sends routing table to A before
A can send? – instability scenario
Figure 22.17 Two-node instability

2 node loop problem

22.36
Solutions to 2 node loop problem

1. Defining Infinity
– Redefine ∞ to say 100
– System will become stable in less updates
– Distance taken as 1 between each node
– Infinity = 16
– Limitations : Size of network cannot
exceed 15 hops
Solutions to 2 node loop problem contd..

2. Split Horizon
– Way to eliminate routing loops
– Speed up convergence
– prevents a router from advertising a route
back out the same interface where the
router originally learned the route
• Send part of table through each interface
• B knows optimum route to reach X via A , eliminate
sending in same interface (A already knows)
• Don’t create confusion
Solutions to 2 node loop problem contd..

3. Poison Reverse
– Route poisoning enables the receiving

router to advertise a route back toward


the source with a metric higher than
the maximum (Infinity).
– Infinity as Warning : “Do not use this value,
What I Know about this route comes from you”
– Why? Split Horizon Drawback : Timer for every
route in DV. Delete route if no news
Figure 22.18 Three-node instability

Cannot be guaranteed for stability

22.40
Figure 22.18 Three-node instability

A will not advertise


back to B but will to C.
Loop continues.
22.41
Routing Information Protocol (RIP)

• Intradomain routing protocol used inside


autonomous system
• Based on Distance Vector Routing
• Metric in RIP
– Hop Count (distance = no of links (networks) to
reach destination)
– Infinity = 16 in RIP
– Route in an AS using RIP cannot have more than
15 hops.
Figure 22.19 Example of a domain using RIP

22.43
Figure 22.19 Example of a domain using RIP

22.44
Modeling a Network
• Modeled as a graph
– Routers  nodes 5

– Link  edges B
3
C
5
• Possible edge costs 2
– Hop A 2 1 F
3
– Delay 1
– Congestion level 2
D E
– …. 1

• Goal of Routing
– Determine “good” path from source to destination
– “Good” usually means the lowest “cost” path
– Where cost is usually hop-count or latency
45
Link State Routing

• Each node obtains entire topology of the


domain
– List of nodes and links
– How they are connected including
• Type of Link
• Cost (metric) of links
• Condition of Link (up/down)
– Node uses Dijkstra’s Algorithm to build routing
table
Link State

• Link-state defines the characteristic of a link (an


edge) that represents a network
• LS protocols will take a path which may have
more hops, but that uses a faster medium over
a path using a slower medium with fewer hops.
• Links with lower costs are preferred to links
with higher costs;
• If the cost of a link is infinity, it means that the
link does not exist or has been broken
Figure 22.20 Concept of link state routing

Every router has knowledge about the network, but from its own
perspective. Ex : City Map
22.48
Figure 20.8: Example of a link-state database

20.49
Link State vs Distance Vector

• In distance vector
– Each Router tells its neighbors
what it knows about the whole AS
• In Link State
– Each Router tells the whole AS
what it knows about the neighbors
Dynamic Topology maintenance

• Latest state of each node & link


– Dynamic Topology
– Any change in any point in network (Ex : Link
down)
• Updated topology at each node?
• No node can know topology at beginning or after
change somewhere in network
• Global Knowledge about topology not clear
– Using Partial Knowledge compile whole
topology
Figure 22.21 Link state knowledge

22.52
Link State Routing

• The routers share the knowledge only


about their neighbors compared to all
the routers in the autonomous system

• Sharing of information takes place only


with all the routers in the internet, by
sending small updates using flooding
compared to sending larger updates to
their neighbors.
Building Routing Tables

1) Creation of the states of the links by each node,


called the link state packet (LSP)

2) Dissemination of LSPs to every other router,


called flooding, in an efficient and reliable way

3) Formation of a shortest path tree for each node

4) Calculation of a routing table based on the


shortest path tree
Creation of LSP

• LSP
– Advertiser ID, Sequence Number, List of neighbors
(Cost of Link) etc.
– Seq No
• Distinguish new LSPs from Old ones

• When generate LSPs?


– When there is a change in the topology of the
domain
• Triggered update
– On a periodic basis but > DV
• 60 minutes or 2 hours
Figure 20.9: LSPs created and sent out by each node to build LSDB

20.56
Flooding of LSPs

• Dissemination of LSPs to every other router, called flooding


• A node that receives an LSP compares it with the copy it may
already have.
– If the newly arrived LSP is older than the one it has, it
discards the LSP.
– If it is newer,
1) the node does discard the old LSP and keep the new
one
2) It sends a copy of it out of each interface except the
one from which the packet arrived
– Guarantees that flooding stops somewhere in the domain
(where node has only one interface)
Figure 20.8: Example of a link-state database

20.58
Figure 22.22 Dijkstra algorithm

22.59
Figure 22.23 Example of formation of shortest path tree

22.60
20.61
Table 22.2 Routing table for node A

22.62
Figure 20.8: Example of a link-state database

20.63
Table 20.2: Dijkstra’s Algorithm
Figure 20.10: Least-cost tree

20.65
Example: Initialization

Distance(source) = 0 ∞ Distance (all vertices


0 A 2
B but source) = ∞

4 1 3 10

2 2 ∞
∞ C D E

5 8 ∞ 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance.

66
Example: Update neighbors' distance

0 2
2
A B

4 1 3 10

2 2 ∞
∞ C D E

5 8 1 4 6

Distance(B) = 2 1
F G
Distance(D) = 1
∞ ∞

67
Example: Remove vertex with
minimum distance
0 2
2
A B

4 1 3 10

2 2 ∞
∞ C D E

5 8 1 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance, i.e., D

68
Example: Update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

Distance(C) = 1 + 2 = 3 1
F G
Distance(E) = 1 + 2 = 3
Distance(F) = 1 + 8 = 9 9 5
Distance(G) = 1 + 4 = 5

69
Example: Continued...
Pick vertex in List with minimum distance (B) and update neighbors
0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6
Note : distance(D) not
F 1
G updated since D is
already known and
9 5 distance(E) not updated
since it is larger than
previously computed

70
Example: Continued...
Pick vertex List with minimum distance (E) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G
No updating
9 5

71
Example: Continued...
Pick vertex List with minimum distance (C) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

Distance(F) = 3 + 5 = 8 1
F G

8 5

72
Example: Continued...
Pick vertex List with minimum distance (G) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G
Previous distance
6 5
Distance(F) = min (8, 5+1) = 6

73
Example (end)

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G

6 5
Pick vertex not in S with lowest cost (F) and update neighbors

74
OSPF (Open Shortest Path First)

• Open Shortest Path First (OSPF) protocol


– intradomain routing protocol based on link state
routing.
– Its domain is also an autonomous system
– RIP was increasingly incapable of serving large,
heterogeneous internetworks
– OSPF being a SPF algorithm scales better than RIP.
– This protocol is open, which means that its
specification is in the public domain.
– It means that anyone can implement it without
paying license fees.
Metrics (Cost) – OSPF depending on TOS

• Administrator can assign cost to each route


• Ex : Metric = 108/Speed
Link State Routing
• Each router has complete network picture
– Topology
– Link costs
• How does each router get the global state?
– Each router reliably floods information about its
neighbors to every other router (more later)
• Each router independently calculates the
shortest path from itself to every other router
– Using, for example, Dijkstra’s Algorithm

77
Figure 21-24
Concept of Link State Routing
Dijkstra’s Algorithm

79
Single-Source Shortest Path Problem

Single-Source Shortest Path Problem - The


problem of finding shortest paths from a source
vertex v to all other vertices in the graph.
Dijkstra's algorithm
Dijkstra's algorithm - is a solution to the single-source
shortest path problem in graph theory.

Works on both directed and undirected graphs. However,


all edges must have nonnegative weights.

Input: Weighted graph G={E,V} and source vertex v∈V,


such that all edge weights are nonnegative

Output: Lengths of shortest paths (or the shortest paths


themselves) from a given source vertex v∈V to all other
vertices
Approach
• The algorithm computes for each vertex u the distance to u
from the start vertex v, that is, the weight of a shortest path
between v and u.
• the algorithm keeps track of the set of vertices for which the
distance has been computed, called the cloud C
• Every vertex has a label D associated with it. For any vertex u,
D[u] stores an approximation of the distance between v and
u. The algorithm will update a D[u] value when it finds a
shorter path from v to u.
• When a vertex u is added to the cloud, its label D[u] is equal
to the actual (final) distance between the starting vertex v and
vertex u.

82
Dijkstra pseudocode
Dijkstra(v1, v2):
for each vertex v: // Initialization
v's distance := infinity.
v's previous := none.
v1's distance := 0.
List := {all vertices}.
while List is not empty:
v := remove List vertex with minimum distance.
mark v as known.
for each unknown neighbor n of v:
dist := v's distance + edge (v, n)'s weight.
if dist is smaller than n's distance:
n's distance := dist.
n's previous := v.
reconstruct path from v2 back to v1,
following previous pointers.

83
Example: Initialization

Distance(source) = 0 ∞ Distance (all vertices


0 A 2
B but source) = ∞

4 1 3 10

2 2 ∞
∞ C D E

5 8 ∞ 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance.

84
Example: Update neighbors' distance

0 2
2
A B

4 1 3 10

2 2 ∞
∞ C D E

5 8 1 4 6

Distance(B) = 2 1
F G
Distance(D) = 1
∞ ∞

85
Example: Remove vertex with
minimum distance
0 2
2
A B

4 1 3 10

2 2 ∞
∞ C D E

5 8 1 4 6

1
F G

∞ ∞

Pick vertex in List with minimum distance, i.e., D

86
Example: Update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

Distance(C) = 1 + 2 = 3 1
F G
Distance(E) = 1 + 2 = 3
Distance(F) = 1 + 8 = 9 9 5
Distance(G) = 1 + 4 = 5

87
Example: Continued...
Pick vertex in List with minimum distance (B) and update neighbors
0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6
Note : distance(D) not
F 1
G updated since D is
already known and
9 5 distance(E) not updated
since it is larger than
previously computed

88
Example: Continued...
Pick vertex List with minimum distance (E) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G
No updating
9 5

89
Example: Continued...
Pick vertex List with minimum distance (C) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

Distance(F) = 3 + 5 = 8 1
F G

8 5

90
Example: Continued...
Pick vertex List with minimum distance (G) and update neighbors

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G
Previous distance
6 5
Distance(F) = min (8, 5+1) = 6

91
Example (end)

0 2
2
A B

4 1 3 10

2 2 3
3 C D E

5 8 1 4 6

1
F G

6 5
Pick vertex not in S with lowest cost (F) and update neighbors

92
Bellman Ford Algorithm
1) This step initializes distances from source to all vertices as infinite and distance to source
itself as 0. Create an array dist[] of size |V| with all values as infinite except dist[src] where src
is source vertex.
2) This step calculates shortest distances. Do following |V|-1 times where |V| is the number of
vertices in given graph.
…..a) Do following for each edge u-v
………………If dist[v] > dist[u] + weight of edge uv, then update dist[v]
………………….dist[v] = dist[u] + weight of edge uv
3) This step reports if there is a negative weight cycle in graph. Do following for each edge u-v
……If dist[v] > dist[u] + weight of edge uv, then “Graph contains negative weight cycle”
The idea of step 3 is, step 2 guarantees shortest distances if graph doesn’t contain negative
weight cycle. If we iterate through all edges one more time and get a shorter path for any
vertex, then there is a negative weight cycle
Let the given source vertex be 0. Initialize all
distances as infinite, except the distance to
source itself. Total number of vertices in the
graph is 5, so all edges must be processed 4
times.
Let all edges are processed
in the following order: (B,
E), (D, B), (B, D), (A, B), (A,
C), (D, C), (B, C), (E, D).
The first row shows initial
distances.
The second row shows
distances when edges (B,
E), (D, B), (B, D) and (A, B)
are processed.
The third row shows
distances when (A, C) is
processed.
The fourth row shows
when (D, C), (B, C) and (E,
D) are processed.
The second iteration guarantees to give all shortest paths which
are at most 2 edges long.
Let all edges are processed in the following order: (B, E), (D, B),
(B, D), (A, B), (A, C), (D, C), (B, C), (E, D).

You might also like