CN UNIT 2 full notes
CN UNIT 2 full notes
The Data-link layer is the second layer from the bottom in the OSI (Open System
Interconnection) network architecture model. It is responsible for the node-to-node delivery
of data. Its major role is to ensure error-free transmission of information. DLL is also
responsible to encode, decode and organize the outgoing and incoming data. This is considered
the most complex layer of the OSI model as it hides all the underlying complexities of the
hardware from the other above layers.
The data link layer receives the information in the form of packets from the Network layer,it
divides packets into frames and sends those frames bit-by-bit to the underlying physical
layer.
Error Detection
When data is transmitted from one device to another device, the system does not
guarantee whether the data received by the device is identical to the data transmitted by
another device. An Error is a situation when the message received at the receiver end is not
identical to the message transmitted.
Types of Errors
Single-Bit Error:
The only one bit of a given data unit is changed from 1 to 0 or from 0 to 1.
In the above figure, the message which is sent is corrupted as single-bit, i.e., 0 bit is changed
to 1.
Single-Bit Error does not appear more likely in Serial Data Transmission. For example,
Sender sends the data at 10 Mbps, this means that the bit lasts only for 1’s and for a single-
bit error to occurred, a noise must be more than 1’s.
Single-Bit Error mainly occurs in Parallel Data Transmission. For example, if eight wires are
used to send the eight bits of a byte, if one of the wire is noisy, then single-bit is corrupted
per byte.
Burst Error:
The two or more bits are changed from 0 to 1 or from 1 to 0 is known as Burst Error.
The Burst Error is determined from the first corrupted bit to the last corrupted bit.
The duration of noise in Burst Error is more than the duration of noise in Single-Bit.
Burst Errors are most likely to occur in Serial Data Transmission.
The number of affected bits depends on the duration of the noise and data rate.
Checksum
Checksum is a error detection which detects the error by dividing the data into the
segments of equal size and then use 1's complement to find the sum of the segments and
then sum is transmitted with the data to the receiver and same process is done by the receiver
and at the receiver side, all zeros in the sum indicates the correctness of the data.
Step-01:
At sender side,
If m bit checksum is used, the data unit to be transmitted is divided into segments of m
bits.
All the m bit segments are added.
The result of the sum is then complemented using 1’s complement arithmetic.
The value so obtained is called as checksum.
Step-02:
The data along with the checksum value is transmitted to the receiver.
Step-03:
At receiver side,
If m bit checksum is being used, the received data unit is divided into segments of m
bits.
All the m bit segments are added along with the checksum value.
The value so obtained is complemented and the result is checked.
Case-02: Result ≠ 0
If the result is non-zero,
Receiver assumes that error occurred in the data during the transmission.
Receiver discards the data and asks the sender for retransmission.
If the resultant of this division is zero which means that it has no error, and the data is
accepted.
If the resultant of this division is not zero which means that the data consists of an error.
Therefore, the data is discarded.
Let's understand this concept through an example:
Suppose the original data is 11100 and divisor is 1001.
CRC Generator
o A CRC generator uses a modulo-2 division. Firstly, three zeroes are appended at the
end of the data as the length of the divisor is 4 and we know that the length of the
string 0s to be appended is always one less than the length of the divisor.
o Now, the string becomes 11100000, and the resultant string is divided by the divisor
1001.
o The remainder generated from the binary division is known as CRC remainder. The
generated value of the CRC remainder is 111.
o CRC remainder replaces the appended string of 0s at the end of the data unit, and
the final string would be 11100111 which is sent across the network.
CRC Checker
o The functionality of the CRC checker is similar to the CRC generator.
o When the string 11100111 is received at the receiving end, then CRC checker
performs the modulo-2 division.
o A string is divided by the same divisor, i.e., 1001.
o In this case, CRC checker generates the remainder of zero. Therefore, the data is
accepted.
In Error Detection, the receiver only needs to know that the received codeword is
invalid; But in Error Correction the receiver needs to guess the Original codeword that is
sent. In this way, error Correction is much more difficult than Error Detection.
The need for redundant bits is more during error correction rather than for error detection.
In order to detect or correct the errors, there is a need to send some extra bits along with
the data. These extra bits are commonly known as Redundant bits.
As we had learned in the previous topics that original data is divided into segments
of k bits; it is referred to as dataword. When we add r redundant bits to each block in order
to make the length;n=k+r then it is referred to as Codeword.
There are two ways to handle the error correction:
1. Whenever an error discovered, the receiver can have the sender in order to retransmit
the entire data unit. This technique is known as the Backward Error correction
technique. This technique is simple and inexpensive in the case of wired transmission
like fiber optics; there is no expense in retransmitting the data. In the case of wireless
transmission, retransmission costs too much thus forward error correction technique is
used then.
2. The receiver can use an error-correcting code that automatically contains certain errors.
This technique is known as the Forward Error Correction technique.
In order to correct the errors, one has to know the exact position of the error. For
example, In case if we want to calculate a single-bit error, the error correction code then mainly
determines which one of seven bits is in the error.
In order to achieve this, we have to add some additional redundant bits.
Suppose r (as the redundant bits) and d indicates the total number of data bits. In order to
calculate the redundant bits(r), the given formula is used;
2r= d+r+1
Error correction is mainly done with the help of the Hamming code.
Here, all the redundant bit, p1, is must calculated as the parity. It should cover all the bit
positions whose binary representation should include a 1 in the 1st position excluding the
position of p1.
P1 is the parity bit for every data bits in positions whose binary representation includes a 1
in the less important position not including 1 Like (3, 5, 7, 9, …. )
P2 is the parity bit for every data bits in positions whose binary representation include 1 in the
position 2 from right, not including 2 Like (3, 6, 7, 10, 11,…)
P3 is the parity bit for every bit in positions whose binary representation includes a 1 in the
position 3 from right not include 4 Like (5-7, 12-15,… )
From the formula we can make out that there are 4 data bits and 3 redundancy bits, referring
to the received 7-bit hamming code.
First, we need to detect whether there are any errors in this received hamming code.
Step 1: For checking parity bit P1, use check one and skip one method, which means,
starting from P1 and then skip P2, take D3 then skip P4 then take D5, and then skip D6 and
take D7, this way we will have the following bits,
As we can observe the total number of bits are odd so we will write the value of parity bit
as P1 = 1. This means error is there.
Step 2: Check for P2 but while checking for P2, we will use check two and skip two method,
which will give us the following data bits. But remember since we are checking for P2, so
we have to start our count from P2 (P1 should not be considered).
As we can observe that the number of 1's are even, then we will write the value of P2 = 0. This
means there is no error.
Step 3: Check for P4 but while checking for P4, we will use check four and skip four
method, which will give us the following data bits. But remember since we arechecking for
P4, so we have started our count from P4(P1 & P2 should not be considered).
As we can observe that the number of 1's are odd, then we will write the value of P4 = 1.
This means the error is there.
So, from the above parity analysis, P1 & P4 are not equal to 0, so we can clearly say that the
received hamming code has errors.
Now we have to determine the decimal value of this error word 101 which is 5.
We get E = 5, which states that the error is in the fifth data bit. To correct it, just invert the
fifth data bit.
So the correct data will be:
Conclusion:
We have seen how the hamming code in computer network technique works for error
detection and correction in a data packet transmitted over a network.
Simplex Protocol
In simplest protocol, there is no flow control and error control mechanism. It is a
unidirectional protocol in which data frames travel in only one direction (from sender
to receiver).
Also, the receiver can immediately handle any received frame with a processing time
that is small enough to be negligible.
The protocol consists of two distinct procedures :a sender and receiver. The sender runs in
the data link layer of the source machine and the receiver runs in the data link layer of
the destination machine. No sequence number or acknowledgements are used here.
Primitives/Rules
Sender side
Rule 1: Send one data packet at a time.
Rule 2: Send the next packet only after receiving acknowledgement of the previous
one.
Receiver side
Rule 1: Receive and consume data packet.
Rule 2: After consuming packet, acknowledgement need to send (flow control).
Diagram
Sender Receiver
Issues faced by Stop AND Wait protocol
1. Problem due to loss of packet.
Diagram:
Sender Receiver
Noise Channels
1. Stop And Wait ARQ protocol
2. Go- Back N ARQ protocol
3. Selective Repeat ARQ
Stop And Wait ARQ protocol
It is one of the straightforward protocol.
After sending data packet wait for acknowledgement before transferring next Frame.
If acknowledgement does not arrive for a certain period of time, the sender timeout
and re-transmits the original frame.
Stop AND Wait ARQ=Stop AND Wait +timeout time+ Sequence Number.
Diagram
Sender Receiver
Timeout (TO)
Timeout
(TO)
b) Problem due to Acknowledgement Lost
Sender Receiver
Timeout
(TO) Retransmit the Frame
Timeout
Both are not lost but time
(TO)
expired
Timeout
(TO)
Drawbacks
One frame at a time (high bandwidth is waste).
Poor utilization of Bandwidth.
Poor performance.
Sliding Window Protocol
Combination of Go-back N ARQ and Selective Repeat ARQ is Sliding window
protocol.
We can send multiple frames at a time.
Number of frames to be sent based on window size.
Each Frame is numbered (sequence number)
10 9 8 7 6 5 4 3 2 1 0
Sliding Window
10 9 8 7 6 5 4 3 2 1 0
Sender Receiver
Window Size=4
0
0
1
1
2
2
3
6
Go Back -N-ARQ
Uses concept of protocol pipelining i.e the sender can send multiple frames before
receiving the ACK for first frame.
There are finite number of frames the frames are numbered in a sequential manner.
The number of frames that can be sent depends on the window size of the sender.
If the acknowledgement of frame is not received within the agreed upon time period
all frames in the current sliding window are re-transmitted.
The size of the sending window determines the sequence number of outbound frame.
N-Sender window size.
Ex: If the sending window is 4(22) then the sequence number will be 0,1,2,3,0,1,2,3,0,1.
The number of bits in the sequence number to generate the binary sequence
00,01,10,11.
10 9 8 7 6 5 4 3 2 1 0
Sliding Window panel
10 9 8 7 6 5 4 3 2 1 0
0
1
1
2
2
3
Re-transmitted
frames
frames in memoryand sends NACK for only frame which is missing
Select Repeat
ARQ or damaged.
The sender will send/re-transmit packet for which NACK is received.
Only the
10
erroneous
The network Layer controls the operation of the subnet. The main aim of this layer is to
deliver packets from source to destination across multiple links (networks). If two computers
(system) are connected on the same link, then there is no need for a network layer. It routes
the signal through different channels to the other end and acts as a network controller.
It also divides the outgoing messages into packets and to assemble incoming packets into
messages for higher levels.
In broadcast networks, the routing problem is simple, so the network layer is often thin or
even non-existent.
o
o
Routing classifications:
Different Routing Algorithms:
1. Static Routing Algorithm
a. Shortest path routing
b. Flooding
c. Flow based routing
2. Dynamic Routing Algorithm
a. Distance vector Routing
b. Link State Routing
3. Hierarchical routing
4. Routing for mobile hosts
5. Broad cast routing
6. Multicast routing
1. Static Routing Algorithm
estination
pkt
B D
D
pkt
A
Source
C E
pkt
The major disadvantages are vast number of duplicate packets are generated.
How to stop and eliminate duplicate packets:
a) Using hop counter
Decrement in each router
Discard packet if counter is ‘0’
B
data
D D
Destination
D D
Advantages of Flooding
It is very simple to setup and implement, since a router may know only its neighbours.
It is extremely robust. Even in case of malfunctioning of a large number routers, the
packets find a way to reach the destination.
All nodes which are directly or indirectly connected are visited. So, there are no chances
for any node to be left out. This is a main criteria in case of broadcast messages.
The shortest path is always chosen by flooding.
Limitations of Flooding
Flooding tends to create an infinite number of duplicate data packets, unless some
measures are adopted to damp packet generation.
It is wasteful if a single destination needs the packet, since it delivers the data packet
to all nodes irrespective of the destination.
The network may be clogged with unwanted and duplicate data packets. This may
hamper delivery of other data packets.
2. Dynamic Routing Algorithm:
Distance vector routing algorithm:
o Select the least cost between nodes
o Bellman ford Algorithm
o One routing table per node should be present
Bellman’s ford Algorithm:
o Defines distance at each node
dx(y) = cost of least cost path from x to y.x
= Source, y= Destination
update distance based on neighbour nodesdx(y)
= min { cost (x,v) + dv(y)}
x = Source, y= Destination, v=Intermediate node,
dv(y) = Distance from intermediate node v to y
Source
9
1 B E
A 3 2
5 C D
4
Example:
Lets us take B as source, and A as destination
Routing Table: B -> A = 1
B -> C -> A = 3+5=8
B -> E -> D -> A = 9+2+4+5 =20
Distance Vector:
Routing table for B
Source
9
1 B E
A 3 2
5 C D
4
Destination Cost Nexthop
A 1 A
C 3 C
D 7 C
E 9 E
B to D
B -> A -> C -> D = 10
B -> C -> D = 7
B -> E -> D = 11
B to E
B -> E = 9
B -> C -> D = 9
B -> A -> C -> D -> E = 12
2 C 1
node cost E 2
2
3
4
node cost
node cost B 4
A 3 D 3
D 1 F 2
E 4
Source is A
Iteration Tree B C D E F
Initial {A} 3 2 5 ∞ ∞
1 {A, C} 3 - 4 ∞ 3
2 {A, C, B} - - 4 7 3
2 {A, B, C, F} - - 4 5 -
3 {A, C, B, F, D} - - - 5 -
4 {A, C, B, F, D, E} - - - - -
Dijkstra’s Algorithm:
{
Tree = { root }
For (y=1 to N)
{
If( y in the root)
D[y=0]
Else if ( y in the neighbour)
D[y] = c[root][y]
Else D[y]
=∞
Repeat
{
Find a node with D[N] minimum
Tree = Tree u{w}
For (every node x, which is a neighbour)
{
D[x]=min(D[x],D[w] + c[w][x])
}
}
Until all nodes
}
Hierarchical Routing
When the network size grows, the number of routers in the network increases,
consequently the size of routing table increases, as well and routers can’t handle
network traffic as efficiently.
o So, we use hierarchical routing to overcome this problem.
This type of reading is essentially a “Divide and Conquer” strategy
The network is divided into different region and a router for a particular region
knows only about its own domain and other neighbour routers
In this 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 its own domain and other neighbour routers
Each router has only the information about the routers in its own region and has no
information about routers in other region. So, region and has no information about.
So, routers just save 1 record in their table for every other region.
Example: If ‘A’ wants to send the packet to any router in region 2(D, E, F & G) sends them
to B and so on as it is seen in this type of routing, the tables can be summarised. So, network
efficiency improves. The below example shows 2 level hierarchical routing.
In short, we can say congestion means traffic in the network occurs due to the availability
of extra packets in the subnet.
For example, If we compare the congestion with a real-life example then it would be the
same as road traffic which we encounter occasionally while travelling. Both are having almost
similar reasons to occur, i.e., load is greater than available resources.
Causes Of Network Congestion
There may be several reasons for the congestion in a network. Let’s understand them so that
necessary steps can be taken as a preventive measure. The network team uses NPM (Network
Performance Monitors) to find out the any problem that may cause during the transmission.
Effect Of Congestion
The main function of the network gets affected by the congestion, which results in:
1. Slowing down the response time
2. Retransmission of data
3. Confidentiality Breach
Congestion Control
Congestion control is a method to monitor the traffic over the network to keep it at an
acceptable level so that congestion can be prevented before it occurs or if congestion already
occurred, it can be removed.
We can deal with congestion, either by increasing the resources or either by reducing the load.
We will discuss few techniques as well as algorithms for congestion control.
Similarly, each network interface contains a leaky bucket and the following steps areinvolved
in leaky bucket algorithm:
1. When host wants to send packet, packet is thrown into the bucket.
2. The bucket leaks at a constant rate, meaning the network interface transmits packets
at a constant rate.
3. Bursty traffic is converted to a uniform traffic by the leaky bucket.
4. In practice the bucket is a finite queue that outputs at a finite rate.
Ways in which token bucket is superior to leaky bucket : The leaky bucket algorithm
controls the rate at which the packets are introduced in the network, but it is very conservative
in nature. Some flexibility is introduced in the token bucket algorithm. In the token bucket,
algorithm tokens are generated at each tick (up to a certain limit). For an incoming packet to be
transmitted, it must capture a token and the transmission takes place at the same rate. Hence
some of the busty packets are transmitted at the same rate if tokens are available and thus
introduces some amount of flexibility in the system.
Open Loop Congestion Control: This technique is used to prevent congestion beforeit
occurs. Either sender or receiver controls the congestion using this method. In Open loop
congestion control, few policies are used to prevent the congestion before it happens.
Admission Control
In admission policy, the availability of the resources for the transmission is checked by the
switches. If there is a congestion or even a chance for the same to occur then the router will
deny to establish the virtual network connection. It is one of techniques that is widely used in
virtual-circuit networks to keep congestion at bay. The idea is do not set up a new virtual circuit
unless the network can carry the added traffic without becoming congested.
Admission control can also be combined with traffic aware routing by considering routes
around traffic hotspots as part of the setup procedure.
Example
Take two networks (a) A congestion network and (b) The portion of the network that is not
congested. A virtual circuit A to B is also shown below −
Explanation
Step 1 − Suppose a host attached to router A wants to set up a connection to a host attached
to router B. Normally this connection passes through one of the congested routers.
Step 2 − To avoid this situation, we can redraw the network as shown in figure (b),
removing the congested routers and all of their lines.
Step 3 − The dashed line indicates a possible route for the virtual circuit that avoids the
congested routers.
Closed Loop Congestion Control: This technique is used to remove the congestion if
congestion has already occurred in the network. We have further few techniques inside closed
loop to deal with the connection that already occurred.
Choke Packets:
This approach can be used in virtual circuits as well as in the datagram subnets. In this
technique, each router associates a real variable with each of its output lines.
This real variable says “u” has a value between 0and1 and it indicates the percentage utilization
of that line. If the value of “u” goes above the threshold, then that output line will enter
into a “warning” state.
So, to help this, Hop-by-Hop Choke packets are used. Over long distances or at high speeds
choke p y packets are not very effective. A more efficient the method is to send choke packets
hop-by-hop.
This requires each hop to reduce its transmission even before the choke packet arrives at the
source.