CN Unit - Iii
CN Unit - Iii
Let us assume for this example that the message is four times longer
than the maximum packet size, so the network layer has to break it
into four packets, 1, 2, 3, and 4, and send each of them in turn to
router A.
Every router has an internal table telling it where to send packets for
each of the possible destinations. Each table entry is a pair(destination
and the outgoing line). Only directly connected lines can be used.
A’s initial routing table is shown in the figure under the label
‘‘initially.’’ At A, packets 1, 2, and 3 are stored briefly, having arrived
on the incoming link. Then each packet is forwarded according to A’s
table, onto the outgoing link to C within a new frame. Packet 1 is then
forwarded to E and then to F.
However, something different happens to packet 4. When it gets to A
it is sent to router B, even though it is also destined for F. For some
reason (traffic jam along ACE path), A decided to send packet 4 via a
different route than that of the first three packets. Router A updated its
routing table, as shown under the label ‘‘later.’’
The algorithm that manages the tables and makes the routing
decisions is called the routing algorithm.
It refers to the algorithms that help to find the shortest path between a
sender and receiver for routing the data packets through the network
in terms of shortest distance, minimum cost, and minimum time.
● It is mainly for building a graph or subnet containing routers as
nodes and edges as communication lines connecting the nodes.
● Hop count is one of the parameters that is used to measure the
distance.
● Hop count: It is the number that indicates how many routers are
covered. If the hop count is 6, there are 6 routers/nodes and the
edges connecting them.
● Another metric is a geographic distance like kilometers.
● We can find the label on the arc as the function of bandwidth,
average traffic, distance, communication cost, measured delay,
mean queue length, etc.
Dijkstra’s Algorithm
The Dijkstra’s Algorithm is a greedy algorithm that is used to find the
minimum distance between a node and all other nodes in a given
graph. Here we can consider node as a router and graph as a network.
It uses weight of edge .ie, distance between the nodes to find a
minimum distance route.
Algorithm:
1: Mark the source node current distance as 0 and all others as
infinity.
2: Set the node with the smallest current distance among the
non-visited nodes as the current node.
3: For each neighbor, N, of the current node:
● Calculate the potential new distance by adding the current distance
of the current node with the weight of the edge connecting the
current node to N.
● If the potential new distance is smaller than the current distance of
node N, update N’s current distance with the new distance.
4: Make the current node as visited node.
5: If we find any unvisited node, go to step 2 to find the next node
which has the smallest current distance and continue this process.
Example:
Consider the graph G:
Now,we will start normalising graph one by one starting from node 0.
step 1
step 5
3.2.2: FLOODING
Types of Flooding
2. Multi-destination Routing:
Each broadcast packet contains either a list of destinations or a bit
map indicating the desired destinations.
Routers determine the output lines needed for the destinations and
generate new copies of the packet for each output line.
Bandwidth usage is more efficient compared to distinct packets,
but the source still needs to know all destinations, and routers have to
determine where to send the packets.
3. Flooding:
Flooding involves sending a broadcast packet to all links in the
network, except the one it arrived on.
Although it uses links efficiently and is simple to implement, it can
lead to a large number of duplicates and is generally not suitable for
point-to-point communication.
Flooding is a popular method for broadcasting due to its simplicity.
Core-Based Trees:
Core-based trees are an alternative design for multicast routing.
All routers agree on a core (or rendezvous point) and construct the
tree by sending a packet from each group member to the core. The
tree is formed by the union of the paths traced by these packets.
The core-based tree allows sending packets to the core, which then
forwards them down the tree to all group members.
It provides a shared tree for all sources, reducing storage costs,
messages sent, and computation, making it efficient for sparse groups.
Example
Consider-
● There is a network consisting of 4 routers.
● The weights are mentioned on the edges.
● Weights could be distances or costs or delays.
It works in the following steps-
Step-01:
Each router prepares its routing table using its local knowledge.
Routing table prepared by each router is shown below-
At Router A-
A 0 A
B 2 B
C ∞ –
D 1 D
At Router B-
Destination Distance Next Hop
A 2 A
B 0 B
C 3 C
D 7 D
At Router C-
Destinatio
Distance Next Hop
n
A ∞ –
B 3 B
C 0 C
D 11 D
At Router D-
Destinatio
Distance Next Hop
n
A 1 A
B 7 B
C 11 C
D 0 D
Step-02:
● Each router exchanges its distance vector obtained in Step-01
with its neighbors.
● After exchanging the distance vectors, each router prepares a
new routing table.
This is shown below-
At Router A-
A 0 A
B 2 B
C 5 B
D 1 D
At Router B-
● Router B receives distance vectors from its neighbors A, C and
D.
● Router B prepares a new routing table as-
A 2 A
B 0 B
C 3 C
D 3 A
At Router C-
● Router C receives distance vectors from its neighbors B and D.
● Router C prepares a new routing table as-
A 5 B
B 3 B
C 0 C
D 10 B
At Router D-
Router D receives distance vectors from its neighbors A, B and C.
● Router D prepares a new routing table as-
A 1 A
B 3 A
C 10 B
D 0 D
Step-03:
● Each router exchanges its distance vector obtained in Step-02
with its neighboring routers.
● After exchanging the distance vectors, each router prepares a
new routing table.
This is shown below-
At Router A-
● Router A receives distance vectors from its neighbors B and
D.
● Router A prepares a new routing table as-
A 0 A
B 2 B
C 5 B
D 1 D
At Router B-
● Router B receives distance vectors from its neighbors A, C and
D.
● Router B prepares a new routing table as-
●
Cost of reaching destination A from router B = min { 2+0 ,
3+5 , 3+1 } = 2 via A.
● Cost of reaching destination C from router B = min { 2+5 ,
3+0 , 3+10 } = 3 via C.
● Cost of reaching destination D from router B = min { 2+1 ,
3+10 , 3+0 } = 3 via A.
A 2 A
B 0 B
C 3 C
D 3 A
At Router C-
A 5 B
B 3 B
C 0 C
D 6 B
At Router D-
● Router D receives distance vectors from its neighbors A, B
and C.
● Router D prepares a new routing table as-
B 3 A
C 6 A
D 0 D
• Also, when the bucket is full, any additional water that enters into
the bucket spills over the sides and is lost.
• The same concept can be applied to packets in the network.
Consider that data is coming from the source at variable speeds.
Suppose that a source sends data at 12 Mbps for 4 seconds. Then
there is no data for 3 seconds. The source again transmits data at a
rate of 10 Mbps for 2 seconds. Thus, in a time span of 9 seconds, 68
Mb data has been transmitted.
If a leaky bucket algorithm is used, the data flow will be 8 Mbps for
9 seconds. Thus constant flow is maintained.
Tunnelling is useful when the source and destination hosts are on the
same type of network, but there is a different network (the tunnel) in
between. For example, an organisation with an IPv6 network in Paris,
an IPv6 network in London, and connectivity between the offices via
the IPv4 Internet.
Fragmentation Strategies:
Transparent Fragmentation: In this strategy, routers break up
oversized packets into fragments, and each fragment is addressed to
the same exit router where they are recombined. Subsequent networks
are unaware that fragmentation occurred. However, this approach
requires the exit router to know when all fragments have arrived and
may constrain routing options.
The design principles that drove the success of the network layer in
the Internet can be summarized as follows:
1. Make sure it works: Finalize the design or standard only after
successful communication between multiple prototypes. Avoid
writing extensive standards that may be deeply flawed and do not
work.
2. Keep it simple: Use the simplest solution when in doubt. Avoid
adding unnecessary features; fight complexity to keep the design
straightforward.
3. Make clear choices: Choose one way of doing things when there
are multiple options. Avoid providing multiple modes or parameters,
as it can lead to trouble.
4. Exploit modularity: Use protocol stacks with independent layers.
This allows changing one module or layer without affecting others.
5. Expect heterogeneity: Design the network to handle different
hardware, transmission facilities, and applications. Keep the design
simple, general, and flexible to accommodate varying requirements.
6. Avoid static options and parameters: Prefer dynamic negotiation
of parameters between the sender and receiver rather than defining
fixed choices.
7. Look for a good design; it need not be perfect: Choose a good
design even if it cannot handle some rare special cases. The burden of
working around specific requirements can be put on the users with
unique needs.
8. Be strict when sending and tolerant when receiving: Strictly
adhere to standards when sending packets but be flexible and able to
handle non-conforming incoming packets.
9. Think about scalability: Design the network to handle millions of
hosts and billions of users effectively. Avoid centralized databases and
spread the load evenly across available resources.
10. Consider performance and cost: Ensure that the network has
good performance and reasonable costs to encourage its usage.
The Internet's network layer is built around the Internet Protocol (IP).
The network layer provides a best-effort way to transport IP packets
from the source to the destination without concern for whether the
machines are on the same network or whether multiple networks are
in between.
Version Field:
The version field indicates the version of the IP protocol being
used, and it is set to 4 for IPv4.
Protocol Field:
The Protocol field specifies the transport protocol to which the
packet should be handed at the destination, such as TCP or UDP.
Subnets
CANN (Internet Corporation for Assigned Names and Numbers)
manages the allocation of network numbers to avoid conflicts.
ICANN delegates parts of the address space to regional authorities,
who assign IP addresses to ISPs and other companies.
As companies grow and require more IP addresses, the initial block
allocation may become inefficient. Routers need all hosts in a network
to have the same network number for proper routing by prefix. When
a single network becomes too large, dividing it into smaller subnets is
necessary to address the address shortage issue.
Subnetting Process:
Subnetting allows a block of IP addresses to be split into several
smaller parts for internal use as multiple networks (subnets). Subnets
enable efficient use of IP address space without requiring additional
blocks from external authorities. Each subnet must be aligned so that
any bits can be used in the lower host portion.
Subnet Example:
An example network with a /16 prefix is split into three subnets for
different departments.
Computer Science Dept.: /17 (half of the original block)
Electrical Engineering Dept.: /18 (quarter of the original block)
Art Dept.: /19 (eighth of the original block)
One eighth of the original block remains unallocated.
Subnet Routing:
When a packet arrives at a router, the router needs to determine which
subnet the destination IP address belongs to. The router does this by
ANDing the destination address with the subnet mask for each subnet
and checking if it matches the corresponding prefix. The longest
matching prefix determines the correct subnet for the packet.
Routers at the edge of a network need entries for each of their subnets
in their routing tables. Core routers in the default-free zone of the
Internet need to know routes to every network, leading to large
routing tables. Large routing tables can cause performance issues and
communication complexities.
Cambridge University:
Needs 2048 addresses.
Assigned IP addresses: 194.24.0.0 to 194.24.7.255
Subnet mask: 255.255.248.0 (which is equivalent to /21 prefix)
The subnet mask 255.255.248.0 (or /21) means that the first 21 bits of
the IP address are the network portion, and the remaining 11 bits are
the host portion. This allows for 2^11 = 2048 addresses, which is
sufficient for Cambridge University.
Oxford University:
Needs 4096 addresses.
The subnet mask 255.255.240.0 (or /20) allows for 4096 addresses,
with the first 20 bits being the network portion and the remaining 12
bits being the host portion. Oxford University gets a block of 4096
addresses that starts at 194.24.16.0.
University of Edinburgh:
Needs 1024 addresses.
Advantages of CIDR:
Reduces the size of routing tables, making routing more efficient.
Allows flexible address allocation and aggregation based on
network requirements.
CIDR is widely used in the Internet and reduces routing table sizes
to manageable levels.
Hardware Support:
Complex algorithms have been devised to speed up the address
matching process in routers.
Commercial routers use custom VLSI chips with these algorithms
embedded in hardware to handle large routing tables efficiently.
IPv6 packet may contain zero, one or more extension headers but these
should be present in their recommended order:
ARP Caching:
After an ARP request and response have occurred, many hosts will
cache the result (IP-to-Ethernet mapping) for a period of time to avoid
repeating the ARP process for the same destination. This caching
helps to optimise network performance and reduce unnecessary
broadcast traffic.
MPLS Header:
A 4-byte header is added to the packet, containing:
● Label: Index into the forwarding table.
● QoS (Quality of Service): Indicates priority or service level.
● S (Stacking) Bit: Used for stacking multiple labels.
● TtL (Time to Live): Decremented at each hop to prevent
looping.
MPLS operates
MPLS can use multiple labels stacked on top of each other. Outer
label guides the path, inner labels are revealed at the end of the path
for further forwarding.
MPLS is sometimes referred to as a "layer 2.5" protocol. It operates
between the network layer (IP) and the link layer (PPP, Ethernet, etc.).
It doesn't interfere with IP addresses, allowing flexibility in routing.
Benefits of MPLS:
1. Fast Forwarding: Labels enable quick and efficient forwarding
based on lookup tables.
2. Quality of Service (QoS): MPLS can support differentiated service
levels.
3. Traffic Engineering: Optimizing network resources and traffic
distribution.
4. Multiprotocol Support: MPLS can carry various types of traffic,
not just IP.
OSPF Areas
Special routers are also there in a divided area. The routers that are
present at the border of an area are considered special routers and
these are also known as Area Border Routers.
Special routers generally summarise the whole information of an area
and also share information about an area with other areas.
Working of OSPF
Step 3: The third step in the working of the OSPF protocol is to select
the best route. After an exchange of LSDB information, the router
finds the best route for adding to the routing table.
The logic used by the router to set the router ID is given below.
Manually assigned: First of all the router checks whether the router
ID is assigned manually or not. If the ID is set manually, then that is
considered the router ID. Otherwise, if the ID is not manually set then
the router selects the highest 'up' status loopback interface IP address
as an ID. In a situation, where no loopback interfaces are available
then for the ID it will select the highest 'up' status non-loopback
interface IP address.
Type: It is the field of 8 bits that is used to specify the OSPF packet
type.
OSPF Packets
Hello
Database Description
The router sends the link-state request to get the information about the
specified route. Let us assume two routers are connected and router 1
wants to know the information of router 2. For this router1 sends the
link state request to the router2. Router2 sends the link-state
information to router 1 after receiving the link-state request from
router 1.
Link state link-state update is used for advertising. Link state update
is also used when the router wants to broadcast the link state.
OSPF States
Down
When the state of the device is down, it is not able to receive the
HELLO packet. This down state does not refer to the down condition
of the device physically. It simply means that the process of the OSPF
protocol has not been started.
Init
When the device enters in init state, it refers to the HELLO packet
being received from the other routers.
Exstart
If the connection between both the routers starts, then the routers
enter the Exstart state. In this state, the master and slave get selected
based on the router's ID. The main function of the master is to control
the sequence of numbers and then begin the exchange process.
Exchange
When the device enters the exchange state, both routers start
transferring the list of LSA(Link State Advertisements) to each other.
The LSA includes a database description.
Loading
Full
The device will enter into the full state if the exchange of LSA is
completed successfully.
Router Attributes
Before entering the Extract state, the OSPF protocol selects one router
that acts as a designated router(DR) and other routers act as a backup
designated router(BDR). These routers are only the attributes but not
the type of routers. If there is a condition of the broadcast network,
then the router chooses one router that acts as a designated router and
the other router acts as a backup designated router.
Refer to the below image for an example of the concept of the DR.