Network layer
Network layer
Network Layer
Network layer is the third layer in the OSI model of computer networks. It’s main function is
to transfer network packets from the source to the destination. It is involved both at the source
host and the destination host. At the source, it accepts a packet from the transport layer,
encapsulates it in a datagram and then deliver the packet to the data link layer so that it can
further be sent to the receiver. At the destination, the datagram is decapsulated, the packet is
extracted and delivered to the corresponding transport layer.
Features :
1. Main responsibility of Network layer is to carry the data packets from the source to the
destination without changing or using it.
2. If the packets are too large for delivery, they are fragmented i.e., broken down into smaller
packets.
3. It decides the root to be taken by the packets to travel from the source to the destination
among the multiple roots available in a network (also called as routing).
4. The source and destination addresses are added to the data packets inside the network
layer.
The services which are offered by the network layer protocol are as follows:
1. Packetizing –
The process of encapsulating the data received from upper layers of the network(also called
as payload) in a network layer packet at the source and decapsulating the payload from the
network layer packet at the destination is known as packetizing.
1
The source host adds a header that contains the source and destination address and some
other relevant information required by the network layer protocol to the payload received
from the upper layer protocol, and delivers the packet to the data link layer.
The destination host receives the network layer packet from its data link layer, decapsulates
the packet, and delivers the payload to the corresponding upper layer protocol. The routers
in the path are not allowed to change either the source or the destination address. The
routers in the path are not allowed to decapsulate the packets they receive unless they need
to be fragmented.
[Link] Control –
Although it can be implemented in the network layer, but it is usually not preferred because
the data packet in a network layer maybe fragmented at each router, which makes error
checking inefficient in the network layer.
[Link] Control –
It regulates the amount of data a source can send without overloading the receiver. If the
source produces a data at a very faster rate than the receiver can consume it, the receiver
will be overloaded with data. To control the flow of data, the receiver should send a
feedback to the sender to inform the latter that it is overloaded with data. There is a lack of
flow control in the design of the network layer. It does not directly provide any flow
control. The datagrams are sent by the sender when they are ready, without any attention to
the readiness of the receiver.
[Link] Control –
Congestion occurs when the number of datagrams sent by source is beyond the capacity of
network or routers. This is another issue in the network layer protocol. If congestion
continues, sometimes a situation may arrive where the system collapses and no datagrams
are delivered. Although congestion control is indirectly implemented in network layer, but
still there is a lack of congestion control in the network layer.
2
Routing
o A Router is a process of selecting path along which the data can be transferred from
source to the destination. Routing is performed by a special device known as a router.
o A Router works at the network layer in the OSI model and internet layer in TCP/IP model
o A router is a networking device that forwards the packet based on the information
available in the packet header and forwarding table.
o The routing algorithms are used for routing the packets. The routing algorithm is nothing
but a software responsible for deciding the optimal path through which packet can be
transmitted.
o The routing protocols use the metric to determine the best path for the packet delivery.
The metric is the standard of measurement such as hop count, bandwidth, delay, current
load on the path, etc. used by the routing algorithm to determine the optimal path to the
destination.
o The routing algorithm initializes and maintains the routing table for the process of path
determination.
Routing metrics and costs are used for determining the best route to the destination. The factors
used by the protocols to determine the shortest path, these factors are known as a [Link]
are the network variables used to determine the best route to the destination. For some protocols
use the static metrics means that their value cannot be changed and for some other routing
protocols use the dynamic metrics means that their value can be assigned by the system
administrator.
o Hop count: Hop count is defined as a metric that specifies the number of passes through
internetworking devices such as a router, a packet must travel in a route to move from
source to the destination. If the routing protocol considers the hop as a primary metric
value, then the path with the least hop count will be considered as the best path to move
from source to the destination.
o Delay: It is a time taken by the router to process, queue and transmit a datagram to an
interface. The protocols use this metric to determine the delay values for all the links
along the path end-to-end. The path having the lowest delay value will be considered as
the best path.
3
o Bandwidth: The capacity of the link is known as a bandwidth of the link. The bandwidth
is measured in terms of bits per second. The link that has a higher transfer rate like
gigabit is preferred over the link that has the lower capacity like 56 kb. The protocol will
determine the bandwidth capacity for all the links along the path, and the overall higher
bandwidth will be considered as the best route.
o Load: Load refers to the degree to which the network resource such as a router or
network link is busy. A Load can be calculated in a variety of ways such as CPU
utilization, packets processed per second. If the traffic increases, then the load value will
also be increased. The load value changes with respect to the change in the traffic.
o Reliability: Reliability is a metric factor may be composed of a fixed value. It depends
on the network links, and its value is measured dynamically. Some networks go down
more often than others. After network failure, some network links repaired more easily
than other network links. Any reliability factor can be considered for the assignment of
reliability ratings, which are generally numeric values assigned by the system
administrator.
Types of Routing
o Static Routing
o Default Routing
o Dynamic Routing
Static Routing
o Static Routing is also known as Nonadaptive Routing.
o It is a technique in which the administrator manually adds the routes in a routing table.
4
o A Router can send the packets for the destination along the route defined by the
administrator.
o In this technique, routing decisions are not made based on the condition or topology of
the networks
o No Overhead: It has ho overhead on the CPU usage of the router. Therefore, the cheaper
router can be used to obtain static routing.
o Bandwidth: It has not bandwidth usage between the routers.
o Security: It provides security as the system administrator is allowed only to have control
over the routing to a particular network.
o For a large network, it becomes a very difficult task to add each route manually to the
routing table.
o The system administrator should have a good knowledge of a topology as he has to add
each route manually.
Default Routing
o Default Routing is a technique in which a router is configured to send all the packets to
the same hop device, and it doesn't matter whether it belongs to a particular network or
not. A Packet is transmitted to the device for which it is configured in default routing.
o Default Routing is used when networks deal with the single exit point.
o It is also useful when the bulk of transmission networks have to transmit the data to the
same hp device.
o When a specific route is mentioned in the routing table, the router will choose the specific
route rather than the default route. The default route is chosen only when a specific route
is not mentioned in the routing table.
5
Dynamic Routing
o It is also known as Adaptive Routing.
o It is a technique in which a router adds a new route in the routing table for each packet in
response to the changes in the condition or topology of the network.
o Dynamic protocols are used to discover the new routes to reach the destination.
o In Dynamic Routing, RIP and OSPF are the protocols used to discover the new routes.
o If any route goes down, then the automatic adjustment will be made to reach the
destination.
o All the routers must have the same dynamic routing protocol in order to exchange the
routes.
o If the router discovers any change in the condition or topology, then router broadcast this
information to all other routers.
6
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.
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 −
7
Dijkstra’s algorithm, published in 1959 and named after its creator Dutch computer scientist
Edsger Dijkstra, can be applied on a weighted graph. The graph can either be directed or
undirected.
Suppose a student wants to go from home to school in the shortest possible way. She knows
some roads are heavily congested and difficult to use. In Dijkstra's algorithm, this means the
edge has a large weight--the shortest path tree found by the algorithm will try to avoid edges
with larger weights. If the student looks up directions using a map service, it is likely they may
use Dijkstra's algorithm, as well as others.
Find the shortest path from home to school in the following graph:
Home→B→D→F→School
Dijktstra's Algorithm:
At the end each node will be labeled with its distance from source node along the best known
path. Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm
proceeds and paths are found, the labels may change reflecting better paths. Initially, all labels
are tentative. When it is discovered that a label represents the shortest possible path from the
source to that node, it is made permanent and never changed thereafter.
Look at the weighted undirected graph of Figure.1(a), where the weights represent, for example,
distance. We want to find shortest path from A to D. We start by making node A as permanent,
indicated by a filled in circle. Then we examine each of the nodes adjacent to A (the working
node), relabeling each one with the distance to A. Whenever a node is relabeled, we also label it
8
with the node from which the probe was made so that we can construct the final path later.
Having examined each of the nodes adjacent to A, we examine all the tentatively labeled nodes
in the whole graph and make the one with the smallest label permanent, as shown
in Figure.1(b). This one becomes new working node.
We now start at B, and examine all nodes adjacent to it. If the sum of the label on B and the
distance from B to the node being considered is less than the label on the node, we have a shorter
path, so the node is relabeled. After all the nodes adjacent to the working node have been
inspected and the tentative labels changed if possible, the entire graph is searched for the
tentatively labeled node with the smallest value. This node is made permanent and becomes the
working node for the next round. The Figure. 1 shows the first five steps of the algorithm.
Note: Dijkstra's Algorithm is applicable only when cost of all the nodes is non-negative.
9
Flooding
Flooding is the static routing algorithm. In this algorithm, every incoming packet is sent on all
outgoing lines except the line on which it has [Link] major problem of this algorithm is
that it generates a large number of duplicate packets on the network.
Several measures are takes to stop the duplication of packets. These are:
1. One solution is to include a hop counter in the header of each packet. This counter is decremented at
each hop along the path. When this counter reaches zero the packet is discarded. Ideally, the hop
counter should become zero at the destination hop, indicating that there are no more intermediate
hops and destination is reached. This requires the knowledge of exact number of hops from a source to
destination.
2. Another technique is to keep the track of the packed that have been flooded, to avoid sending
them a second time. For this, 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.
3. Another solution is to use selective flooding. In selective flooding the routers do not send
every incoming packet out on every output line. Instead packet is sent only on those lines which
are approximately going in the right direction.
Hierarchical Routing
When the network size grows, the number of routers in the network increases. Consequently, the
size of routing tables increases, as well, and routers can't handle network traffic as efficiently.
We use hierarchical routing to overcome this problem.
Let's examine this subject with an example-We use Distance Vector algorithms to find best
routes between nodes. In the situation depicted below, every node of the network has to save a
routing table with 17 records. Here is a typical graph and routing table for A:
10
In hierarchical routing, routers are classified in groups known as regions. Each router has only
the information about the routers in its own region and has no information about routers in other
regions. So routers just save one record in their table for every other region. In this example, we
have classified our network into five regions (see below).
If A wants to send packets to any router in region 2 (D, E, F or G), it sends them to B, and so on.
As you can see, in this type of routing, the tables can be summarized, so network efficiency
improves. The above example shows two-level hierarchical routing. We can also use three- or
four-level hierarchical routing.
In three-level hierarchical routing, the network is classified into a number of clusters. Each
cluster is made up of a number of regions, and each region contains a number or routers.
Hierarchical routing is widely used in Internet routing and makes use of several routing
protocols.
Unicast routing
Most of the traffic on the internet and intranets known as unicast data or unicast traffic is sent
with specified destination. Routing unicast data over the internet is called unicast routing. It is
the simplest form of routing because the destination is already known. Hence the router just has
to look up the routing table and forward the packet to next hop.
11
Broadcast routing
By default, the broadcast packets are not routed and forwarded by the routers on any network.
Routers create broadcast domains. But it can be configured to forward broadcasts in some
special cases. A broadcast message is destined to all network devices.
Broadcast routing can be done in two ways (algorithm):
A router creates a data packet and then sends it to each host one by one. In this case, the
router creates multiple copies of single data packet with different destination addresses.
All packets are sent as unicast but because they are sent to all, it simulates as if router is
broadcasting.
This method consumes lots of bandwidth and router must destination address of each
node.
Secondly, when router receives a packet that is to be broadcasted, it simply floods those
packets out of all interfaces. All routers are configured in the same way.
This method is easy on router's CPU but may cause the problem of duplicate packets
received from peer routers.
Reverse path forwarding is a technique, in which router knows in advance about its
predecessor from where it should receive broadcast. This technique is used to detect and
discard duplicates.
Multicast Routing
Multicast routing is special case of broadcast routing with significance difference and
challenges. In broadcast routing, packets are sent to all nodes even if they do not want it. But in
Multicast routing, the data is sent to only nodes which wants to receive the packets.
12
The router must know that there are nodes, which wish to receive multicast packets (or stream)
then only it should forward. Multicast routing works spanning tree protocol to avoid looping.
Multicast routing also uses reverse path Forwarding technique, to detect and discard duplicates
and loops.
Step-1:Each router prepares its routing table. By their local knowledge. each router knows
about-
i)All the routers present in the network
Step-2:
Each router exchanges its distance vector with its neighboring routers.
Each router prepares a new routing table using the distance vectors it has obtained from its
neighbors.
This step is repeated for (n-2) times if there are n routers in the network.
13
Example-
Consider-
Step-01:
Each router prepares its routing table using its local knowledge.
At Router A-
A 0 A
B 2 B
C ∞ –
D 1 D
At Router B-
Destinatio
Distance Next Hop
n
A 2 A
B 0 B
C 3 C
14
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 [Link] exchanging the
distance vectors, each router prepares a new routing table.
At Router A-
15
Cost of reaching destination B from router A = min { 2+0 , 1+7 } = 2 via B.
Router A can reach the destination router B via its neighbor B or neighbor D.
It chooses the path which gives the minimum cost.
Cost of reaching router B from router A via neighbor B = Cost (A→B) + Cost (B→B)= 2 + 0 = 2
Cost of reaching router B from router A via neighbor D = Cost (A→D) + Cost (D→B) = 1 + 7 = 8
Since the cost is minimum via neighbor B, so router A chooses the path via B.
It creates an entry (2, B) for destination B in its new routing table.
Similarly, we calculate the shortest path distance to each destination router at every router.
Distanc
Destination Next Hop
e
A 0 A
B 2 B
C 5 B
D 1 D
At Router B-
16
Cost of reaching destination A from router B = min { 2+0 , 3+∞ , 7+1 } = 2 via A.
Cost of reaching destination C from router B = min { 2+∞ , 3+0 , 7+11 } = 3 via C.
Cost of reaching destination D from router B = min { 2+1 , 3+11 , 7+0 } = 3 via A.
Destinatio
Distance Next Hop
n
A 2 A
B 0 B
C 3 C
D 3 A
At Router C-
17
Cost of reaching destination D from router C = min { 3+7 , 11+0 } = 10 via B.
Destinatio
Distance Next Hop
n
A 5 B
B 3 B
C 0 C
D 10 B
At Router D-
Cost of reaching destination A from router D = min { 1+0 , 7+2 , 11+∞ } = 1 via A.
Cost of reaching destination B from router D = min { 1+2 , 7+0 , 11+3 } = 3 via A.
Cost of reaching destination C from router D = min { 1+∞ , 7+3 , 11+0 } = 10 via B.
Destinatio
Distance Next Hop
n
18
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 [Link]
exchanging the distance vectors, each router prepares a new routing table.
At Router A-
Destinatio
Distance Next Hop
n
A 0 A
19
B 2 B
C 5 B
D 1 D
At Router B-
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.
Destinatio
Distance Next Hop
n
A 2 A
B 0 B
C 3 C
20
D 3 A
At Router C-
Destinatio
Distance Next Hop
n
A 5 B
B 3 B
C 0 C
D 6 B
At Router D-
21
Router D prepares a new routing table as-
Cost of reaching destination A from router D = min { 1+0 , 3+2 , 10+5 } = 1 via A.
Cost of reaching destination B from router D = min { 1+2 , 3+0 , 10+3 } = 3 via A.
Cost of reaching destination C from router D = min { 1+5 , 3+3 , 10+0 } = 6 via A.
Destinatio
Distance Next Hop
n
A 1 A
B 3 A
C 6 A
D 0 D
We have-
The value of next hop in the final routing table of router A suggests that only edges AB and AD are used.
The value of next hop in the final routing table of router B suggests that only edges BA and BC are used.
22
The value of next hop in the final routing table of router C suggests that only edge CB is used.
The value of next hop in the final routing table of router D suggests that only edge DA is used.
Now imagine that the link between A and B is cut. At this time, B corrects its table. After a
specific amount of time, routers exchange their tables, and so B receives C's routing table. Since
C doesn't know what has happened to the link between A and B, it says that it has a link to A
with the weight of 2 (1 for C to B, and 1 for B to A -- it doesn't know B has no link to A). B
receives this table and thinks there is a separate link between C and A, so it corrects its table and
changes infinity to 3 (1 for B to C, and 2 for C to A, as C said). Once again, routers exchange
their tables. When C receives B's routing table, it sees that B has changed the weight of its link to
A from 1 to 3, so C updates its table and changes the weight of the link to A to 4 (1 for C to B,
and 3 for B to A, as B said).
This process loops until all nodes find out that the weight of link to A is infinity. This situation is
shown in the table below. In this way, experts say DV algorithms have a slow convergence rate.
In other words when too much traffic is offered, congestion sets in and performance degrades
sharply
Causing of Congestion:
• The routers are too slow to perform bookkeeping tasks (queuing buffers, updating tables, etc.).
• The routers’ buffer is too limited.
• Congestion in a subnet can occur if the processors are slow. Slow speed CPU at routers will
perform the routine tasks such as queuing buffers, updating table etc slowly. As a result of this,
queues are built up even though there is excess line capacity.
• Congestion is also caused by slow links. This problem will be solved when high speed links are
used. But it is not always the case. Sometimes increase in link bandwidth can further deteriorate
the congestion problem as higher speed links may make the network more
[Link] can make itself worse. If a route!” does not have free buffers, it start
24
ignoring/discarding the newly arriving packets. When these packets are discarded, the sender
may retransmit them after the timer goes off. Such packets are transmitted by the sender again
and again until the source gets the acknowledgement of these packets. Therefore multiple
transmissions of packets will force the congestion to take place at the sending end.
• In this method, policies are used to prevent the congestion before it happens.
• Congestion control is handled either by the source or by the destination.
• The various methods used for open loop congestion control are:
Retransmission Policy
• The sender retransmits a packet, if it feels that the packet it has sent is lost or corrupted.
• However retransmission in general may increase the congestion in the network. But we need
to implement good retransmission policy to prevent congestion.
• The retransmission policy and the retransmission timers need to be designed to optimize
efficiency and at the same time prevent the congestion.
Window Policy
• To implement window policy, selective reject window method is used for congestion control.
25
• Selective Reject method is preferred over Go-back-n window as in Go-back-n method, when
timer for a packet times out, several packets are resent, although some may have arrived safely
at the receiver. Thus, this duplication may make congestion worse.
• Selective reject method sends only the specific lost or damaged packets
Acknowledgement Policy
• The acknowledgement policy imposed by the receiver may also affect congestion.
• If the receiver does not acknowledge every packet it receives it may slow down the sender and
help prevent congestion.
• Acknowledgments also add to the traffic load on the network. Thus, by sending fewer
acknowledgements we can reduce load on the network.
• To implement it, several approaches can be used:
1. A receiver may send an acknowledgement only if it has a packet to be sent.
2. A receiver may send an acknowledgement when a timer expires.
3. A receiver may also decide to acknowledge only N packets at a time.
Discarding Policy
• A router may discard less sensitive packets when congestion is likely to happen.
• Such a discarding policy may prevent congestion and at the same time may not harm the
integrity of the transmission.
Admission Policy
• Closed loop congestion control mechanisms try to remove the congestion after it happens.
• The various methods used for closed loop congestion control are:
Backpressure
• Back pressure is a node-to-node congestion control that starts with a node and propagates, in
the opposite direction of data flow.
26
The backpressure technique can be applied only to virtual circuit networks. In such virtual circuit each
node knows the upstream node from which a data flow is coming.
In this method of congestion control, the congested node stops receiving data from the
immediate upstream node or nodes.
• This may cause the upstream node on nodes to become congested, and they, in turn, reject data
from their upstream node or nodes.
• As shown in fig node 3 is congested and it stops receiving packets and informs its upstream
node 2 to slow down. Node 2 in turns may be congested and informs node 1 to slow down. Now
node 1 may create congestion and informs the source node to slow down. In this way the
congestion is alleviated. Thus, the pressure on node 3 is moved backward to the source to
remove the congestion.
Choke Packet
• In this method of congestion control, congested router or node sends a special type of packet called
choke packet to the source to inform it about the congestion.
• Here, congested node does not inform its upstream node about the congestion as in
backpressure method.
• In choke packet method, congested node sends a warning directly to the source station i.e. the
intermediate nodes through which the packet has traveled are not warned.
Implicit Signaling
• In implicit signaling, there is no communication between the congested node or nodes and the
source.
• The source guesses that there is congestion somewhere in the network when it does not
receive any acknowledgment. Therefore the delay in receiving an acknowledgment is
interpreted as congestion in the network.
• On sensing this congestion, the source slows down.
• This type of congestion control policy is used by TCP.
27
Explicit Signaling
• In this method, the congested nodes explicitly send a signal to the source or destination to
inform about the congestion.
• Explicit signaling is different from the choke packet method. In choke packed method, a
separate packet is used for this purpose whereas in explicit signaling method, the signal is
included in the packets that carry data .
• Explicit signaling can occur in either the forward direction or the backward direction .
• In backward signaling, a bit is set in a packet moving in the direction opposite to the
congestion. This bit warns the source about the congestion and informs the source to slow
down.
• In forward signaling, a bit is set in a packet moving in the direction of congestion. This bit
warns the destination about the congestion. The receiver in this case uses policies such as
slowing down the acknowledgements to remove the congestion.
Congestion control algorithms
•
Also, when the bucket is full, any additional water that enters into the bucket spills over the sides and is
lost.
28
• 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.
• The leaky bucket algorithm allows only an average (constant) rate of data flow. Its major
problem is that it cannot deal with bursty data.
• A leaky bucket algorithm does not consider the idle time of the host. For example, if the host
was idle for 10 seconds and now it is willing to sent data at a very high speed for another 10
seconds, the total data transmission will be divided into 20 seconds and average data rate will be
maintained. The host is having no advantage of sitting idle for 10 seconds.
• To overcome this problem, a token bucket algorithm is used. A token bucket algorithm allows
bursty data transfers.
• A token bucket algorithm is a modification of leaky bucket in which leaky bucket contains
tokens.
• In this algorithm, a token(s) are generated at every clock tick. For a packet to be transmitted,
system must remove token(s) from the bucket.
• Thus, a token bucket algorithm allows idle hosts to accumulate credit for the future in form of
tokens.
29
For example, if a system generates 100 tokens in one clock tick and the host is idle for 100
ticks. The bucket will contain 10,000 tokens.
Now, if the host wants to send bursty data, it can consume all 10,000 tokens at once for sending
10,000 cells or bytes.
Thus a host can send bursty data as long as bucket is not empty.
30
Jitter buffer
This is a temporary storage buffer which is used to store the incoming data packets, it is used
in packet-based networks to ensure that the continuity of the data streams doesn't get
disturbed, it does that by smoothing out the packet arrival times during periods of network
congestion.
Traffic shaping
This technique which is also known as packet shaping, is a congestion control or management
technique that helps to regulate network data transfer by delaying the flow of least important or
least necessary data packets.
QoS is included in the service-level agreement when an organization signs it with its network service
provider which guarantees the selected performance level.
1. Stateless solution: Here, the server is not required to keep or store the server information
or session details to itself. The routers maintain no fine-grained state about traffic, one
positive factor of this is, that it's scalable and robust. But also, it has weak services as
there is no guarantee about the kind of performance delay in a particular application
which we encounter. In the stateless solution, the server and client are loosely
coupled and can act.
2. Stateful solution: Here, the server is required to maintain the current state and session
information, the routers maintain per-flow state as the flow is very important in
providing the Quality-of-Service which is providing powerful services such as guaranteed
services and high resource utilization, provides protection, and is much less scalable and
robust. Here, the server and client are tightly bounded.
Quality of Service Parameters:
31
Mean opinion score: it is a metric for rating the audio quality which uses a five-point
scale, with a five indicating the highest or best quality.
We can implement Quality of service through three of the following existing models:
1. Best Effort: if we are applying this model then, it means that we are prioritizing all the
data packets equally. But since we all setting the priority order like this, then there is no
guarantee that all the data packets will be delivered, but it will put up the best effort to
deliver all of them. Point to remember is, that the best-effort model is applied when
networks haven’t configured with the QoS policies or incase their network infrastructure
does not support QoS.
2. Integrated Services: or IntServ, this QoS model reserves the bandwidth along a specific
path on the network. The applications ask the network's resource reservation for
themselves and parallelly the network devices monitor the flow of packets to make sure
network resources can accept packets. Point to remember: while implementing Integrated
Services Model, the IntServ-capable routers and resource reservation protocol is
necessary. This model has limited scalability and high consumption of the network
resources.
3. Differentiated Services: in this QoS model, the network elements such as routers and
switches are configured to serve multiple categories of traffic with different priority
orders. A company can categorize the network traffic based on its requirements. Eg.
Assigning higher priority to audio traffic etc.
Internetworking
Internetworking started as a way to connect disparate types of computer networking
technology. Computer network term is used to describe two or more computers that are linked
to each other. When two or more computer LANs or WANs or computer network segments are
connected using devices such as a router and configure by logical addressing scheme with
a protocol such as IP, then it is called as computer internetworking.
Internetworking is a term used by Cisco. Any interconnection among or between public, private,
commercial, industrial, or governmental computer networks may also be defined as an
internetwork or “Internetworking“.In modern practice, the interconnected computer networks
or Internetworking use the Internet Protocol. Two architectural models are commonly used to describe
the protocols and methods used in internetworking. The standard reference model
for internetworking is Open Systems Interconnection (OSI).
32
Type of Internetworking
Internetworking is implemented in Layer 3 (Network Layer) of this model The most notable
example of internetworking is the Internet (capitalized). There are three variants of internetwork
or Internetworking, depending on who administers and who participates in them :
• Extranet
• Intranet
• Internet
Intranets and extranets may or may not have connections to the Internet. If connected to the
Internet, the intranet or extranet is normally protected from being accessed from the Internet
without proper authorization. The Internet is not considered to be a part of the intranet or
extranet, although it may serve as a portal for access to portions of an extranet.
Extranet
Internet
33
Network (ARPANET) developed by ARPA of the U.S. Department of Defense also home to
the World Wide Web (WWW) and referred to as the ‘Internet‘ with a capital ‘I’ to
distinguish it from other generic internetworks. Participants in the Internet, or their service
providers, use IP Addresses obtained from address registries that control assignments.
IP address
A computer network consists of various devices such as desktops, laptops, servers, routers,
and, switches to share data and resources. These devices are connected together using wired or
wireless medium. Each device in the network has an address to recognize it. Hence, this address
is called the IP address, which stands for Internet Protocol Address. The IP address helps the
devices in the network to communicate with each other. Furthermore, there are two types of IP
address. Namely, they are static IP address and dynamic IP address. A static IP address is a
permanent address assigned to a device while a dynamic address is a temporary address that
changes frequently.
Static IP Address
Static IP address is a fixed IP address assigned to the device manually. It was the original method
to assign IP addresses to the devices in the network. Here, for each computer, the network
administrator has to open the network configuration page and manually type the IP address.
Additionally, the administrator should also include details such as subnet mask and default
gateway. Moreover, this process had to be followed on all the devices in the network. Thus, it is
difficult to assign static IP addresses when there are a large number of devices in the network.
34
However, the static IP address is not changed until it is manually changed by the network
administrator or the Internet Service Provider (ISP). Also, this address does not change each time
when the user connects to the network. In other words, the device always uses the same IP
address to connect to the internet. Therefore, the static IP addressing provides multiple
advantages. It gives minimum downtime while providing remote access. Also, the user can
access the device from any location.
Dynamic IP Address
A dynamic IP address is an address obtained from a Dynamic Host Configuration Protocol
(DHCP) server. It assigns a device with dynamic IP address, subnet mask, default gateway, and
a DNS server. In a Microsoft computer, selecting the option “obtain an IP address automatically”
in the network property window will set the device to obtain an IP address dynamically.
The dynamic IP address changes frequently. Each time the device connects to the network, the
dynamic IP address changes. When the device tries to connect to the network, the DHCP server
provides a dynamic address. When the user types a URL on the web browser, the DNS server
maps the domain name to the IP address. Overall, Dynamic IP addressing is automatic and it
makes managing a network easier.
35
There are two types of IP addresses:
o IPv4
o IPv6
IPV4
IPv4 is a version 4 of IP. It is a current version and the most commonly used IP address. It is a
32-bit address written in four numbers separated by 'dot', i.e., periods. This address is unique for
each device.
The above example represents the IP address in which each group of numbers separated by
periods is called an Octet. Each number in an octet is in the range from 0-255. This address can
produce 4,294,967,296 possible unique addresses.
In today's computer network world, computers do not understand the IP addresses in the standard
numeric format as the computers understand the numbers in binary form only. The binary
number can be either 1 or 0. The IPv4 consists of four sets, and these sets represent the octet. The
bits in each octet represent a number.
36
Let us discuss each field of IPv4 header one by one.
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.
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.
Minimum And Maximum Header Length-
The length of IP header always lies in the range-[20 bytes , 60 bytes]
The initial 5 rows of the IP header are always used.
So, minimum length of IP header = 5 x 4 bytes = 20 bytes.
The size of the 6th row representing the Options field vary.
The size of Options field can go up to 40 bytes.
So, maximum length of IP header = 20 bytes + 40 bytes = 60 bytes.
3. Type Of Service- Type of service is a 8 bit field that is used for Quality of Service (QoS).
4. Total Length-Total length is a 16 bit field that contains the total length of the datagram (in
bytes).
37
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 [Link] is used for the identification of the fragments
of an original IP datagram.
When an IP datagram is fragmented,
Each fragmented datagram is assigned the same identification number.
This number is useful during the re assembly of fragmented datagrams.
It helps to identify to which IP datagram, the fragmented datagram belongs to.
6. DF Bit- DF bit stands for Do Not Fragment [Link] value may be 0 or 1.
When DF bit is set to 0,
It grants the permission to the intermediate devices to fragment the datagram if required.
38
Fragment offset for a given fragmented datagram= Number of data bytes ahead of it in the original
unfragmented datagram
14. Options- Options is a field whose size vary from 0 bytes to 40 bytes.
Drawback of IPv4
Currently, the population of the world is 7.6 billion. Every user is having more than one device
connected with the internet, and private companies also rely on the internet. As we know that
IPv4 produces 4 billion addresses, which are not enough for each device connected to the
39
internet on a planet. Although the various techniques were invented, such as variable- length
mask, network address translation, port address translation, classes, inter-domain translation, to
conserve the bandwidth of IP address and slow down the depletion of an IP address. In these
techniques, public IP is converted into a private IP due to which the user having public IP can
also use the internet. But still, this was not so efficient, so it gave rise to the development of the
next generation of IP addresses, i.e., IPv6.
IP Addressing-
Classful Addressing- An IP address is a 32 bit unique address having an address space of 2 32.
Generally, there are two notations in which IP address is written, dotted decimal notation and
hexadecimal notation.
1. The value of any segment (byte) is between 0 and 255 (both included).
2. There are no zeroes preceding the value in any segment (054 is wrong, 54 is correct).
40
Hexadecimal Notation:
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for
multicast and experimental purposes respectively. The order of bits in the first octet determine
the classes of IP address.
IPv4 address is divided into two parts:
Network ID
41
Host ID
The class of IP address is used to determine the bits used for network ID and host ID and the
number of total networks and hosts possible in that particular class. Each ISP or network
administrator assigns IP address to each device that is connected to its network.
Note: IP addresses are globally managed by Internet Assigned Numbers Authority(IANA) and
regional Internet registries(RIR).
Class A:
IP address belonging to class A are assigned to the networks that contain a large number of
hosts.
Class C:
Class E:
IP addresses belonging to class E are reserved for experimental and research purposes. IP
addresses of class E ranges from [Link] – [Link].
42
Classless Addressing-
CIDR Block-
When a user asks for specific number of IP Addresses,
CIDR dynamically assigns a block of IP Addresses based on certain rules.
This block contains the required number of IP Addresses as demanded by the user.
This block of IP Addresses is called as a CIDR block.
Rule-01:
Rule-02:
Rule-03:
First IP Address of the block must be divisible by the size of the block.
CIDR Notation-
CIDR IP Addresses look like-
43
a.b.c.d / n
IPV6
IPv4 produces 4 billion addresses, and the developers think that these addresses are enough, but
they were wrong. IPv6 is the next generation of IP addresses. The main difference between IPv4
and IPv6 is the address size of IP addresses. The IPv4 is a 32-bit address, whereas IPv6 is a 128-
bit hexadecimal address. IPv6 provides a large address space, and it contains a simple header as
compared to IPv4.
It provides transition strategies that convert IPv4 into IPv6, and these strategies are as follows:
o Dual stacking: It allows us to have both the versions, i.e., IPv4 and IPv6, on the same
device.
o Tunneling: In this approach, all the users have IPv6 communicates with an IPv4 network
to reach IPv6.
o Network Address Translation: The translation allows the communication between the
hosts having a different version of IP.
This hexadecimal address contains both numbers and alphabets. Due to the usage of both the
numbers and alphabets, IPv6 is capable of producing over 340 undecillion (3.4*1038) addresses.
IPv6 is a 128-bit hexadecimal address made up of 8 sets of 16 bits each, and these 8 sets are
separated by a colon. In IPv6, each hexadecimal character represents 4 bits. So, we need to
convert 4 bits to a hexadecimal number at a time
Address format
44
The above diagram shows the address format of IPv4 and IPv6. An IPv4 is a 32-bit decimal
address. It contains 4 octets or fields separated by 'dot', and each field is 8-bit in size. The
number that each field contains should be in the range of 0-255. Whereas an IPv6 is a 128-bit
hexadecimal address. It contains 8 fields separated by a colon, and each field is 16-bit in size.
IP version 6 is the new version of Internet Protocol, which is way better than IP version 4 in
terms of complexity and efficiency. Let’s look at the header of IP version 6 and understand
how it is different from IPv4 header.
IP version 6 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 priority
of the packet. If congestion occurs on router then packets with least priority will be discarded.
As of now only 4-bits are being used (and 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.
Priority assignment of Congestion controlled traffic :
45
Uncontrolled data traffic is mainly used for Audio/Video data. So we give higher priority to
Uncontrolled data traffic.
Source node is allowed to set the priorities but on the way routers can change it. Therefore,
destination should not expect same priority which was set by source node.
Flow Label (20-bits) : Flow Label field is used by 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, intermediate
router can use source address, 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 do 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, source is
also supposed to specify the lifetime of flow.
Payload Length (16-bits) : It is a 16-bit (unsigned integer) field, indicates total size of the
payload which tells routers about amount of information a particular packet contains in its
payload. Payload Length field includes extension headers(if any) and upper layer packet. In
case length of 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 jumbo payload option
is used in the Hop-by-Hop options extension header.
Next Header (8-bits) : Next Header indicates type of extension header(if present) immediately
following the IPv6 header. Whereas In some cases it indicates the protocols contained within
upper-layer packet, such as TCP, UDP.
Hop Limit (8-bits) : Hop Limit field is 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 packet is discarded if value
decrements to 0. This is used to discard the packets that are stuck in infinite loop because of
some routing error.
Source Address (128-bits) : Source Address is 128-bit IPv6 address of the original source of
the packet.
Destination Address (128-bits) : 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 IPv4 Option Field, Extension
Headers are introduced in IPversion 6. The extension header mechanism is very important part
of the IPv6 architecture. 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.
IPv6 packet may contain zero, one or more extension headers but these should be present in
their recommended order:
46
Differences between IPv4 and IPv6
IPV4 IPV6
Classes IPv4 has 5 different classes of IP IPv6 does not contain classes of
address that includes Class A, Class B, IP addresses.
Class C, Class D, and Class E.
47
Security features In IPv4, security depends on the In IPv6, IPSEC is developed for
application. This IP address is not security purposes.
developed in keeping the security
feature in mind.
Packet flow It does not provide any mechanism for It uses flow label field in the
identification packet flow identification. header for the packet flow
identification.
Checksum field The checksum field is available in IPv4. The checksum field is not
available in IPv6.
Encryption and It does not provide encryption and It provides encryption and
Authentication authentication. authentication.
48