Module 4
Module 4
Module 4
● can not correct two or three bit error. It can only detect two or three bit error.
● If we have a error in the parity bit then this scheme will not work.
2. Cyclic Redundancy Check
which is used in networks such as LANs and WANs.
CRC- Encoder
➔ In the encoder, the dataword has k bits (4 here); the codeword has m bits
(7 here).
➔ The size of the dataword is augmented by adding n bits (3 here) 0s to the
right-hand side of the word.
➔ The m-bit result is fed into the generator.
Benefit: we have a polynomial such as X23 + x3 + 1. Here the bit pattern is 24 bits
in length (three 1s and twenty-one 0s) while the polynomial is just three terms.
Binary Division
in a CRC Generator
(Uses modular 2division)
Binary Division
in a
CRC Checker
3. CHECKSUM-Checksum is an error-detecting technique that can be applied to a message of any length.
Traditionally, the Internet has used a 16-bit checksum. The sender and the
receiver follow the steps depicted in Table 10.5. The sender or the receiver uses
five steps.
Eg
at sender
ERROR CORRECTION
Error correction
~ can be handled in two ways:
➔ when an error is discovered, the receiver can have the sender retransmit the
entire data unit.
➔ a receiver can use an error-correcting code, which automatically corrects
certain errors.
➔ Error correction method: Hamming Code
Hamming Code
~ developed by R.W.Hamming in the 1950s
➔ an error-correcting code used to ensure data accuracy during transmission
➔ helps to improve the reliability of communication
➔ It adds extra bits to the original data, allowing the system to detect and
correct single-bit errors.
Example:
r1 = bits 1, 3, 5, 7, 9, 11
r2 = bits 2, 3, 6, 7, 10, 11
r4 = bits 4, 5, 6, 7
r8 = bits 8, 9, 10, 11
etc.
R1 bit is calculated using parity check at all the
bits positions whose binary representation
includes a 1 in the least significant position. R1:
bits 1, 3, 5, 7, 9, 11
● For R1: bits 1, 3, 5, 7, 9, 11. We can see that the number of 1’s in these bit
positions are 3 and that’s odd so we get a 1 for this.
● For R2: bits 2,3,6,7,10,11 . we get a 1 for this.
● For R4: bits 4, 5, 6, 7 . we get a 1 for this.
● For R8: bit 8,9,10,11 . so we get a 0 for this.
● The bits give the binary number 0111 whose decimal representation is 7.
Thus, bit 7 contains an error. To correct the error the 7th bit is changed from
0 to 1.
FLOW AND ERROR CONTROL
FLOW AND ERROR CONTROL
➔ The most important responsibilities of the data link layer are flow control and
error control. Collectively, these functions are known as data link control.
➔ Flow control refers to a set of procedures used to restrict the amount of data
that the sender can send before waiting for acknowledgment.
➔ Error control in the data link layer is based on automatic repeat
request,which is the retransmission of data.
Simple Stop and Wait
At Sender
At Receiver
1. Sender sends the data, which is The sender assigns sequence numbers
also received by the receiver. to each data frame it sends.
2. The receiver sends an This allows the receiver to identify and
acknowledgment after receiving acknowledge each frame individually,
the packet. ensuring reliable delivery of data
packets. After sending a frame, the
3. The acknowledgment is lost in
sender waits for an acknowledgment
the network.
before sending the next frame.
4. The sender does not send the
next data packet because it
does not receive
acknowledgement,
Fig:Sequence number(Data)
3. Delayed Acknowledgement/Data
1. The sender has a control variable, which we call Sn (sender, next frame to
send), that holds the sequence number for the next frame to be sent (0 or 1).
2. The receiver has a control variable, which we call Rn (receiver,next frame
expected), that holds the number of the next frame expected.
3. Sender sends a data frame with sequence number 0.
4. Receiver , after receiving the data frame, sends an acknowledgement with
sequence number 1 (the sequence number of the next expected data frame
or packet)
2. Go-Back -N ARQ
➔ Frames from a sending station are numbered sequentially. If the header of the
frame allows m bits for the sequence number, the sequence numbers range
from 0 to 2m - 1.
➔ The sliding window is an abstract concept that defines the range of sequence
numbers that is the concern of the sender and receiver.
➔ The range which is the concern of the sender is called the send sliding window;
➔ the range that is the concern of the receiver is called the receive sliding window.
➔ The size of the send window must be less than 2m; the size of the receiver
window is always 1.
➔ The receive window makes sure that the correct data frames are received and
that the correct acknowledgments are sent.
In Selective Repeat ARQ, the size of the sender and receiver window must be at
most one-half of 2m.
Those slots inside the window that are coloured define frames that have arrived
out of order and are waiting for their neighbours to arrive before delivery to the
network layer.
Figure: Send window for Selective Repeat ARQ
Figure:Receive window for Selective Repeat ARQ
Media Access Protocols
Introduction:
Data Link Layer - LLC & MAC sublayers
➔ The upper sublayer that is responsible for flow and error control is called the
logical link control (LLC) layer.
➔ The lower sublayer that is mostly responsible for multiple access resolution is
called the media access control (MAC) layer.
➔ When nodes or stations are connected and use a common link, called a
multipoint or broadcast link, we need a multiple-access protocol to
coordinate access to the link.
➔ Many protocols have been devised to handle access to a shared link.
➔ All of these protocols belong to a sublayer in the data-link layer called media
access control (MAC).
➔ We categorize them into three groups,
RANDOM ACCESS
Random Access /Contention Protocols
Features:
➔ Random access:There is no scheduled time for a station to transmit.
Transmission is random among the stations.
➔ Contention methods:no rules specify which station should send next. Stations
compete with one another to access the medium.
➔ No station is superior to another station and none is assigned control over another.
➔ At each instance, a station that has data to send uses a procedure defined by the
protocol to make a decision on whether or not to send.
➔ This decision depends on the state of the medium (idle or busy).
➔ if more than one station tries to send, there is an access conflict—collision—and
the frames will be either destroyed or modified.
➔ The random-access methods have evolved from protocol known as ALOHA,
which used a very simple procedure called multiple access (MA).
➔ The method was improved with the addition of a procedure that forces the
station to sense the medium before transmitting. This was called carrier
sense multiple access (CSMA).
1. A collision involves two or more stations. If all these stations try to resend
their frames after the time-out, the frames will collide again.
Pure ALOHA dictates that when the time-out period passes, each station
waits a random amount of time before resending its frame. The randomness
will help avoid more collisions. This time known as backoff time TB.
➔ The backoff time TB is a random value that normally depends on K (the number of
attempted unsuccessful transmissions).
or
Vulnerable time: The length of time in which there is a possibility of collision.
➔ We assume that the stations send fixed-length frames with each frame taking Tfr
seconds to send.
➔ Figure shows the vulnerable time for station B.
Station B starts to send a frame at
time t. Now imagine station A has
started to send its frame after t − Tfr.
This leads to a collision between the
frames from station B and station A.
On the other hand, suppose that
station C starts to send a frame
before time t + Tfr. Here, there is also
a collision between frames from
station B and station C.
The vulnerable time during which a
collision may occur in pure ALOHA is
Pure ALOHA vulnerable time = 2 x Tfr 2 times the frame transmission time.
Throughput: the average number of successfully transmitted frames
➔ Let us call G the average number of frames generated by the system during one frame
transmission time.
➔ In other words, if one-half a frame is generated during one frame transmission time (one frame
during two frame transmission times), then 18.4 percent of these frames reach their destination
successfully.
➔ We expect G = 1/2 to produce the maximum throughput because the vulnerable time is 2 times
the frame transmission time. Therefore, if a station generates only one frame in this vulnerable
time (and no other stations generate a frame during this time), the frame will reach its destination
successfully.
1.b. Slotted ALOHA
➔ invented to improve the efficiency of pure ALOHA.
➔ In slotted ALOHA we divide the time into slots of Tfr seconds and force the
station to send only at the beginning of the time slot.
Vulnerable time:
➔ Because a station is allowed to send only at the beginning of the synchronized
time slot, if a station misses this moment, it must wait until the beginning of the
next time slot.
➔ This means that the station which started at the beginning of this slot has already
finished sending its frame.
➔ There is still the possibility of collision if two stations try to send at the beginning
of the same time slot. However, the vulnerable time is now reduced to one-half,
equal to Tfr.
Throughput:
➔ In other words, if one frame is generated during one frame transmission time, then
36.8 percent of these frames reach their destination successfully. We expect G = 1 to
produce maximum throughput because the vulnerable time is equal to the frame
transmission time. Therefore, if a station generates only one frame in this vulnerable
time (and no other station generates a frame during this time), the frame will reach
its destination successfully.
2. CSMA
1. 1-persistent method
2. non-persistent method
3. p-persistent method.
1-Persistent
➔ The 1-persistent method is simple and straightforward.
➔ If the line is idle, it sends its frame immediately (with probability 1).
➔ otherwise it continuously keeps on checking the medium for being idle.
➔ This method has the highest chance of collision because two or more stations
may find the line idle and send their frames immediately.
➔ Ethernet uses this method.
Nonpersistent
➔ In the non persistent method, a station that has a frame to send senses the
line.
➔ If the line is idle, it sends immediately.
➔ If the line is not idle, it waits a random amount of time and then senses the
line again.
➔ Reduces the chance of collision because it is unlikely that two or more
stations will wait the same amount of time and retry to send simultaneously.
➔ However, this method reduces the efficiency of the network because the
medium remains idle when there may be stations with frames to send.
p-Persistent
➔ The p-persistent method is used if the channel has time slots with a slot duration
equal to or greater than the maximum propagation time.
➔ The p-persistent approach combines the advantages of the other two
strategies. It reduces the chance of collision and improves efficiency.
➔ In this method, after the station finds the line idle it follows these steps:
2. With probability q = 1 − p, the station waits for the beginning of the next
time slot and checks the line again.
b. If the line is busy, it acts as though a collision has occurred and uses
the back-off procedure.
3. CSMA/CD
➔ Carrier sense multiple access with collision detection (CSMA/CD)
➔ In this method, a station monitors the medium after it sends a frame to see if
the transmission was successful. If so, the station is finished. If, however,
there is a collision, the frame is sent again.
➔ At time t1, station A has executed its persistence procedure and starts
sending the bits of its frame.
➔ At time t2, station C has not yet sensed the first bit sent by A. Station C
executes its persistence procedure and starts sending the bits in its frame,
which propagate both to the left and to the right.
➔ The collision occurs some- time after time t2.
➔ Station C detects a collision at time t3 when it receives the first bit of A’s
frame.
➔ Station C immediately (or after a short time, but we assume immediately)
aborts transmission.
➔ Station A detects collision at time t4 when it receives the first bit of C’s frame;
it also immediately aborts transmission.
➔ A transmits for the duration t4 − t1; C transmits for the duration t3 − t2.
Minimum Frame Size:
➔ we need a restriction on the frame size.
➔ Before sending the last bit of the frame, the sending station must
detect a collision, if any, and abort the transmission. This is so
because the station, once the entire frame is sent, does not keep a
copy of the frame and does not monitor the line for collision detection.
➔ Therefore, the frame transmission time Tfr must be at least two times
the maximum propagation time Tp.
➔ To understand the reason, let us think about the worst-case scenario.
If the two stations involved in a collision are the maximum distance
apart, the signal from the first takes time Tp to reach the second, and
the effect of the collision takes another time TP to reach the first. So
the requirement is that the first station must still be transmitting
ALOHA vs CSMA/CD
1. The persistence process. We need to sense the channel before we start sending the
frame by using one of the persistence processes (nonpersistent, 1-persistent, or p-
persistent).
2. The frame transmission. In ALOHA, we first transmit the entire frame and then wait
for an acknowledgment. In CSMA/CD, transmission and collision detection are
continuous processes. We do not send the entire frame and then look for a collision.
The station transmits and receives continuously and simultaneously (using two
different ports or a bidirectional port). We use a loop to show that transmission is a
continuous process. We constantly monitor in order to detect one of two conditions:
either transmission is finished or a collision is detected. Either event stops
transmission. When we come out of the loop, if a collision has not been detected, it
means that transmission is complete; the entire frame is transmitted. Otherwise, a
collision has occurred.
Energy Level: The level of energy in a channel can have three values:
◆ At the zero level, the channel is idle.
◆ At the normal level, a station has successfully captured the channel
and is sending its frame.
◆ At the abnormal level, there is a collision and the level of the energy
is twice the normal level.
A station that has a frame to send or is sending a frame needs to monitor the
energy level to determine if the channel is idle, busy, or in collision mode.
Throughput:
➔ The throughput of CSMA/CD is greater than that of pure or slotted ALOHA.
➔ The maximum throughput occurs at a different value of G and is based on the
persistence method and the value of p in the p-persistent approach.
➔ For the 1-persistent method, the maximum throughput is around 50 percent
when G = 1.
➔ For the non persistent method,the maximum throughput can go up to 90
percent when G is between 3 and 8.
Traditional Ethernet
➔ One of the LAN protocols that used CSMA/CD is the traditional Ethernet with
the data rate of 10 Mbps. the traditional Ethernet was a broadcast LAN that
used the 1-persistence method to control access to the common media.
3. CSMA/CA:Carrier sense multiple access with collision avoidance
➔ Specially designed for wireless networks
➔ Collisions are avoided through the use of CSMA/CA’s three strategies:
◆ the interframe space,
◆ the contention window,
◆ Acknowledgments.
1. Interframe space
• Station waits for medium to become idle and if found idle it does not immediately send data (to avoid
collision due to propagation delay) rather it waits for a period of time called Interframe space or IFS.
After this time it again checks the medium for being idle. The IFS can also be used to define the priority
of a station or frame.
2. Contention Window
• It is the amount of time divided into slots. If the sender is ready to send data, it chooses a random
number of slots (according to binary back-off strategy)as wait time which doubles every time medium is
not found idle .
• If the medium is found busy it does not restart the entire process, rather it restarts the timer when the
channel is found idle again.
3. Acknowledgement
• The sender re-transmits the data if acknowledgement is not received before time-out.
CONTROLLED ACCESS
● In controlled access, the stations consult one another to find which station has
the right to send.
● A station cannot send unless it has been authorized by other stations.
● The three popular controlled-access methods are as follows.
1. Reservation
2. Polling
3. Token Passing
Reservation
● In the reservation method, a station needs to make a reservation before
sending data.
● Time is divided into intervals. In each interval, a reservation frame precedes
the data frames sent in that interval.
● If there are N stations in the system, there are exactly N reservation minislots
in the reservation frame.
● Each minislot belongs to a station. When a station needs to send a data
frame, it makes a reservation in its own minislot.
● The stations that have made reservations can send their data frames after
the reservation frame.
● The following figure shows a situation with five stations and a five-minislot
reservation frame. In the first interval, only stations 1, 3, and 4 have made
reservations. In the second interval, only station 1 has made a reservation.
Polling
● Polling works with topologies in which one device is designated as a primary
station and the other devices are secondary stations.
● All data exchanges must be made through the primary device even when the
ultimate destination is a secondary device.
● The primary device controls the link; the secondary devices follow its instructions.
● It is up to the primary device to determine which device is allowed to use the
channel at a given time.
● The primary device, therefore, is always the initiator of a session.
● If the primary wants to receive data, it asks the secondaries if they have anything
to send, this is called poll function.
● If the primary wants to send data, it tells the secondary to get ready to receive; this
is called select function.
Polling - select
● The select function is used whenever the primary device has something to
send.
● If it has something to send, the primary device sends it.It has to know whether
the target device is prepared to receive or not.
● So the primary must alert the secondary to the upcoming transmission and
wait for an acknowledgment of the secondary's ready status.
● Before sending data, the primary creates and transmits a select (SEL) frame,
one field of which includes the address of the intended secondary.
Polling - poll
● The poll function is used by the primary device to solicit transmissions from
the secondary devices.
● When the primary is ready to receive data, it must ask (poll) each device in
turn if it has anything to send.
● When the first secondary is approached, it responds either with a NAK frame
if it has nothing to send or with data (in the form of a data frame) if it does.
● If the response is negative (a NAK frame), then the primary polls the next
secondary in the same manner until it finds one with data to send.
● When the response is positive (a data frame), the primary reads the frame
and returns an acknowledgment (ACK frame), verifying its receipt.
Token Passing
● In the token-passing method, the stations in a network are organized in a
logical ring.
● In other words, for each station, there is a predecessor and a successor.
● The predecessor is the station which is logically before the station in the ring;
the successor is the station which is after the station in the ring.
● The current station is the one that is accessing the channel now.
● The right to this access has been passed from the predecessor to the current
station.
● The right will be passed to the successor when the current station has no
more data to send.
● In this method, a special packet called a token circulates through the ring.
● The possession of the token gives the station the right to access the channel
and send its data.
● When a station has some data to send, it waits until it receives the token
from its predecessor.
● It then holds the token and sends its data.
● When the station has no more data to send, it releases the token, passing it
to the next logical station in the ring.
● The station cannot send data until it receives the token again in the next
round.
● Token management is needed for this access method.
○ Stations must be limited in the time they can have possession of the token.
○ The token must be monitored to ensure it has not been lost or destroyed.
○ To make low-priority stations release the token to high priority stations.