You are on page 1of 58

UNIT-IV

Network Layer
FLOODING

 Another static algorithm is flooding, in which every incoming packet


is sent out on every outgoing line except the one it arrived on.
 Flooding obviously generates vast numbers of duplicate packets, in
fact, an infinite number unless some measures are taken to damp
the process.

 Hop Counter
 Sequence Number
 Selective Flooding

Hop Counter

 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.

Sequence Number

 Avoid the same packet second time


 Keep each router per source a list of packets already seen

Selective Flooding

 We only those lines that are going approximately right direction

Dynamic Routing Algorithms

1. Distance Vector Routing 2. Link State Routing 3.Hierarchical Routing

Distance Vector Routing (DVR)


 A distance-vector routing (DVR) protocol requires that a router
inform its neighbors of topology changes periodically. Historically
known as the old ARPANET routing algorithm (or known as
Bellman-Ford algorithm).
 Bellman Ford Basics – Each router maintains a Distance Vector
table containing the distance between itself and ALL possible
destination nodes. Distances,based on a chosen metric, are
computed using information from the neighbors’ distance vectors.

Information kept by DVR router -


 Each router has an ID
 Associated with each link connected to a router, there is a link cost
(static or dynamic).
 Intermediate hops
Distance Vector Table Initialization -
 Distance to itself = 0
 Distance to ALL other routers = infinity number.

Distance Vector Algorithm –

 A router transmits its distance vector to each of its neighbors in a


routing packet.
 Each router receives and saves the most recently received distance
vector from each of its neighbors.

A router recalculates its distance vector when:

 It receives a distance vector from a neighbor containing different


information than before.
 It discovers that a link to a neighbor has gone down.
 The DVR calculation is based on minimizing the cost to each
destination

Dx(y) = Estimate of least cost from x to y

C(x,v) = Node x knows cost to each neighbor v

Dx = [Dx(y): y ∈ N ] = Node x maintains distance vector

Node x also maintains its neighbors' distance vectors

– For each neighbor v, x maintains Dv = [Dv(y): y ∈ N ]

Note –

From time-to-time, each node sends its own distance vector estimate to
neighbors.

When a node x receives new DVR estimate from any neighbor v, it saves v’s
distance vector and it updates its own DV using B-F equation:

Dx(y) = min { C(x,v) + Dv(y), Dx(y) } for each node y ∈ N

Example – Consider 3-routers X, Y and Z as shown in figure. Each router


have their routing table. Every routing table will contain distance to the
destination nodes.
Similarly for Z also –

Finally the routing table for all –

Advantages of Distance Vector routing –

 It is simpler to configure and maintain than link state routing.

Disadvantages of Distance Vector routing –

 It is slower to converge than link state.


 It is at risk from the count-to-infinity problem.
 It creates more traffic than link state since a hop count change must
be propagated to all routers and processed on each router. Hop count
updates take place on a periodic basis, even if there are no changes in
the network topology, so bandwidth-wasting broadcasts still occur.
 For larger networks, distance vector routing results in larger routing
tables than link state since each router must know about all other
routers. This can also lead to congestion on WAN links.

Link State Routing Algorithm

Link state routing is a technique in which each router shares the knowledge
of its neighborhood with every other router in the internetwork.

The three keys to understand the Link State Routing algorithm:

Knowledge about the neighborhood: Instead of sending its routing table, a


router sends the information about its neighborhood only. A router
broadcast its identities and cost of the directly attached links to other
routers.
Flooding: Each router sends the information to every other router on the
internetwork except its neighbors. This process is known as Flooding. Every
router that receives the packet sends the copies to all its neighbors. Finally,
each and every router receives a copy of the same information.

Information sharing: A router sends the information to every other router


only when the change occurs in the information.

Link State Routing has two phases:

Initial state: Each node knows the cost of its neighbors.

Final state: Each node knows the entire graph.

Route Calculation

Each node uses Dijkstra's algorithm on the graph to calculate the optimal
routes to all nodes.

The Link state routing algorithm is also known as Dijkstra's algorithm which
is used to find the shortest path from one node to every other node in the
network.

The Dijkstra's algorithm is an iterative, and it has the property that after
kth iteration of the algorithm, the least cost paths are well known for k
destination nodes.

Let's describe some notations:

c( i , j): Link cost from node i to node j. If i and j nodes are not directly
linked, then c(i , j) = ∞.

D(v): It defines the cost of the path from source code to destination v that
has the least cost currently.

P(v): It defines the previous node (neighbor of v) along with current least cost
path from source to v.

N: It is the total number of nodes available in the network.

Example:
 First, we have to consider any vertex as a source vertex. Suppose we
consider vertex 0 as a source vertex.
 Here we assume that 0 as a source vertex, and distance to all the
other vertices is infinity. Initially, we do not know the distances. First,
we will find out the vertices which are directly connected to the vertex
0. As we can observe in the above graph that two vertices are directly
connected to vertex 0.

Let's assume that the vertex 0 is represented by 'x' and the vertex 1 is
represented by 'y'. The distance between the vertices can be calculated by
using the below formula:

d(x, y) = d(x) + c(x, y) < d(y)

= (0 + 4) < ∞

=4<∞

Since 4<∞ so we will update d(v) from ∞ to 4.

Therefore, we come to the conclusion that the formula for calculating the
distance between the vertices:

{if( d(u) + c(u, v) < d(v))

d(v) = d(u) +c(u, v) }

Now we consider vertex 0 same as 'x' and vertex 4 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (0 + 8) < ∞

=8<∞

Therefore, the value of d(y) is 8. We replace the infinity value of vertices 1


and 4 with the values 4 and 8 respectively. Now, we have found the shortest
path from the vertex 0 to 1 and 0 to 4. Therefore, vertex 0 is selected. Now,
we will compare all the vertices except the vertex 0. Since vertex 1 has the
lowest value, i.e., 4; therefore, vertex 1 is selected.

Since vertex 1 is selected, so we consider the path from 1 to 2, and 1 to 4.


We will not consider the path from 1 to 0 as the vertex 0 is already selected.
First, we calculate the distance between the vertex 1 and 2. Consider the
vertex 1 as 'x', and the vertex 2 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (4 + 8) < ∞

= 12 < ∞

Since 12<∞ so we will update d(2) from ∞ to 12.

Now, we calculate the distance between the vertex 1 and vertex 4. Consider
the vertex 1 as 'x' and the vertex 4 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (4 + 11) < 8

= 15 < 8

Since 15 is not less than 8, we will not update the value d(4) from 8 to 12.

Till now, two nodes have been selected, i.e., 0 and 1. Now we have to
compare the nodes except the node 0 and 1. The node 4 has the minimum
distance, i.e., 8. Therefore, vertex 4 is selected.

Since vertex 4 is selected, so we will consider all the direct paths from the
vertex 4. The direct paths from vertex 4 are 4 to 0, 4 to 1, 4 to 8, and 4 to 5.
Since the vertices 0 and 1 have already been selected so we will not consider
the vertices 0 and 1. We will consider only two vertices, i.e., 8 and 5.

First, we consider the vertex 8. First, we calculate the distance between the
vertex 4 and 8. Consider the vertex 4 as 'x', and the vertex 8 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (8 + 7) < ∞

= 15 < ∞

Since 15 is less than the infinity so we update d(8) from infinity to 15.

Now, we consider the vertex 5. First, we calculate the distance between the
vertex 4 and 5. Consider the vertex 4 as 'x', and the vertex 5 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (8 + 1) < ∞

=9<∞

Since 5 is less than the infinity, we update d(5) from infinity to 9.

Till now, three nodes have been selected, i.e., 0, 1, and 4. Now we have to
compare the nodes except the nodes 0, 1 and 4. The node 5 has the
minimum value, i.e., 9. Therefore, vertex 5 is selected.
Since the vertex 5 is selected, so we will consider all the direct paths from
vertex 5. The direct paths from vertex 5 are 5 to 8, and 5 to 6.

First, we consider the vertex 8. First, we calculate the distance between the
vertex 5 and 8. Consider the vertex 5 as 'x', and the vertex 8 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (9 + 15) < 15

= 24 < 15

Since 24 is not less than 15 so we will not update the value d(8) from 15 to
24.

Now, we consider the vertex 6. First, we calculate the distance between the
vertex 5 and 6. Consider the vertex 5 as 'x', and the vertex 6 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (9 + 2) < ∞

= 11 < ∞

Since 11 is less than infinity, we update d(6) from infinity to 11.

Till now, nodes 0, 1, 4 and 5 have been selected. We will compare the nodes
except the selected nodes. The node 6 has the lowest value as compared to
other nodes. Therefore, vertex 6 is selected.

Since vertex 6 is selected, we consider all the direct paths from vertex 6. The
direct paths from vertex 6 are 6 to 2, 6 to 3, and 6 to 7.

First, we consider the vertex 2. Consider the vertex 6 as 'x', and the vertex 2
as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (11 + 4) < 12

= 15 < 12

Since 15 is not less than 12, we will not update d(2) from 12 to 15

Now we consider the vertex 3. Consider the vertex 6 as 'x', and the vertex 3
as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (11 + 14) < ∞

= 25 < ∞

Since 25 is less than ∞, so we will update d(3) from ∞ to 25.


Now we consider the vertex 7. Consider the vertex 6 as 'x', and the vertex 7
as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (11 + 10) < ∞

= 22 < ∞

Since 22 is less than ∞ so, we will update d(7) from ∞ to 22.

Till now, nodes 0, 1, 4, 5, and 6 have been selected. Now we have to


compare all the unvisited nodes, i.e., 2, 3, 7, and 8. Since node 2 has the
minimum value, i.e., 12 among all the other unvisited nodes. Therefore,
node 2 is selected.

Since node 2 is selected, so we consider all the direct paths from node 2.
The direct paths from node 2 are 2 to 8, 2 to 6, and 2 to 3.

First, we consider the vertex 8. Consider the vertex 2 as 'x' and 8 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (12 + 2) < 15

= 14 < 15

Since 14 is less than 15, we will update d(8) from 15 to 14.

Now, we consider the vertex 6. Consider the vertex 2 as 'x' and 6 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (12 + 4) < 11

= 16 < 11

Since 16 is not less than 11 so we will not update d(6) from 11 to 16.

Now, we consider the vertex 3. Consider the vertex 2 as 'x' and 3 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (12 + 7) < 25

= 19 < 25

Since 19 is less than 25, we will update d(3) from 25 to 19.

Till now, nodes 0, 1, 2, 4, 5, and 6 have been selected. We compare all the
unvisited nodes, i.e., 3, 7, and 8. Among nodes 3, 7, and 8, node 8 has the
minimum value. The nodes which are directly connected to node 8 are 2, 4,
and 5. Since all the directly connected nodes are selected so we will not
consider any node for the updation.
The unvisited nodes are 3 and 7. Among the nodes 3 and 7, node 3 has the
minimum value, i.e., 19. Therefore, the node 3 is selected. The nodes which
are directly connected to the node 3 are 2, 6, and 7. Since the nodes 2 and 6
have been selected so we will consider these two nodes.

Now, we consider the vertex 7. Consider the vertex 3 as 'x' and 7 as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (19 + 9) < 21

= 28 < 21

Since 28 is not less than 21, so we will not update d(7) from 28 to 21.

Let's consider the directed graph.

Here, we consider A as a source vertex. A vertex is a source vertex so entry


is filled with 0 while other vertices filled with ∞. The distance from source
vertex to source vertex is 0, and the distance from the source vertex to other
vertices is ∞.

We will solve this problem using the below table:

A B C D E

∞ ∞ ∞ ∞ ∞

Since 0 is the minimum value in the above table, so we select vertex A and
added in the second row shown as below:

A B C D E

A 0 ∞ ∞ ∞ ∞

As we can observe in the above graph that there are two vertices directly
connected to the vertex A, i.e., B and C. The vertex A is not directly
connected to the vertex E, i.e., the edge is from E to A. Here we can calculate
the two distances, i.e., from A to B and A to C. The same formula will be
used as in the previous problem.
If(d(x) + c(x, y) < d(y))

Then we update d(y) = d(x) + c(x, y)

A B C D E

A 0 ∞ ∞ ∞ ∞

10 5 ∞ ∞

As we can observe in the third row that 5 is the lowest value so vertex C will
be added in the third row.

We have calculated the distance of vertices B and C from A. Now we will


compare the vertices to find the vertex with the lowest value. Since the
vertex C has the minimum value, i.e., 5 so vertex C will be selected.

Since the vertex C is selected, so we consider all the direct paths from the
vertex C. The direct paths from the vertex C are C to B, C to D, and C to E.

First, we consider the vertex B. We calculate the distance from C to B.


Consider vertex C as 'x' and vertex B as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (5 + 3) < ∞

=8<∞

Since 8 is less than the infinity so we update d(B) from ∞ to 8. Now the new
row will be inserted in which value 8 will be added under the B column.

A B C D E

A 0 ∞ ∞ ∞ ∞

10 5 ∞ ∞

We consider the vertex D. We calculate the distance from C to D. Consider


vertex C as 'x' and vertex D as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (5 + 9) < ∞

= 14 < ∞
Since 14 is less than the infinity so we update d(D) from ∞ to 14. The value
14 will be added under the D column.

A B C D E

A 0 ∞ ∞ ∞ ∞

C 10 5 ∞ ∞

8 14

We consider the vertex E. We calculate the distance from C to E. Consider


vertex C as 'x' and vertex E as 'y'.

d(x, y) = d(x) + c(x, y) < d(y)

= (5 + 2) < ∞

=7<∞

Since 14 is less than the infinity so we update d(D) from ∞ to 14. The value
14 will be added under the D column.

A B C D E

A 0 ∞ ∞ ∞ ∞

C 10 5 ∞ ∞

8 14 7

As we can observe in the above table that 7 is the minimum value among 8,
14, and 7. Therefore, the vertex E is added on the left as shown in the below
table:

A B C D E

A 0 ∞ ∞ ∞ ∞

C 10 5 ∞ ∞

E 8 14 7

The vertex E is selected so we consider all the direct paths from the vertex E.
The direct paths from the vertex E are E to A and E to D. Since the vertex A
is selected, so we will not consider the path from E to A.
Consider the path from E to D.

d(x, y) = d(x) + c(x, y) < d(y)

= (7 + 6) < 14

= 13 < 14

Since 13 is less than the infinity so we update d(D) from ∞ to 13. The value
13 will be added under the D column.

A B C D E

A 0 ∞ ∞ ∞ ∞

C 10 5 ∞ ∞

E 8 14 7

B 8 13

The value 8 is minimum among 8 and 13. Therefore, vertex B is selected.


The direct path from B is B to D.
d(x, y) = d(x) + c(x, y) < d(y)
= (8 + 1) < 13
= 9 < 13
Since 9 is less than 13 so we update d(D) from 13 to 9. The value 9 will be
added under the D column.

A B C D E

A 0 ∞ ∞ ∞ ∞

C 10 5 ∞ ∞

E 8 14 7

B 8 13

D 9
Hierarchical Routing

 In hierarchical routing, the routers are divided into regions. Each


router has complete details about how to route packets to destinations
within its own region. But it does not have any idea about the internal
structure of other regions.
 As we know, in both LS and DV algorithms, every router needs to save
some information about other routers. When network size is growing,
the number of routers in the network will increase. Therefore, the size
of routing table increases, then routers cannot handle network traffic
as efficiently. To overcome this problem we are using hierarchical
routing.
 In hierarchical routing, routers are classified in groups called regions.
 Each router has information about the routers in its own region and it
has no information about routers in other regions. So, routers save
one record in their table for every other region.
 For huge networks, a two-level hierarchy may be insufficient hence, it
may be necessary to group the regions into clusters, the clusters into
zones, the zones into groups and so on.

Hierarchical Table for 1A Full table of 1A


Dest Line Hops Dest Line Hops
1A -- -- Dest Line Hops
1A --- ----
1B 1B 1 5A 1C 4
1B 1B 1
1C 1C 1 5B 1C 5
1C 1C 1
2 1B 2 5C 1B 5
2A 1B 2
3 1C 2 5D 1C 6
2B 1B 3
4 1C 3 5E 1C 5
2C 1B 3
5 1C 4 2D 1B 4
3A 1C 3
3B 1C 2
4A 1C 3
4B 1C 4
4C 1C 4
Explanation

Step 1 − For example, the best path from 1A to 5C is via region 2, but
hierarchical routing of all traffic to region 5 goes via region 3 as it is better
for most of the other destinations of region 5.

Step 2 − Consider a subnet of 720 routers. If no hierarchy is used, each


router will have 720 entries in its routing table.

Step 3 − Now if the subnet is partitioned into 24 regions of 30 routers each,


then each router will require 30 local entries and 23 remote entries for a
total of 53 entries.

Congestion Control
Token Bucket
 Token bucket algorithm is one of the techniques for congestion control
algorithms. When too many packets are present in the network it
causes packet delay and loss of packet which degrades the
performance of the system. This situation is called congestion.
 The network layer and transport layer share the responsibility for
handling congestions.
 One of the most effective ways to control congestion is trying to reduce
the load that transport layer is placing on the network. To maintain
this network and transport layers have to work together.

Token Bucket Algorithm

The leaky bucket algorithm enforces output patterns at the average rate, no
matter how busy the traffic is. So, to deal with the more traffic, we need a
flexible algorithm so that the data is not lost. One such approach is the
token bucket algorithm.

Step 1 − In regular intervals tokens are thrown into the bucket


Step 2 − The bucket has a maximum capacity
Step 3 − If the packet is ready, then a token is removed from the bucket,
and the packet is sent.
Step 4 − suppose, if there is no token in the bucket, the packet cannot be
sent.
Internet Working

How networks can be connected different ways


1. Tunneling 2. Internet work routing 3.Fragmentation

Tunneling
 Tunneling is an internetworking strategy that is used when source
and destination networks of same type are connected through a
network of different type.
 In such a case, the packet from one network reaches the other
network via different kind of network that interconnects them.
 To understand tunneling, let an Ethernet is to be connected to
another Ethernet via a WAN.
 The IP packets are to be sent from host 1 of Ethernet 1 to host 2 of
Ethernet 2 via a WAN.
 To send an IP packet to host 2, host 1 constructs the packet
containing the IP address of host 2.
 It then inserts this packet into an Ethernet frame. This frame is
addressed to the multi-protocol router M1 and is placed on Ethernet.
 When this packet reaches, multiprotocol router MI, it removes the IP
packet and insert it in the payload field of the WAN network layer
packet.
 This WAN network layer packet is then addressed to multi-
protocol router M2.
 When this packet reaches M2, it removes the IP packet and inserts it
into the Ethernet frame and sends it to host 2.
 In the above process, IP packets do not have to deal with WAN, they
just travel from one end 0f the tunnel to the other end. The host 1
and host 2 on two Ethernet also do not have to deal with WAN.
 The multi-protocol routers M1 & M2 understand about IP and WAN
packets.
INTERNET WORKING

 Routing between two networks is called internetworking.


 Networks can be considered different based on various
parameters such as, Protocol, topology, Layer-2 network and
addressing scheme.
 In internetworking, routers have knowledge of each other’s
address and addresses beyond them. They can be statically
configured go on different network or they can learn by using
internetworking routing protocol.

 Routing protocols which are used within an organization or


administration are called Interior Gateway Protocols or IGP. RIP, OSPF
are examples of IGP. Routing between different organizations or
administrations may have Exterior Gateway Protocol, and there is only
one EGP i.e. Border Gateway Protocol.

FRAGMENTATION

Fragmentation is done by the network layer when the maximum size of


datagram is greater than maximum size of data that can be held in a frame
i.e., its Maximum Transmission Unit (MTU).
The network layer divides the datagram received from the transport layer
into fragments so that data flow is not disrupted.

Since there are 16 bits for total length in IP header so, the maximum size of
IP datagram = 216 – 1 = 65, 535 bytes.
It is done by the network layer at the destination side and is usually done at
routers.
Source side does not require fragmentation due to wise (good) segmentation
by transport layer i.e. instead of doing segmentation at the transport layer
and fragmentation at the network layer, the transport layer looks at
datagram data limit and frame data limit and does segmentation in such a
way that resulting data can easily fit in a frame without the need of
fragmentation.

Receiver identifies the frame with the identification (16 bits) field in the IP
header. Each fragment of a frame has the same identification number.

Receiver identifies the sequence of frames using the fragment offset (13
bits) field in the IP header

Overhead at the network layer is present due to the extra header introduced
due to fragmentation.

Fields in IP header for fragmentation

Identification (16 bits) – use to identify fragments of the same frame.

Fragment offset (13 bits) – use to identify the sequence of fragments in the
frame. It generally indicates a number of data bytes proceeding or ahead of
the fragment.
Maximum fragment offset possible = (65535 – 20) = 65515
So, we need ceil(log265515) = 16 bits for a fragment offset but the fragment
offset field has only 13 bits. So, to represent efficiently we need to scale
down the fragment offset field by 216/213 = 8 which acts as a scaling factor.
Hence, all fragments except the last fragment should have data in multiples
of 8 so that fragment offset ∈ N.

More fragments (MF = 1 bit) – tells if more fragments are ahead of this
fragment i.e. if MF = 1, more fragments are ahead of this fragment and if MF
= 0, it is the last fragment.

Don’t fragment (DF = 1 bit) – if we don’t want the packet to be fragmented


then DF is set i.e. DF = 1.

Reassembly of Fragments

It takes place only at the destination and not at routers since packets take
an independent path (datagram packet switching), so all may not meet at a
router and hence a need of fragmentation may arise again. The fragments
may arrive out of order also.
Algorithm

Destination should identify that datagram is fragmented from MF, Fragment


offset field.

Destination should identify all fragments belonging to same datagram from


Identification field.

Identify the 1st fragment(offset = 0).

Identify subsequent fragments using header length, fragment offset.

Repeat until MF = 0.

Efficiency –

Efficiency (e) = useful/total = (Data without header)/(Data with header)

Throughput = e * B {where B is bottleneck bandwidth}

IP PROTOCOLS

1. IPV4 2. IPV6

IPV4 Header Format

 IPv4 short for Internet Protocol Version 4 is the fourth version of


the Internet Protocol (IP).
 IP is responsible to deliver data packets from the source host to the
destination host.
 This delivery is solely based on the IP Addresses in the packet
headers.
 IPv4 is the first major version of IP.
 IPv4 is a connectionless protocol for use on packet-switched
networks.
1. Version-

 Version is a 4 bit field that indicates the IP version used.


 The most popularly used IP versions are version-4 (IPv4) and version-6
(IPv6).
 Only IPv4 uses the above header. So, this field always contains the
decimal value 4.

2. Header Length-

 Header length is a 4 bit field that contains the length of the IP header.
 It helps in knowing from where the actual data begins.
 The length of IP header always lies in the range-[20 bytes , 60 bytes]

3. Type Of Service-

 Type of service is a 8 bit field that is used for Quality of Service (QoS).
 The datagram is marked for giving a certain treatment using this
field.

4. Total Length-

 Total length is a 16 bit field that contains the total length of the
datagram (in bytes).

Total length = Header length + Payload length

 Minimum total length of datagram = 20 bytes (20 bytes header + 0


bytes data)
 Maximum total length of datagram = Maximum value of 16 bit word =
65535 bytes

5. Identification-

 Identification is a 16 bit field.


 It is used for the identification of the fragments of an original IP
datagram.
6. Flag Bits

a) DF Bit-

 DF bit stands for Do Not Fragment bit.


 Its value may be 0 or 1.

b)MF Bit-

 MF bit stands for More Fragments bit.


 Its value may be 0 or 1.

7. Fragment Offset-

 Fragment Offset is a 13 bit field.


 It indicates the position of a fragmented datagram in the original
unfragmented IP datagram.
 The first fragmented datagram has a fragment offset of zero.

8. Time to Live-

 Time to live (TTL) is a 8 bit field.


 It indicates the maximum number of hops a datagram can take to
reach the destination.
 The main purpose of TTL is to prevent the IP datagrams from looping
around forever in a routing loop.

9. Protocol-

 Protocol is a 8 bit field.


 It tells the network layer at the destination host to which protocol the
IP datagram belongs to.
 In other words, it tells the next level protocol to the network layer at
the destination side.
 Protocol number of ICMP is 1, IGMP is 2, TCP is 6 and UDP is 17.

10. Source IP Address-

 Source IP Address is a 32 bit field.


 It contains the logical address of the sender of the datagram.

11. Destination IP Address-

 Destination IP Address is a 32 bit field.


 It contains the logical address of the receiver of the datagram.

12. Padding or Data

 Addition of dummy data to fill up unused space in the transmission


unit and make it conform to the standard size is called as padding.
 Options field is used for padding.
IPV6 Header Format

Version (4-bits): Indicates version of Internet Protocol which contains bit


sequence 0110.

Traffic Class (8-bits): The Traffic Class field indicates class or priority of
IPv6 packet which is similar to Service Field in IPv4 packet. It helps routers
to handle the traffic based on the priority of the packet. If congestion occurs
on the router then packets with the least priority will be discarded.
As of now, only 4-bits are being used (and the remaining bits are under
research), in which 0 to 7 are assigned to Congestion controlled traffic and 8
to 15 are assigned to Uncontrolled traffic.

Flow Label (20-bits): Flow Label field is used by a source to label the
packets belonging to the same flow in order to request special handling by
intermediate IPv6 routers, such as non-default quality of service or real-time
service. In order to distinguish the flow, an intermediate router can use the
source address, a destination address, and flow label of the packets.
Between a source and destination, multiple flows may exist because many
processes might be running at the same time. Routers or Host that does not
support the functionality of flow label field and for default router handling,
flow label field is set to 0. While setting up the flow label, the source is also
supposed to specify the lifetime of the flow.

Payload Length (16-bits): It is a 16-bit (unsigned integer) field, indicates


the total size of the payload which tells routers about the amount of
information a particular packet contains in its payload. The payload Length
field includes extension headers (if any) and an upper-layer packet. In case
the length of the payload is greater than 65,535 bytes (payload up to 65,535
bytes can be indicated with 16-bits), then the payload length field will be set
to 0 and the jumbo payload option is used in the Hop-by-Hop options
extension header.
Next Header (8-bits): Next Header indicates the type of extension header (if
present) immediately following the IPv6 header. Whereas In some cases it
indicates the protocols contained within upper-layer packets, such as TCP,
UDP.

Hop Limit (8-bits): Hop Limit field is the same as TTL in IPv4 packets. It
indicates the maximum number of intermediate nodes IPv6 packet is
allowed to travel. Its value gets decremented by one, by each node that
forwards the packet and the packet is discarded if the value decrements to
0. This is used to discard the packets that are stuck in an infinite loop
because of some routing error.

Source Address (128-bits): Source Address is the 128-bit IPv6 address of


the original source of the packet.

Destination Address (128-bits): The destination Address field indicates the


IPv6 address of the final destination (in most cases). All the intermediate
nodes can use this information in order to correctly route the packet.

Extension Headers: In order to rectify the limitations of the IPv4 Option


Field, Extension Headers are introduced in IP version 6. The extension
header mechanism is a very important part of the IPv6 architecture. The
next Header field of IPv6 fixed header points to the first Extension Header
and this first extension header points to the second extension header and so
on.

Class full address

 IP Address is short for Internet Protocol Address.


 It is a unique address assigned to each computing device in an IP
network.
 ISP assigns IP Address to all the devices present on its network.
 Computing devices use IP Address to identify and communicate with
other devices in the IP network

Types of IP Address-

1. Static IP Address-

 Static IP Address is an IP Address that once assigned to a network


element always remains the same.
 They are configured manually.
2. Dynamic IP Address-

 Dynamic IP Address is a temporarily assigned IP Address to a


network element.
 It can be assigned to a different device if it is not in use.
 DHCP or PPPoE assigns dynamic IP addresses.

IP Address Format-

 IP Address is a 32 bit binary address written as 4 numbers separated


by dots.
 The 4 numbers are called as octets where each octet has 8 bits.
 The octets are divided into 2 components- Net ID and Host ID.

 Network ID represents the IP Address of the network and is used to


identify the network.
 Host ID represents the IP Address of the host and is used to identify
the host within the network

IP Addressing-

In Classful Addressing System, IP Addresses are organized into following 5 classes-

Class A

 In class A an IP address is assign to those networks that contain large


no. of networks.
 In class A the network id is 8 bits and host id is 24 bits
 In class A high order bit of the first octet is also set to ‘0’ and reaming
7 bits determine as network id.
Leading bit N/W ID Host ID
0 7 24

 The total no. of networks in class A is 27. and total no. of host is 224.
 In class the leading bit is Zero(0) and the range of class A is 0 to 127

So we are calculating the range of class A is

00000000.00000000.00000000.00000000

to

01111111.00000000.00000000.00000000

Class B

 In class B an IP address is assign to those networks that range


from contain small to large no. of networks.
 In class B the network id is 16 bits and host id is 16 bits
 In class B high order bit of the first octet is also set to 1,0 and
reaming 14bits determine as network id.
Leading bit

N/W ID Host ID
1 0 7 24

 The total no. of networks in class B is 214. and total no. of host is
216
 In class B the leading bits are 1,0 and the range of class B is 128
to 191

So we are calculating the range of class B is

00000000.00000000.00000000.00000000

to

10111111.00000000.00000000.00000000

Class C

 In class C an IP address is assign to those networks that range is


very small no. of networks.
 In class C the network id is 24 bits and host id is 8 bits
 In class C high order bit of the first octet is also set to 1,1,0 and
reaming 21bits determine as network id.
Leading bit

N/W ID Host ID
1 1 0 21 8
 The total no. of networks in class C is 221. and total no. of host is
28
 In class C the leading bits are 1, 1,0 and the range of class C is
192 to 223.

So we are calculating the range of class C is

00000000.00000000.00000000.00000000

to

11011111.00000000.00000000.00000000

Class D

 In class D an IP address are reserved for multicasting address


 In class D doesn’t possess sub netting
 In class D high order bit of the first octet is also set to 1,1,1,0 and
reaming 28bits determine as Host id.
Leading bit

Host ID
1 1 1 0 28

 In class D the leading bits are 1,1, 1,0 and the range of class D is
224 to 239

So we are calculating the range of class D is

00000000.00000000.00000000.00000000

to

11101111.00000000.00000000.00000000

Class E

 In class E the IP address are used for future use or research and
development purpose
 It doesn’t possess any sub netting
 In class E high order bit of the first octet is also set to 1,1,1,1 and
reaming 28bits determine as Host id.
Leading bit

Host ID
1 1 1 1 28

 In class E the leading bits are 1,1, 1,1 and the range of class E is
239 to 255
So we are calculating the range of class E is

00000000.00000000.00000000.00000000

to

11111111.00000000.00000000.00000000

CIDR-Classless Addressing
 Classless addressing is an include of IP address system
 It allocate the IP address more effectively
 It replace the old class full addressing system
 It is also known as classless inter domain routing (CIDR)

CIDR BLOCK

 In CIDR block IP address are assigned based on certain rules


 As per demand ,the user is assigned the IP address to CIDR block
 The block of IP address is also called CIDR block

< 32 bits>

Block ID Host ID

Rules for CIDR Block

 The CIDR block is based on following rules

R-1: All the IP address in CIDR block must be contiguous

R-2: The size of block must be presentable as a power of 2

R-3: First IP address of block must be divisible by the size of the block

CIDR Notation

a.b.c.d/n i.e.182.0.1.2/28

 The end of the slash followed by a number called as IP network


prefix (Network ID).
 The IP network prefix tells that no. of bits used for the
identification of network
 The reaming bits are used for identification of host id

Ex: 182.0.1.2/28 here Network ID is 28 bits and host ID is 32-28


=4 bits

Ex: The given CIDR representation is 20.10.30.35/27 find the range of IP


address in a CIDR block.

Sol: It suggest that the 27 bits are identify as network id and reaming 5 bits
are identify as host id.
It suggests-

27 bits are used for the identification of network.

Remaining 5 bits are used for the identification of hosts in the network.

Given CIDR IP Address may be represented as-

00010100.00001010.00011110.00100011 / 27

So,

First IP Address = 00010100.00001010.00011110.00100000 = 20.10.30.32

Last IP Address = 00010100.00001010.00011110.00111111 = 20.10.30.63

Thus, Range of IP Addresses = [ 20.10.30.32 , 20.10.30.63]

Network Address Translation (NAT)

 Network Address Translation (NAT) is a service that is used in


routers. Its purpose is to translate a set of IP addresses to another set
of IP addresses.

Network Address Translation (NAT) working –

Generally, the border router is configured for NAT i.e the router which have
one interface in local (inside) network and one interface in global (outside)
network. When a packet traverse outside the local (inside) network, then
NAT converts that local (private) IP address to a global (public) IP address.
When a packet enters the local network, the global (public) IP address is
converted to local (private) IP address.

If NAT run out of addresses, i.e., no address is left in the pool configured
then the packets will be dropped and an Internet Control Message Protocol
(ICMP) host unreachable packet to the destination is send.

NAT inside and outside addresses

Inside refers to the addresses which must be translated. Outside refers to


the addresses which are not in control of an organisation. These are the
network Addresses in which the translation of the addresses will be done.
Inside local address – An IP address that is assigned to a host on the Inside
(local) network. The address is probably not a IP address assigned by the
service provider i.e., these are private IP address. This is the inside host
seen from the inside network.

Inside global address – IP address that represents one or more inside local
IP addresses to the outside world. This is the inside host as seen from the
outside network.

Outside local address – This is the actual IP address of the destination host
in the local network after translation.

Outside global address – This is the outside host as seen form the outside
network. It is the IP address of the outside destination host before
translation.

Network Address Translation (NAT) Types –


There are 3 ways to configure NAT:

Static NAT –In this, a single unregistered (Private) IP address is mapped


with a legally registered (Public) IP address i.e one-to-one mapping between
local and global address. This is generally used for Web hosting. These are
not used in organizations as there are many devices who will need Internet
access and to provide Internet access, public IP address is needed.

Dynamic NAT – In this type of NAT, an unregistered IP address is translated


into a registered (Public) IP address from a pool of public IP address. If the IP
addresses of pool are not free, then the packet will be dropped as only fixed
number of private IP address can be translated to public addresses.

Suppose, if there is pool of 2 public IP addresses then only 2 private IP


addresses can be translated at a given time. If 3rd private IP address wants
to access Internet then the packet will be dropped therefore many private IP
addresses are mapped to a pool of public IP addresses. NAT is used when
the number of users who wants to access the Internet are fixed. This is also
very costly as the organizations have to buy many global IP addresses to
make a pool.
Port Address Translation (PAT) – This is also known as NAT overload. In
this, many local (private) IP addresses can be translated to single registered
IP address .Port numbers are used to distinguish the traffic i.e., which traffic
belongs to which IP address. This is most frequently used as it is cost
effective as thousands of users can be connected to the Internet by using
only one real global (public) IP address.

Advantages of NAT –

 NAT conserves legally registered IP addresses .


 It provides privacy as the device IP address, sending and receiving the
traffic, will be hidden.
 Eliminates address renumbering when a network evolves.
Disadvantage of NAT –

 Translation results in switching path delays.


 Certain applications will not function while NAT is enabled.
 Complicates tunneling protocols such as IPSec.
 Also, router being a network layer device, should not tamper with port
numbers (transport layer) but it has to do so because of NAT.

Subnet
 It is a logical sub division of an IP address in networks

Class A Network ID Host ID Host ID Host ID


Class B Network ID Network ID Host ID Host ID
Class C Network ID Network ID Network ID Host ID
Class D Network ID Network ID Network ID Network ID

Sub netting

 It is a practice of dividing large network in to small networks.

Ex:

Subnet Mask

 It is a 32 bit address used to distinguish between network address


and Host address.

Ex:
Subnet Binary Format
255 11111111
254 11111110
252 11111100
240 11110000

Default Subnet Mask: It is a no. of bits which is reserved by the address


class. The default subnet mask will accommodate single network.
Super Netting: It is opposite to sub netting; here single networks are
combined as a large network.

Transition from IPv4 to IPv6

Complete transition from IPv4 to IPv6 might not be possible because IPv6 is
not backward compatible. This results in a situation where either a site is
on IPv6 or it is not. It is unlike implementation of other new technologies
where the newer one is backward compatible so the older system can still
work with the newer version without any additional changes.

To overcome this short-coming, we have a few technologies that can be used


to ensure slow and smooth transition from IPv4 to IPv6.

Dual Stack Routers

A router can be installed with both IPv4 and IPv6 addresses configured on
its interfaces pointing to the network of relevant IP scheme

In the above diagram, a server having IPv4 as well as IPv6 address


configured for it can now speak with all the hosts on both the IPv4 as well as
the IPv6 networks with the help of a Dual Stack Router. The Dual Stack
Router can communicate with both the networks. It provides a medium for
the hosts to access a server without changing their respective IP versions.

Tunneling

In a scenario where different IP versions exist on intermediate path or


transit networks, tunneling provides a better solution where user’s data can
pass through a non-supported IP version.

The above diagram depicts how two remote IPv4 networks can communicate
via a Tunnel, where the transit network was on IPv6. Vice versa is also
possible where the transit network is on IPv6 and the remote sites that
intend to communicate are on IPv4.
NAT Protocol Translation

This is another important method of transition to IPv6 by means of a NAT-


PT (Network Address Translation – Protocol Translation) enabled device.
With the help of a NAT-PT device, actual can take place happens between
IPv4 and IPv6 packets and vice versa. See the diagram below:

A host with IPv4 address sends a request to an IPv6 enabled server on


Internet that does not understand IPv4 address. In this scenario, the NAT-
PT device can help them communicate. When the IPv4 host sends a request
packet to the IPv6 server, the NAT-PT device/router strips down the IPv4
packet, removes IPv4 header, and adds IPv6 header and passes it through
the Internet. When a response from the IPv6 server comes for the IPv4 host,
the router does vice versa.

Compare IPV4 and IPV6

IPv4 is a 32-bit address. IPv6 is a 128-bit address


IPv4 is a numeric address that IPv6 is an alphanumeric address
consists of 4 fields which are that consists of 8 fields, which are
separated by dot (.). separated by colon
IPv4 has 5 different classes of IP
IPv6 does not contain classes of IP
address that includes Class A, Class
addresses.
B, Class C, Class D, and Class E.
IPv4 has a limited number of IP IPv6 does not contain classes of IP
addresses addresses

It supports VLSM (Virtual Length


It does not support VLSM.
Subnet Mask).
In IPv4, the IP address is represented In IPv6, the representation of the IP
in decimal address in hexadecimal.

It generates 340 undecillion unique


It generates 4 billion unique addresses
addresses.
Fragmentation is done by the senders Fragmentation is done by the
and the forwarding routers senders only.

It consists of 4 octets. It consists of 8 fields, and each field


contains 2 octets. Therefore, the total
number of octets in IPv6 is 1
Internet Protocols

1. ICMP 2.ARP 3.DHCP

ICMP

 ICMP stands for Internet Control Message Protocol.


 The ICMP is a network layer protocol used by hosts and routers to
send the notifications of IP datagram problems back to the sender.
 ICMP uses echo test/reply to check whether the destination is
reachable and responding.
 ICMP handles both control and error messages, but its main function
is to report the error but not to correct them.
 An IP datagram contains the addresses of both source and
destination, but it does not know the address of the previous router
through which it has been passed. Due to this reason, ICMP can only
send the messages to the source, but not to the immediate routers.
 ICMP protocol communicates the error messages to the sender. ICMP
messages cause the errors to be returned back to the user processes.
 ICMP messages are transmitted within IP datagram.

The Format of an ICMP message

 The first field specifies the type of the message.


 The second field specifies the reason for a particular message type.
 The checksum field covers the entire ICMP message.

Error Reporting

ICMP protocol reports the error messages to the sender.


Five types of errors are handled by the ICMP protocol:

 Destination unreachable
 Source Quench
 Time Exceeded
 Parameter problems
 Redirection
ARP: Address resolution protocol

 ARP stands for Address Resolution Protocol


 This is used to find the MAC address of the device from its
known IP address.
 This means, the source device already knows the IP address but
not the MAC address of the destination device.
 The MAC address of the device is required because you cannot
communicate with a device in a local area network (Ethernet)
without knowing its MAC address. So, the Address Resolution
Protocol helps to obtain the MAC address of the destination
device.

 The purpose of ARP is to convert the 32-bit logical address (IPv4


address) to the 48-bit physical address (MAC address).
 This protocol works between layer 2 and layer 3 of the OSI model.
 The MAC address resides at layer 2, which is also known as the data
link layer and IP address resides at layer 3, this layer is also known as
the network layer.

Example: Suppose two devices (device A and device B) want to communicate


with each other. The device A already knows the IP address of the Device B.
But in order to communicate with the device B, device A still needs the MAC
address of the device B. The IP address is used to locate a device on a local
area network and the MAC address is used to identify the actual device. The
device A first look at its internal list known as ARP cache (table) to check if
the IP address of the device B already consists of its MAC address or not. If
the ARP table consists of the MAC address of the device B, then device A
simply use that MAC address and start communication.

If the table does not consist of the MAC address of device B, then device A
sends an ARP broadcast message on the network to know which device has
that specific IP address and ask for the MAC address of that particular
device. Then the device that has matching IP address to the source address
sends an ARP response message that consists of the MAC address of the
device B. When device A obtains the MAC address of the device B, it will
store the information in the ARP cache (table). The ARP cache is used to
make the network more efficient. It stores the IP address of the device along
with its MAC address. The stored information is used when device A wants
to communicate with device B on a network, and it does not need to
broadcast a message on the network again. It will simply check the ARP
cache for the entries and then use it for communication.
DHCP: Dynamic Host Controller Protocol

 Dynamic Host Configuration Protocol (DHCP) is a network


management protocol used to dynamically assign an IP address to nay
device, or node, on a network so they can communicate using IP
(Internet Protocol).
 DHCP automates and centrally manages these configurations. There
is no need to manually assign IP addresses to new devices. Therefore,
there is no requirement for any user configuration to connect to a
DHCP based network.
 DHCP can be implemented on local networks as well as large
enterprise networks. DHCP is the default protocol used by the most
routers and networking equipment. DHCP is also called RFC (Request
for comments) 2131.
 DHCP manages the provision of all the nodes or devices added or
dropped from the network.
 DHCP maintains the unique IP address of the host using a DHCP
server.
 It sends a request to the DHCP server whenever a client/node/device,
which is configured to work with DHCP, connects to a network. The
server acknowledges by providing an IP address to the
client/node/device.
 DHCP is also used to configure the proper subnet mask, default
gateway and DNS server information on the node or device.
 There are many versions of DCHP are available for use in IPV4
(Internet Protocol Version 4) and IPV6 (Internet Protocol Version 6).
 DHCP runs at the application layer of the TCP/IP protocol stack to
dynamically assign IP addresses to DHCP clients/nodes and to
allocate TCP/IP configuration information to the DHCP clients.
Information includes subnet mask information, default gateway, IP
addresses and domain name system addresses.
 DHCP is based on client-server protocol in which servers manage a
pool of unique IP addresses, as well as information about client
configuration parameters, and assign addresses out of those address
pools.
 First of all, a client (network device) must be connected to the
internet.
 DHCP server responds to the client request by providing IP server
address and other configuration information. This configuration
information also includes time period, called a lease, for which the
allocation is valid.

Components of DHCP

When working with DHCP, it is important to understand all of the


components. Following are the list of components:

DHCP Server: DHCP server is a networked device running the DCHP service
that holds IP addresses and related configuration information. This is
typically a server or a router but could be anything that acts as a host, such
as an SD-WAN appliance.

DHCP client: DHCP client is the endpoint that receives configuration


information from a DHCP server. This can be any device like computer,
laptop, IoT endpoint or anything else that requires connectivity to the
network. Most of the devices are configured to receive DHCP information by
default.

IP address pool: IP address pool is the range of addresses that are available
to DHCP clients. IP addresses are typically handed out sequentially from
lowest to the highest.

Subnet: Subnet is the partitioned segments of the IP networks. Subnet is


used to keep networks manageable.

Lease: Lease is the length of time for which a DHCP client holds the IP
address information. When a lease expires, the client has to renew it.

DHCP relay: A host or router that listens for client messages being
broadcast on that network and then forwards them to a configured server.
The server then sends responses back to the relay agent that passes them
along to the client. DHCP relay can be used to centralize DHCP servers
instead of having a server on each subnet.

Benefits of DHCP

There are following benefits of DHCP:

 Centralized administration of IP configuration: DHCP IP


configuration information can be stored in a single location and
enables that administrator to centrally manage all IP address
configuration information.
 Dynamic host configuration: DHCP automates the host
configuration process and eliminates the need to manually configure
individual host. When TCP/IP (Transmission control protocol/Internet
protocol) is first deployed or when IP infrastructure changes are
required.
 Seamless IP host configuration: The use of DHCP ensures that
DHCP clients get accurate and timely IP configuration IP configuration
parameter such as IP address, subnet mask, default gateway, IP
address of DND server and so on without user intervention.
 Flexibility and scalability: Using DHCP gives the administrator
increased flexibility, allowing the administrator to move easily change
IP configuration when the infrastructure changes.

You might also like