Professional Documents
Culture Documents
C N D C Notes.03
C N D C Notes.03
Chapter 03
(version April 23, 2007)
01 02 03 04 05 06 07 08
Introduction Physical Layer Data Link Layer MAC Sublayer Network Layer Transport Layer Application Layer Network Security
00 1
Design Issues
Provide well-dened interface to network layer Handle transmission errors Regulate ow of data: get sender and receiver in the same pace
Payload field
Trailer
03 2
Basic Services
Network layer passes a number of bits (frame) to the data link layer. Data link layer is responsible for transmitting the frame to the destination machine. Receiving layer passes received frame to its network layer. Basic services commonly provided: unacknowledged connectionless service (LANs) acknowledged connectionless service (Wireless systems). acknowledged connection-oriented service (WANs). Question: Why are we so concerned about errorfree frame transmissions? Cant the higher layers take care of that?
03 3 Data Link Layer/3.1 Design Issues
2 1
2 1
2 1
(a)
(b)
Router
Routing process
03 4
Frames
The physical layer doesnt do much: it just pumps bits from one end to the other. But things may go wrong the data link layer needs a means to do retransmissions. The unit of retransmission is a frame (which is just a xed number of bits). Problem: How can we break up a bit stream into frames? Counting wont do:
Character count One character
(a) 5
3 4
Frame 1 5 characters
Frame 3 8 characters
Frame 4 8 characters
(b) 5
4 5
Frame 1
Frame 2 (Wrong)
03 5
FLAG Header
Trailer FLAG
ESC
ESC
ESC
ESC
FLAG
ESC
ESC
ESC
FLAG
ESC
ESC
ESC
ESC
ESC
ESC
(b)
03 6
frame to send frame transmitted over the wire frame after removing stuffed bits
Question: Would this also work with other ag bytes, say 01010101?
03 7
03 9
1 2 4 8
Conclusion: check bit at position 2, is used to even out the bits for positions 2, 3, 6, 7, 10, and 11, so that 1100001 is encoded as (check bits in boldface/blue):
b1 X b2 X b3 X X b4 b5 X X 1 b6 X X 0 b7 X X X 0 b8 b9 X b10 X X 1 X 0 X 0 b11 X X X 1
1 2 4 8
X 1 0 1 1
03 10
1 2 4 8 C: S: R: F:
X 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1
S: string sent R: string received C: string corrected on the check bits: #1 and #8 corrected bit #9 is wrong F: nal result after correction
03 11 Data Link Layer/3.2 Error Control
03 12
Example: a = 01011 a(x) = 0 x0 + 1 x1 + 0 x2 + 1 x3 + 1 x4 = x + x3 + x4 g(x) = 1 + x2 + x3 a(x) g(x) = (x + x3 + x4)(1 + x2 + x3 ) = x + 2x3 + 2x4 + x5 + 2x6 + x7 = x + x5 + x7
03 13
03 14
Some basic assumptions: We have a machine A that wants to send data to machine B There is always enough data for A to send There is a well-dened interface to the network layer, and to the physical layer The receiver generally waits for an event to happen by calling wait for event
03 15
typedef struct { frame_kind kind; seq_nr seq; seq_nr ack; packet info; } frame;
typedef enum {frame_arrival} event_type; void sender1(void){ frame s; packet buffer; while (true) { from_network_layer(&buffer); s.info = buffer; to_physical_layer(&s); } } void receiver1(void){ frame r; event_type event; while (true) { wait_for_event(&event); from_physical_layer(&r); to_network_layer(&r.info); } }
Question: What are some of the underlying assumptions here? How does the ow control manifest itself?
03 16 Data Link Layer/3.3 Basic Protocols
Simplex Stop-and-Wait
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 typedef enum {frame_arrival} event_type; #include "protocol.h" void sender2(void){ frame s; packet buffer; event_type event; while (true) { from_network_layer(&buffer); s.info = buffer; to_physical_layer(&s); wait_for_event(&event); } } void receiver2(void){ frame r, s; event_type event; while (true) { wait_for_event(&event); from_physical_layer(&r); to_network_layer(&r.info); to_physical_layer(&s); } }
03 17
03 19
03 20
03 21
Sliding Windows
Principle: Rather than just sending a single frame at a time, permit the sender to transmit a set of frames, called the sending window. A frame is removed from the sending window iff it has been acknowledged. The receiver has a receiving window containing frames it is permitted to receive. Note: 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 #N-1 has been received. Note: If both window sizes equal one, we are dealing with the stop-and-wait protocols. Question: Is there a relationship between window size, transmission rate, and propagation delay? Note: Sequence numbers can now correspond to the position a frame has in the window. The receiver needs to keep track of the received frames by their sequence number.
03 22 Data Link Layer/3.4 Sliding Window Protocols
a: b: c: d:
Initially. After sending frame #1. After receiving frame #1. After receiving ack for frame #1.
Question: How would you interpret the shaded areas? Important: Note that we can stick to an n-bit sequence number were not going to run out of sequence numbers.
03 23 Data Link Layer/3.4 Sliding Window Protocols
03 24
(a)
Time
(b)
Observation: We are transmitting more than once, just because the two senders are more or less out of sync.
03 25 Data Link Layer/3.4 Sliding Window Protocols
03 26
03 27
03 28
01234567
Solution: we must avoid overlapping send and receive windows the highest sequence number must be at least twice the window size.
03 30 Data Link Layer/3.4 Sliding Window Protocols
03 31
03 32
03 33
The data link layer is responsible for transmitting frames from sender to receiver. It can use only the physical layer, which supports only 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 ow control (windows, frame numbers, etc.)
03 34
Bits
8 01111110
8 Address
8 Control
>0 Data
16 Checksum
8 01111110
Question: What do we need the address eld for? The control eld is used to dinguish different kinds of frames:
HDLC uses a sliding window protocol with 3-bit sequencing the control eld contains sequence numbers, acks, nacks, etc.
03 35
Problem: One way or the other wed like to use the Internet protocol stack at our home. The bottom line is that well have to transfer IP (network) packets across our telephone line. Note: We may also be talking ADSL here! Issue: How can we (1) embed IP packets into frames, that can be (2) unpacked at the other end, to be handed to the network layer?
03 36 Data Link Layer/3.6 Examples
03 37
Name Congure-request Congure-ack Congure-nack Congure-reject Terminate-request Terminate-ack Code-reject Protocol-reject Echo-request Echo-reply Discard-request 03 39
Dir. IR IR IR IR IR IR IR IR IR IR IR
Description Proposed options and values All options are accepted Some options are not accepted Some options are not negotiable Request to shut the line down OK, line shut down Unknown request received Unknown protocol requested Please send this frame back Here is the frame back Just discard this frame (testing) Data Link Layer/3.6 Examples
03 40