Data Link Layer: Paolo Costa Costa@cs - Vu.nl
Data Link Layer: Paolo Costa Costa@cs - Vu.nl
Note
We’ll just concentrate on transmission issues. Channel access is
(Version May 9, 2008) discussed in Chapter 4
Paolo Costa 03 - Data Link Layer 1 / 55 Paolo Costa 03 - Data Link Layer Introduction 2 / 55
Question
1 Provide well-defined interface to network layer Why are we so concerned about error-free frame transmissions?
2 Handle transmission errors Can’t the higher layers take care of that?
It’s not mandatory but it may improve efficiency (fine-grained
3 Regulate flow of data: get sender and receiver in the same pace
recovery: frames vs. messages)
Paolo Costa 03 - Data Link Layer Design Issues 3 / 55 Paolo Costa 03 - Data Link Layer Design Issues 4 / 55
Transmission Routing
Frames Frames
Counting Byte Stuffing
The physical layer doesn’t do much: it just pumps bits from one Byte stuffing: Mark the beginning and end of a byte frame with two
end to the other. special flag bytes – a special bit sequence (e.g. 01111110). If
But things may go wrong such bytes appear in the original frame, escape them:
⇒ the data link layer needs a means to do retransmissions.
The unit of retransmission is a frame (which is just a fixed number
of bits).
Problem: How can we break up a bit stream into frames?
naive solution: counting
1 0 0 0 1 0 0 1
1 0 1 1 0 0 0 1 ⊕ ←− XOR
0 0 1 1 1 0 0 0
To detect d errors, you need a distance d + 1 code
d-single bit errors cannot change a valid codeword in another
To correct d errors, you need a distance 2d+1 code
(a) frame to send (b) frame transmitted over the wire (c) reconstructed frame this way, even with 2d changes, the original codeword is still closer
that any other codeword
Paolo Costa 03 - Data Link Layer Design Issues 9 / 55 Paolo Costa 03 - Data Link Layer Error Control 10 / 55
We can detect a single error (i.e., k = 1 and d = 2) E.g., if the codeword 0000000111 is received, the receiver knows
remember that to detect d errors, you need a distance d+1 code that the original must have been 0000011111
If, however, a triple error changes 0000000000 into 0000000111,
the error will not be corrected properly
Paolo Costa 03 - Data Link Layer Error Control 11 / 55 Paolo Costa 03 - Data Link Layer Error Control 12 / 55
Error Correction Error Correction: Hamming
Lower Bound Definition
Paolo Costa 03 - Data Link Layer Error Control 13 / 55 Paolo Costa 03 - Data Link Layer Error Control 14 / 55
(x 3 + x) + (x + 1) = x 3 + 2x + 1 ≡ x 3 + 1 (x 2 + x)(x + 1) = x 3 + x 2 + x 2 + 1 = x 3 + 2x 2 + 1 ≡ x 3 + 1
note that 2x becomes zero because addition of coefficient is done Division
modulo 2 we can also divide polynomials mod 2 and find the quotient and
2x = x + x = (1 + 1)x = 0x = 0 remainder
analogous to exclusive OR (XOR) x3 + x2 + x 1
= (x 2 + 1) −
x +1 x −1
1010 ⊕ 0011 → 1001
or in other words:
Subtraction
works like addition (only absolute values are used) (x 3 + x 2 + x) = (x 2 + 1)(x + 1) − 1
(x 4 + x 2 + 1) − (x + 1) = x 4 + x 2 − x ≡ x 4 + x 2 + x
Paolo Costa 03 - Data Link Layer Error Control 19 / 55 Paolo Costa 03 - Data Link Layer Error Control 20 / 55
CRC CRC
Algorithm Division Example
CRC CRC
Decoding Burst Error
Simplex Protocol for Noisy Channel Simplex Protocol for Noisy Channel
Sender Receiver
next_frame_to_send indicates which is the last message sent frame_expected enables filtering out duplicate
A timer is started after sending a message Its value is increased each time a frame is delivered to the
Only if the correct ack is received, the next message is sent
network layer
1 #define MAX_SEQ 1 ⇒ only two values (0 and 1) are needed
2 typedef enum {frame_arrival, cksum_err, timeout} event_type;
3 void sender3(void) { 1 void receiver3(void) {
4 int next_frame_to_send; 2
5 frame s; 3 seq_nr frame_expected; frame r, s; event_type event;
6 packet buffer; 4
7 event_type event; 5 frame_expected = 0;
8 6 while (true) {
9 next_frame_to_send = 0; 7
10 from_network_layer(&buffer); 8 wait_for_event(&event);
11 while (true) { 9 if(event == frame_arrival) {
12 s.info = buffer; 10
13 s.seq = next_frame_to_send; 11 from_physical_layer(&r);
14 to_physical_layer(&s); 12 if (r.seq == frame_expected) {
15 start_timer(s.seq); 13
16 wait_for_event(&event); 14 to_network_layer(&r.info);
17 15 inc(frame_expected);
18 if (event == frame_arrival) { 16 }
19 from_physical_layer(&s); 17 s.ack = 1 - frame_expected;
20 if (s.ack == next_frame_to_send) { 18 to_physical_layer(&s);
21 stop_timer(s.ack); 19 }
22 from_network_layer(&buffer); 20 }
23 inc(next_frame_to_send); 21 }
24 } } } }
Paolo Costa 03 - Data Link Layer Basic Protocols 31 / 55 Paolo Costa 03 - Data Link Layer Basic Protocols 32 / 55
From Simplex to Duplex Sliding Windows
Problem: We want to allow symmetric frame transmission Principle: Rather than just sending a single frame at a time, permit
between two communicating parties, rather than transmission in the sender to transmit a set of frames, called the sending window.
one direction. a frame is removed from the sending window iff it has been
don’t waste channels, so use the same channel for duplex acknowledged.
communication. the receiver has a receiving window containing frames it is
Solution: Just transmit frames, but distinguish between data, permitted to receive.
acknowledgments (acks), and possibly negative acks (nacks) in A damaged frame is kept in the receiving window until a correct
version is received. Also, frame N is kept in the window until frame
the frame’s type field.
N-1 has been received.
Idea: If the other party is going to send data as well, it might as if both window sizes equal one, we are dealing with the
well send acknowledgments along with its data frames stop-and-wait protocols.
⇒ piggybacking.
Question
Question Is there a relationship between window size, transmission rate, and
What’s good and bad about piggybacking? propagation delay ? If the propagation delay is high and the window size
Good: save bandwidth. is small, transmission rate decreases dramatically because the sender
Bad: poor performance with irregular transmission rate. while waiting for acks cannot send new messages
Paolo Costa 03 - Data Link Layer Basic Protocols 33 / 55 Paolo Costa 03 - Data Link Layer Sliding Window Protocols 34 / 55
Paolo Costa 03 - Data Link Layer Sliding Window Protocols 35 / 55 Paolo Costa 03 - Data Link Layer Sliding Window Protocols 36 / 55
1-Bit Sliding Window Error Control
Simultaneous Transmissions
Paolo Costa 03 - Data Link Layer Sliding Window Protocols 45 / 55 Paolo Costa 03 - Data Link Layer Sliding Window Protocols 46 / 55
Now let’s take a look how point-to-point connections are supported in,
for example, the Internet.
Recall:
The data link layer is responsible for transmitting frames from
sender to receiver.
http://www.csi.uottawa.ca/~elsaddik/abedweb/applets/ It can use only the physical layer, which supports only
Applets/Sliding_Window/sliding-window/index.html transmission of a bit at a time.
The DLL has to take into account that transmission errors may
occur
⇒ error control (ACKs, NACKs, checksums, etc.)
The DLL has to take into account that sender and receiver may
operate at different speeds
⇒ flow control (windows, frame numbers, etc.)
Paolo Costa 03 - Data Link Layer Sliding Window Protocols 49 / 55 Paolo Costa 03 - Data Link Layer Examples 50 / 55
PPP
Example
Question
If an IP address is dynamically assigned, who does the assignment ? The
provider
Question
If an IP address is dynamically assigned, Can someone else ever send you data
(they don’t know your address, do they?) We need to contact them first (our
address is included in the request).