Layer 2 Technologies Layer 2: final level of encapsulation of data before transmission over a physical link responsible for reliable transfer of frames between hosts, hop by hop, i.e. on a per link basis Protocol functions at this layer include Flow control: Ensuring the source sending frames does not overflow the receiver Error control: Ensuring all frames are correctly received by the receiver (typically based on cyclic codes) Frame delineation (method to identify the start and end of a frame on a transmission link) Access control (for shared medium operations, such as shared Ethernet, WLAN) 1
Layer 2 Technologies Some layer 2 technologies can operate over a shared physical medium, allowing Communications between multiple hosts without the need for forwarding. These are technologies used in shared LAN applications (shared Ethernet, WLAN) Basic layer 2 technologies are point to point only and rely on encapsulated layer 3 to perform forwarding at layer 3 (e.g. HDLC, PPP,..) Some layer 2 technologies use Virtual Circuit operations to allow forwarding at layer 2. Examples are in WAN networking (Frame Relay, ATM,..) and to some extent in LAN applications (Switched Ethernet) 2
Flow Control: Stop and Wait Most basic flow control mechanism: Source transmits frame Destination receives frame and replies with frame confirming reception, called Acknowledgement (ACK) Source waits for ACK before sending next frame Destination can stop flow by not sending ACK Source uses time-out to resend frame if no ACK is received (source assumes frame is lost) Receiver may get two copies of same frame! Use ACK,0 and ACK,1 (1 bit sequence nr) Link is not used while transmitter waits for acknowledgement If link bit rate high, and/or packets small, and /or long link, transmission time smaller than propagation time => under utilization of link 3
Stop and Wait Time 4
Sliding Window Flow Control Allow multiple frames to be in transit Receiver has buffer W long Transmitter can send up to W frames without having to wait for an Acknowledgment (ACK) Only W frames can be unacknowledged at any given time Each frame is numbered (Sequence Number) Sequence number bounded by size of Sequence Number field (k bits) Frames are numbered modulo 2 k and numbers are used in a cyclical fashion. ACK includes number of next frame expected Piggybacking, in duplex connections include acknowledgement info as Protocol Control Information with the data, If no data to send, use dedicated acknowledgement frame If data but no acknowledgement to send, send last acknowledgement number again 5
Sliding Window Diagram k=3 bits (Seq. Nr = 0 to 7) W = 7 6
Example Sliding Window Frame 0 Frame 2 Frame 1 Ack 3 Frame 3 Frame 4 Frame 5 Ack 4 Frame 6 7
Error Control For the Detection (and correction in some cases) of errors, an error detection/correction field added to message If correction capability is used, mechanism is called Forward Error Correction If only detection capability, retransmission of the message is requested. The mechanism is called: ARQ - Automatic Repeat request Practically, Flow Control and Error Control operate jointly: Error detection: Negative acknowledgement and retransmission No error: Positive acknowledgment No acknowledgment: Retransmission after timeout 2 slightly different Sliding Window mechanisms posible Go Back N and Selective Repeat 8
Go Back-N Based on sliding window: window size controls number of outstanding frames If no error, ACK as usual with number of next frame expected (also called RR, Receive Ready) If error, reply with rejection (called REJ) Discard that frame and all future frames until error frame received correctly. Transmitter must go back and retransmit that frame and all subsequent frames Receiver detects error in frame i Receiver sends REJ-i Source gets REJ-i Source retransmits frame i and all subsequent frames 9
Selective Repeat Also called Selective Reject Only rejected frames (SREJ sent by receiver) are retransmitted Subsequent frames are accepted by the receiver and buffered => Minimizes retransmission Receiver must maintain large enough buffer Receiver must reorder frames after reception of missing ones More complex logic in source to re-send frame out of sequence 10
Go Back N vs Selective Repeat Ack 2 Ack 2 Ack 4 Ack 4 Ack 5 Ack 7 Ack 7 Go Back N Ack 1 Selective Repeat 11
Maximum window size Go Back-N Maximum window size should be set as 2 k -1 Ex. K=3, window = 8: source sends frame 0,1,2,3,4,5,6,7. Receiver sends ACK 0 (receiver to accept 8 frames starting with number 0). If acknowledgement lost, sender times out and retransmits 0,1,2,3,4,5,6,7. Receiver accepts these as new frames, although they are duplicates. If we take window = 7: source sends frame 0,1,2,3,4,5,6. Receiver sends ACK 7 (receiver to accept 7 frames starting with number 7). If acknowledgement lost, sender times out and retransmits 0,1,2,3,4,5,6. Receiver rejects these frames as it expects frame 7 first, so there are no duplicated frames. 12
Maximum window size Selective Reject Maximum window size should be set as 2 k-1 Ex. K=3, window = 5. source sends frame 0,1,2,3,4. Receiver sends ACK 5 (receiver will accept frames 5,6,7,0,1 in any order). If acknowledgement lost, sender times out and retransmits 0,1,2,3,4. Receiver accepts duplicated frames 0 and 1 as new frames received out of order. Same with window = 4 (2 k-1 ): source sends frame 0,1,2,3. Receiver sends ACK 4 (receiver to accept frames 4,5,6,7). If acknowledgement lost, sender times out and retransmits 0,1,2,3. Receiver does not accept these duplicated frames as numbers don t overlap. 13
High Level Data Link Control HDLC: ISO 13239 largely used, and basis for several other important protocols Modes of operation Asynchronous Balanced Mode (ABM) most widely used Balanced configuration: either station may initiate transmission without receiving permission Unbalanced configurations: primary sends commands to secondary that can only send responses to commands. Asynchronous Response Mode (ARM), rarely used Normal Response Mode (NRM): primary equipment polling multiple terminals 14
Frame Structure 1 byte 1 to n bytes 1 or 2 bytes 2 (4) bytes 1 byte Flag Address Control Payload FCS Flag Single frame format for all data and control exchanges Control field identifies the type of frame Flags: Delineation - Delimit frame at both ends with sequence : 01111110 Payload: encapsulated upper layer data to be carried FCS: Frame Check Sequence (Error detection); 2 or 4 bytes. Address: Usually 8 bits long 15
Control Field N(s): send sequence number N(r): receive sequence number S: Supervisory function M: Unnumbered function 1 2 3 4 5 6 7 8 I: Information 0 N(s) N(r) S: Supervisory 1 0 S N(r) 3 bits sequence number U: Unnumbered 1 1 M M 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I: Information 0 N(s) N(r) S: Supervisory 1 0 S N(r) 7 bits sequence number 16
Control Field Different for different frame type Information - data to be transmitted to user (next layer up) Flow and error control piggybacked on information frames Supervisory - ARQ when piggyback not used Field S to identify REJ for GoBack-N, SREJ for selective reject,.. Unnumbered - supplementary link control: Field M to identify connection set up, disconnection,. First one or two bits of control field identify frame type 3 or 7 bits (extended mode) sequence numbers (specified during connection set up) 17
Point to Point Protocol (PPP) Encapsulation of packets (i.e. Layer 3 PDUs, e.g. IP) for transmission over point to point links (RFCs 1661 & 1662) Used e.g. over dial up modem links Allows multiplexing of different Layer 3 protocols over a serial link Based on HDLC, with following changes: A protocol field is added to identify the upper layer protocol encapsulated in the frame. PPP does not assign individual station addresses; the address field is by default set to 11111111 (Broadcast). Control field is fixed and set by default to Unnumbered information type of frame (see HDLC) Flag Address Control Protocol Data FCS Flag 8 bits 8 bits 8 bits 16 bits Variable 16 (32) bits 8 bits 18
Point to Point Protocol (PPP) Connections are not set up with Unnumbered frames. specific LCP (Link Control Protocol) packets are used. LCP packets are encapsulated in PPP frames (protocol field Hex C021) for: establishment and termination of a link configuration of a link (e.g. payload size) test of a link Specific NCP (Network Control Protocol) packets are then used to choose and configure the network layer protocols to be transmitted. NCP packets are encapsulated in PPP frames IPCP is used to negotiate IP parameters (e.g. IP address of device) PPP frames can then carry over the link various agreed network layer protocols data units 19