Professional Documents
Culture Documents
2.1 Data Link Layer 2.2 Error Detection 2.3 Error Correction 2.4 Flow Control
2.1 Data Link Layer 2.2 Error Detection 2.3 Error Correction 2.4 Flow Control
5-3
LINK LAYER SERVICES
Framing, link access:
encapsulate datagram into frame, adding header, trailer
channel access if shared medium
“MAC” addresses used in frame headers to identify source,
destination
different from IP address!
Reliable delivery between adjacent nodes
seldom used on low bit error link (fiber, some twisted pair)
wireless links: high error rates
5-4
LINK LAYER SERVICES
Flow Control:
pacing between adjacent sending and receiving nodes
Error Detection:
errors caused by signal attenuation, noise.
receiver detects presence of errors:
signals sender for retransmission or drops frame
Error Correction:
receiver identifies and corrects bit error(s) without resorting to
retransmission
Half-duplex and full-duplex
with half duplex, nodes at both ends of link can transmit, but not
at same time 5-5
ADAPTORS COMMUNICATING
datagram
link layer protocol rcving
sending node
node
frame frame
adapter adapter
5-8
PARITY CHECKING
Two Dimensional Bit Parity:
Single Bit Parity: Detect and correct single bit errors
Detect single bit errors
0 0
5-9
INTERNET CHECKSUM
Goal: detect “errors” (e.g., flipped bits) in transmitted segment
(note: used at transport layer only)
Sender: Receiver:
treat segment contents as compute checksum of received
sequence of 16-bit integers segment
checksum: addition (1’s
check if computed checksum
complement sum) of equals checksum field value:
NO - error detected
segment contents
YES - no error detected. But
sender puts checksum
maybe errors nonetheless.
value into checksum field
CYCLIC REDUNDANCY CHECK
view data bits, D, as a binary number
choose r+1 bit pattern (generator), G
goal: choose r CRC bits, R, such that
<D,R> exactly divisible by G (modulo 2)
receiver knows G, divides <D,R> by G. If non-zero remainder: error
detected!
can detect all burst errors less than r+1 bits
5-11
CRC EXAMPLE
Want:
D.2r XOR R = nG
equivalently: R = remainder[ D] .2r
G
D.2r = nG XOR R
equivalently:
if we divide D.2r by G,
want remainder R
5-12
EXAMPLE
Generator = 1001
Message = 101110
The resulting 4 bit number reveals the bit position of the error.
(0111 => bit position 7)
In this example using an (11, 7) Hamming code, with a
minimum distance of 3, this code can correct all single bit error
FLOW 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.
Flow control is one of the most important duties of the data link layer.
The sender keeps a copy of the sent frame and starts a timer.
If the timer expires and there is no ACK for the sent frame, the
frame is resent.
An ACK frame can also be corrupted and lost.
The ACK numbers tell the sequence number of the next frame
expected by the receiver.
If frame 0 has arrived without error, the receiver sends an ACK
1.
If frame 1 has arrived without error, the receiver sends an ACK
0.
Sender
Sn = 0; // Frame 0 should be sent first
canSend = true; // Allow the first request to go
while (true)
{
WaitForEvent();
if (Event (RequestToSend) AND canSend)
{
GetData () ;
MakeFrame (Sn) ; //The seqNo is Sn
StoreFrame(Sn); // keep copy
SendFrame(Sn) ;
StartTimer();
Sn = Sn + 1;
canSend = false;
}
WaitForEvent();
if (Event (ArrivaINotification) //An ACK has arrived
{
ReceiveFrame(ackNo); //Receive the ACK frame Sn
if(not corrupted AND ackNo==Sn) //Valid ACK
{
Stoptime();
PurgeFrame(Sn-l); //Copy is not needed
canSend = true;
}
}
if (Event (TimeOut)) // The timer expired
{
StartTimer();
ResendFrame(Sn-l); //Resend a copy check
}
}
Receiver
Rn = 0; // Frame 0 expected to arrive first
while (true)
{WaitForEvent(); // Sleep until an event occurs
if(Event(Arriva1Notification)) //Data frame arrives
{ReceiveFrame();
if(corrupted(frame))
sleep();
if (seqNo == Rn) //Valid data frame
{ExtractData();
De1iverData(); //Deliver data
Rn = Rn + 1;}
SendFrame (Rn) ; //Send an ACK
} }
EFFICIENCY
The Stop-and-Wait ARQ is very inefficient if our channel
is having large bandwidth and longer round-trip delay.
The product of these two is called the bandwidth delay
product.
We can think of the channel as a pipe.