Computer Network_Unit 2
Computer Network_Unit 2
o In the OSI model, the data link layer is a 4th layer from the top and 2nd layer
from the bottom.
o The communication channel that connects the adjacent nodes is known as links,
and in order to move the datagram from source to the destination, the
datagram must be moved across an individual link.
o The main responsibility of the Data Link Layer is to transfer the datagram across
an individual link.
o The Data link layer protocol defines the format of the packet exchanged across
the nodes as well as the actions such as Error detection, retransmission, flow
control, and random access.
o The Data Link Layer protocols are Ethernet, token ring, FDDI and PPP.
o An important characteristic of a Data Link Layer is that datagram can be handled
by different link layer protocols on different links in a path. For example, the
datagram is handled by Ethernet on the first link, PPP on the second link.
It is a data-link layer protocol which is used for transmitting the data over the noiseless
channels. It provides unidirectional data transmission which means that either sending
or receiving of data will take place at a time. It provides flow-control mechanism but
does not provide any error control mechanism.
The idea behind the usage of this frame is that when the sender sends the frame then
he waits for the acknowledgment before sending the next frame.
Sender side
Rule 1: Sender sends one data packet at a time.
Rule 2: Sender sends the next packet only when it receives the acknowledgment of
the previous packet.
Therefore, the idea of stop and wait protocol in the sender's side is very simple, i.e.,
send one packet at a time, and do not send another packet before receiving the
acknowledgment.
Receiver side
Rule 1: Receive and then consume the data packet.
Rule 2: When the data packet is consumed, receiver sends the acknowledgment to the
sender.
Therefore, the idea of stop and wait protocol in the receiver's side is also very simple,
i.e., consume the packet, and once the packet is consumed, the acknowledgment is
sent. This is known as a flow control mechanism.
The above figure shows the working of the stop and wait protocol. If there is a sender
and receiver, then sender sends the packet and that packet is known as a data packet.
The sender will not send the second packet without receiving the acknowledgment of
the first packet. The receiver sends the acknowledgment for the data packet that it has
received. Once the acknowledgment is received, the sender sends the next packet. This
process continues until all the packet are not sent. The main advantage of this protocol
is its simplicity but it has some disadvantages also. For example, if there are 1000 data
packets to be sent, then all the 1000 packets cannot be sent at a time as in Stop and
Wait protocol, one packet is sent at a time.
Suppose the sender sends the data and the data is lost. The receiver is waiting for the
data for a long time. Since the data is not received by the receiver, so it does not send
any acknowledgment. Since the sender does not receive any acknowledgment so it
will not send the next packet. This problem occurs due to the lost data.
Suppose the sender sends the data and it has also been received by the receiver. The
receiver then sends the acknowledgment but the acknowledgment is received after
the timeout period on the sender's side. As the acknowledgment is received late, so
acknowledgment can be wrongly considered as the acknowledgment of some other
data packet.
o The Sliding Window is a method of flow control in which a sender can transmit
the several frames before getting an acknowledgement.
o In Sliding Window Control, multiple frames can be sent one after the another
due to which capacity of the communication channel can be utilized efficiently.
o A single ACK acknowledge multiple frames.
o Sliding Window refers to imaginary boxes at both the sender and receiver end.
o The window can hold the frames at either end, and it provides the upper limit
on the number of frames that can be transmitted before the acknowledgement.
o Frames can be acknowledged even when the window is not completely filled.
o The window has a specific size in which they are numbered as modulo-n means
that they are numbered from 0 to n-1. For example, if n = 8, the frames are
numbered from 0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1........
o The size of the window is represented as n-1. Therefore, maximum n-1 frames
can be sent before acknowledgement.
o When the receiver sends the ACK, it includes the number of the next frame that
it wants to receive. For example, to acknowledge the string of frames ending
with frame number 4, the receiver will send the ACK containing the number 5.
When the sender sees the ACK with the number 5, it got to know that the frames
from 0 through 4 have been received.
Sender Window
o At the beginning of a transmission, the sender window contains n-1 frames, and
when they are sent out, the left boundary moves inward shrinking the size of
the window. For example, if the size of the window is w if three frames are sent
out, then the number of frames left out in the sender window is w-3.
o Once the ACK has arrived, then the sender window expands to the number
which will be equal to the number of frames acknowledged by ACK.
o For example, the size of the window is 7, and if frames 0 through 4 have been
sent out and no acknowledgement has arrived, then the sender window
contains only two frames, i.e., 5 and 6. Now, if ACK has arrived with a number 4
which means that 0 through 3 frames have arrived undamaged and the sender
window is expanded to include the next four frames. Therefore, the sender
window contains six frames (5,6,7,0,1,2).
Receiver Window
1. Go-Back-N ARQ
2. Selective Repeat ARQ
Go-Back-N ARQ
In Go-Back-N ARQ, N is the sender's window size. Suppose we say that Go-Back-3,
which means that the three frames can be sent at a time before expecting the
acknowledgment from the receiver.
It uses the principle of protocol pipelining in which the multiple frames can be sent
before receiving the acknowledgment of the first frame. If we have five frames and the
concept is Go-Back-3, which means that the three frames can be sent, i.e., frame no 1,
frame no 2, frame no 3 can be sent before expecting the acknowledgment of frame no
1.
In Go-Back-N ARQ, the frames are numbered sequentially as Go-Back-N ARQ sends
the multiple frames at a time that requires the numbering approach to distinguish the
frame from another frame, and these numbers are known as the sequential numbers.
The number of frames that can be sent at a time totally depends on the size of the
sender's window. So, we can say that 'N' is the number of frames that can be sent at a
time before receiving the acknowledgment from the receiver.
The sequence number of the outbound frames depends upon the size of the sender's
window. Suppose the sender's window size is 2, and we have ten frames to send, then
the sequence numbers will not be 1,2,3,4,5,6,7,8,9,10. Let's understand through an
example.
The number of bits in the sequence number is 2 to generate the binary sequence
00,01,10,11.
Step 1: Firstly, the sender will send the first four frames to the receiver, i.e., 0,1,2,3, and
now the sender is expected to receive the acknowledgment of the 0th frame.
Let's assume that the receiver has sent the acknowledgment for the 0 frame, and the
receiver has successfully received it.
The sender will then send the next frame, i.e., 4, and the window slides containing four
frames (1,2,3,4).
The receiver will then send the acknowledgment for the frame no 1. After receiving the
acknowledgment, the sender will send the next frame, i.e., frame no 5, and the window
will slide having four frames (2,3,4,5).
Now, let's assume that the receiver is not acknowledging the frame no 2, either the
frame is lost, or the acknowledgment is lost. Instead of sending the frame no 6, the
sender Go-Back to 2, which is the first frame of the current window, retransmits all the
frames in the current window, i.e., 2,3,4,5.
Selective-Repeat ARQ
For example, suppose that there is a classroom full of students. When a teacher asks a
question, all the students (small channels) in the class start answering the question at
the same time (transferring the data simultaneously). All the students respond at the
same time due to which data is overlap or data lost. Therefore it is the responsibility
of a teacher (multiple access protocol) to manage the students and make them one
answer.
Following are the types of multiple access protocol that is subdivided into the different
process as:
o Aloha
o CSMA
o CSMA/CD
o CSMA/CA
It is designed for wireless LAN (Local Area Network) but can also be used in a shared
medium to transmit data. Using this method, any station can transmit data across a
network simultaneously when a data frameset is available for transmission.
Aloha Rules
Whenever data is available for sending over a channel at stations, we use Pure Aloha.
In pure Aloha, when each station transmits data to a channel without checking whether
the channel is idle or not, the chances of collision may occur, and the data frame can
be lost. When any station transmits the data frame to a channel, the pure Aloha waits
for the receiver's acknowledgment. If it does not acknowledge the receiver end within
the specified time, the station waits for a random amount of time, called the backoff
time (Tb). And the station may assume the frame has been lost or destroyed. Therefore,
it retransmits the frame until all the data are successfully transmitted to the receiver.
As we can see in the figure above, there are four stations for accessing a shared channel
and transmitting data frames. Some frames collide because most stations send their
frames at the same time. Only two frames, frame 1.1 and frame 2.2, are successfully
transmitted to the receiver end. At the same time, other frames are lost or destroyed.
Whenever two frames fall on a shared channel simultaneously, collisions can occur,
and both will suffer damage. If the new frame's first bit enters the channel before
finishing the last bit of the second frame. Both frames are completely finished, and
both stations must retransmit the data frame.
Slotted Aloha
The slotted Aloha is designed to overcome the pure Aloha's efficiency because pure
Aloha has a very high possibility of frame hitting. In slotted Aloha, the shared channel
is divided into a fixed time interval called slots. So that, if a station wants to send a
frame to a shared channel, the frame can only be sent at the beginning of the slot, and
only one frame is allowed to be sent to each slot. And if the stations are unable to send
data to the beginning of the slot, the station will have to wait until the beginning of
the slot for the next time. However, the possibility of a collision remains when trying
to send a frame at the beginning of two or more station time slot.
It is a carrier sense multiple access based on media access protocol to sense the
traffic on a channel (idle or busy) before transmitting the data. It means that if the
channel is idle, the station can send data to the channel. Otherwise, it must wait until
the channel becomes idle. Hence, it reduces the chances of a collision on a
transmission medium.
Non-Persistent: It is the access mode of CSMA that defines before transmitting the
data, each node must sense the channel, and if the channel is inactive, it immediately
sends the data. Otherwise, the station must wait for a random time (not continuously),
and when the channel is found to be idle, it transmits the frames.
CSMA/ CA
Following are the methods used in the CSMA/ CA to avoid the collision:
Interframe space: In this method, the station waits for the channel to become idle,
and if it gets the channel is idle, it does not immediately send the data. Instead of this,
it waits for some time, and this time period is called the Interframe space or IFS.
However, the IFS time is often used to define the priority of the station.
Contention window: In the Contention window, the total time is divided into different
slots. When the station/ sender is ready to transmit the data frame, it chooses a
random slot number of slots as wait time. If the channel is still busy, it does not restart
the entire process, except that it restarts the timer only to send data packets when the
channel is inactive.
Acknowledgment: In the acknowledgment method, the sender station sends the data
frame to the shared channel if the acknowledgment is not received ahead of time.