Module III
Module III
2.1 Framing:
Framing in the data link layer separates a message from one source to a destination by adding a
sender address & a destination address. The destination address defines where the packet is to
go; the sender address helps the recipient acknowledge the receipt. Although the whole message
could be packed in one frame, that is not normally done. One reason is that a frame can be very
large, making flow & error control very inefficient. When a message is carried in one very large
frame, even a single-bit error would require the retransmission of the whole message. When a
message is divided into smaller frames, a single-bit error affects only that small frame.
i) Fixed-size framing:
In this there is no need for defining the boundaries of the frames, the size itself can be used as a
delimiter.
Ex: ATM wide area network which uses frames of fixed size called cells.
In this, we need a way to define the end of the frame and the beginning of the next.
Ex: LAN
Historically 2 approaches were used for variable size framing: Character-oriented & bit-oriented.
a) Character-oriented approach:
Stuffed
Frame sent
Fla Header ESC Flag ESC ESC Trailer Flag
g
Extra 2 bytes
Frame received
Fla Header ESC Flag ESC ESC Trailer Flag
g
Unstuffed
Flag ESC
b) Bit-oriented approach:
Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the
data, so that the receiver doesn’t mistake the pattern 01111110 for a flag
Unstuffed
0001111111001111101000
Flow Control:
• Any receiving device has a limited speed at which it can process incoming data and a
limited amount of memory in which to store incoming data.
• The flow of data must not be allowed to overwhelm the receiver.
• The receiver must be able to tell the sender to halt transmission until it is once again able
to receive.
• Flow control refers to a set of procedures used to restrict the amount of data that the
sender can send before waiting for acknowledgement.
Error Control:
• Errors occur due to noises in the channel.
• Error control is both error detection & error correction.
• In the data link layer error control refers to methods of error detection and retransmission.
• To sender should add certain amount of redundant bits to the data, based on which the
receiver will be able to detect errors.
2.3 PROTOCOLS:
Protocols
i) Simplest protocol:
Design:
Sender Receiver
Request from
Event: network layer
Notification from
Event: physical layer
Sender Receiver
A B
Request Frame
Arrival
Request
Frame
Arrival
Request Frame
Arrival
Time Time
Design:
Sender Receiver
ACK Frame
Request from
Event:
network layer
A B
Request Frame
Arrival
Arrival ACK
Request Frame
Arrival
Arrival ACK
Time Time
Assumptions are:
Sn Next Rn Next
frame to frame to
send receive
0 1 0 1 0 0 1 0 1 0
Sender Receiver
Data frames
Network Get Deliver Network
data data
seqNo
Data link ACK Frame Data link
Sender-site algorithm:
Receiver-site algorithm:
Flow diagram:
Sender Receiver
Rn
A B
Sn
0 1 0 1 0 Initially
Start Request Frame 0
0 1 0 1 0 Rn
Sn
Stop Arrival
ACK 1 0 1 0 1 0 Arrival
0 1 0 1 0
Sn
Start Request Frame 1
0 1 0 1 0
Timer-out
Sn Lost
restart Timeout Frame 1
0 1 0 1 0 Rn
Sn resent
Stop
ACK 0 0 1 0 1 0 Arrival
Arrival 0 1 0 1 0
Sn
Start Request Frame 0 Rn
0 1 0 1 0
Sn
ACK 1 0 1 0 1 0 Arrival
Timer-out
Timeout Frame 0 Lost
restart 0 1 0 1 0 Rn
Sn
resent
ACK 1 0 1 0 1 0 Arrival
Stop Arrival 0 1 0 1 0 Discard, Duplicate
Time Time
• Bandwidth-Delay product.
• Pipelining.
• Sequence numbers range from 0 to 2m – 1.
• Sliding window is an abstract concept that defines the range of sequence numbers that is
the concern of the Sender & Receiver.
• Timers – timer for the first outstanding frame always expires first, we resend all
outstanding frames when this timer expires.
• Acknowledgement – sends ACK for safe and in order frames, receiver will be silent for
corrupted & out of order frames.
• Resending a frame – when the timer expires, the sender resends all the outstanding
frames.
1 1 1 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 0 1
3 4 5 0 1 2 3 4 5
Sf Sn
1 1 1 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 0 1
3 4 5 0 1 2 3 4 5
a) Receive window
Rn Receive window, next frame expected
13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1 15 0 1
4
Frames already Frames that can’t be received until the
received & window slides
acknowledged
13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1 15 0 1
4
Design:
Sender Receiver
Data frames
Network Get Deliver Network
data data
seqNo
ACK Frame
Data link Data link
Sender-site algorithm:
Sw = 2m – 1;
Sf = 0;
Sn = 0; //Frame 0 should be sent first
While(true) //Repeat forever
{
waitForEvent(); //Sleep until an event occurs
if(event(requestTosend)) //there is a packet to send
{
if(Sn – Sf >= Sw) //If window is full
Sleep();
GetData(); //get data from n/w layer
MakeFrame(Sn); //make a frame
StoreFrame(Sn); //copy of frame
SendFrame(Sn); //send the frame
StartTimer();
Sn = Sn + 1; //Mod-2 addition
if(timer not running); //can’t send until ACK arrives
StartTimer();
}
if(Event(ArrivalNotification)) //an ACK has arrived
{
Receive (ACK); //Receive the ACK frame
if(corrupted (ACK))
Sleep();
if((ackNo > Sf && (ackNo <= Sn)))
While(Sf <= ackNo)
{
Purgeframe(Sn-1);
Sf = Sf + 1;
}
StopTimer();
}
If(Event(Timeout))
{
StartTimer();
Temp = Sf;
While(Temp < Sn)
{
SendFrame(Sf); //sendframe(temp);
Sf = Sf + 1; //temp = temp+1;
}
}
}
Receiver-site algorithm :
Stop-and-Wait ARQ is actually a Go-Back-N ARQ in which there are only two sequence
numbers and the send window size is 1.
i.e., m = 1; 2m – 1 = 1
• In a noisy link frame has a higher probability of damage, means resending of multiple
frames.
• This uses more bandwidth & slows down the transmission.
• Instead of sending N frames when just one frame is damaged, a mechanism is required to
resend only the damaged frame.
• Sequence numbers range from 0 to 2m – 1.
• Both send & receive window size = 2(m – 1).
1 14 1 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 0 1
3 5 Frames that can be received and stored 0 1 2 3 4 5
Frames already for later delivery. Colored boxes, already Frames that
received
received can’t be
Rsize = 2m – 1 received
Design:
Sender Receiver
Data frames
Network Get Deliver Network
data ACK or NAK data
seqNo
Data link Data link
ackNo
or Receive Send
Receiv Send
Physical e frame nakNo frame frame Physical
frame
Event:
Repeat Repeat
Request from forever
Algorithm for forever for
Algorithm
network layer
sender site receiver site
Time
Out
Event:
Sender-site algorithm:
Sw = 2m-1 ;
Sf = 0;
Sn = 0; //Frame 0 should be sent first
While(true) //Repeat forever
{
waitForEvent(); //Sleep until an event occurs
if(event(requestTosend)) //there is a packet to send
{
if(Sn – Sf >= Sw) //If window is full
Sleep();
GetData(); //get data from n/w layer
MakeFrame(Sn); //make a frame
StoreFrame(Sn); //copy of frame
SendFrame(Sn); //send the frame
Sn = Sn + 1;
StartTimer(Sn);
}
if(Event(ArrivalNotification)) //an ACK has arrived
{ Receive (frame); //Receive the ACK frame
if (corrupted (frame))
Sleep();
if (FrameType == NAK)
if (nakNo between Sf & Sn)
{ resend(nakNo);
StartTimer(nakNo);
}
if (FrameType == ACK)
if (ackNo between Sf & Sn)
SJBIT/Dept of ECE Page 27
Computer Communication Networks 06EC71
Receiver-site algorithm :
{ SendACK(Rn);
AckNeeded = false;
NakSent = false; }
}
}
}
}
Piggybacking
• When the data transfer is bidirectional, i.e., from node A to node B and from node B to
node A, the control information also needs to flow in both the directions.
• Efficiency can be improved if the control information can be passed to the other end
along with the data itself which is flowing to that end. This concept is called as
piggybacking.
Flow diagram:
Rn
Initial Sf Sn Sender Receive Initial
r 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 A B
0 Sf Sn
Request Frame 0 Rn
0 1 2 3 4 5 6 7 0 Initial
Sf Sn
ACK 1
0 1 2 3 4 5 6 7
Arrival
Arrival
0 1 2 S3 4 5 6 7 0 Frame 0
1 Sf n
Frame 1 delivered
Request
0 1 2 3 4 5 6 7 0
Sf Sn Lost
2 Request Frame 2 Rn
0 1 2 3 4 5 6 7 0
Sf Sn
3 NAK 1 0 1 2 3 4 5 6 7
Arrival
Request Frame 3
0 1 2 3 4 5 6 7 0 Rn
Sf Sn
Frame 1 0 1 2 3 4 5 6 7 Arrival
1 Arrival 0 1 2 3 4 5 6 7 0 resent Rn
ACK 4
Sf Sn
0 1 2 3 4 5 6 7 Arrival
Arrival 0 1 2 3 4 5 6 7 0 Frames 1, 2, 3
delivered
Time Time
Frame format :
Recommended questions:
Syllabus:
Recommended readings:
3.1 Introduction:
• Data link layer has two sub layers: Upper sub layer – Data link Control & Lower sub
layer – Multiple access Control.
• The upper sub layer is responsible for flow and error control.
• The lower sub layer is responsible for multiple access resolution.
• When the nodes are connected using a dedicated link, lower sub layer is not required, but
when the nodes are connected using a multipoint link (broadcast), multiple access
resolution is required.
i) ALOHA
• The earliest random access method, was developed at the university of Hawaii in early
1970.
• It was designed for a radio (wireless) LAN, but it can be used on any shared medium.
• The medium is shared between the stations. When a station sends data, another station
may attempt to do so at the same time. The data from the two stations collide and become
garbled.
a) PURE ALOHA
• Even if one bit of a frame coexists on the channel with one bit from another frame, there
is a collision and both will be destroyed.
K=0
Wait TB time
(TB = R * Tp or R *
Tfr Send the
frame
Be E
gi B nd
n
Be E
gi A nd
n
Be E
gi C nd
n
t – Tfr t t + Tfr time
Throughput
SJBIT/Dept of ECE Page 35
Computer Communication Networks 06EC71
G = average number of frames generated by the system during one frame transmission time.
b) SLOTTED ALOHA
Collision Collision
duration duration
Be En
gi B d
n
Be En
gi A d
n
Be En
gi C d
n
t – Tfr t t + Tfr time
Throughput
G = average number of frames generated by the system during one frame transmission time.
The chance of collision can be reduced if a station senses the medium before trying to use
it. CSMA requires that each station first listen to the medium before sending. CSMA is
based on the principle “ sense before transmit” or “listen before talk”.
CSMA can reduce the possibility of collision, but it can’t eliminate it. The reason for this
is shown in the above figure, a space and time model of a CSMA network. Stations are
connected to a shared channel. The possibility of collision still exists because of the
propagation delay.
Persistence strategies
The CSMA method does not specify the procedure following the collision. CSMA with
collision detection augments the algorithm to handle the collision.
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.
The basic idea behind CSMA/CD is that a station needs to be able to receive while
transmitting to detect a collision. When there is no collision, the station receives one
signal; its own signal. When there is a collision, the station receives two signals; its own
signal and the signal transmitted by the second station.
Collisions are avoided by deferring transmissions even if the channel is found idle. When
an idle channel is found, the station does not send immediately. It waits for a period of
time called the interframe space or IFS. Even though the channel may appear idle when it
is sensed, a distant station’s signal has not yet reached this station. The IFS time allows
the front of the transmitted signal by the distant station to reach this station.
In controlled access, the stations consult one another to find which station has the right to
send. A station can’t send unless it has been authorized by other stations.
a) Reservation:
In the reservation method, a station needs to make a reservation before sending the data.
Time is divided into intervals. In each interval, a reservation frame precedes the data
frames sent in the interval.
b) 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 select function is used whenever the primary device has something to send. The poll
function is used by the primary device to solicit transmissions from the secondary device.
c) Token Passing:
In the token-passing method, the stations in a network are organized in a logical ring.
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.
3.4 CHANNELIZATION
In FDMA, the bandwidth is divided into channels. Each station is allocated a band to
send its data. Each station also uses a band pass filter to confine the transmitter
frequencies. To prevent station interferences, the allocated bands are separated from one
another by small guard bands.
In TDMA, the stations share the bandwidth of the channel in time. Each station is
allocated a time slot during which it can send data. Each station transmits its data in its
assigned time slot.
CDMA differs from FDMA because only one channel occupies the entire bandwidth of
the link and it differs from TDMA because all stations can send data simultaneously.
Chip sequences
1)
2)
3)
Recommended questions:
Unit 4: Hrs: 07
Syllabus:
IEEE standards, standard Ethernet, changes in the standards, Fast Ethernet, Gigabit
Ethernet, Wireless LAN IEEE 802.11
Recommended readings: