Chapter 5 Peer-To-Peer Protocols and Data Link Layer
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 5 Peer-to-Peer Protocols and Data Link Layer PART I: Peer-to-Peer Protocols Peer-to-Peer Protocols and Service Models ARQ Protocols and Reliable Data Transfer Flow Control Timing Recovery TCP Reliable Stream Service & Flow Control Chapter 5 Peer-to-Peer Protocols and Data Link Layer PART II: Data Link Controls Framing Point-to-Point Protocol High-Level Data Link Control Link Sharing Using Statistical Multiplexing Chapter Overview z Peer-to-Peer protocols: many protocols involve the interaction between two peers z Service Models are discussed & examples given z Detailed discussion of ARQ provides example of development of peer-to-peer protocols z Flow control, TCP reliable stream, and timing recovery z Data Link Layer z Framing z PPP & HDLC protocols z Statistical multiplexing for link sharing Chapter 5 Peer-to-Peer Protocols and Data Link Layer Peer-to-Peer Protocols and Service Models Peer-to-Peer Protocols zzz zzz z Peer-to-Peer processes execute layer-n protocol to provide service to n + 1 peer process n + 1 peer process layer-(n+1) z Layer-(n+1) peer calls SDU SDU layer-n and passes PDU Service Data Units n peer process n peer process (SDUs) for transfer z Layer-n peers exchange Protocol Data Units (PDUs) to effect transfer n – 1 peer process n – 1 peer process z Layer-n delivers SDUs to destination layer-(n+1) peer zzz zzz Service Models z The service model specifies the information transfer service layer-n provides to layer-(n+1) z The most important distinction is whether the service is: z Connection-oriented z Connectionless z Service model possible features: z Arbitrary message size or structure z Sequencing and Reliability z Timing, Pacing, and Flow control z Multiplexing z Privacy, integrity, and authentication Connection-Oriented Transfer Service z Connection Establishment z Connection must be established between layer-(n+1) peers z Layer-n protocol must: Set initial parameters, e.g. sequence numbers; and Allocate resources, e.g. buffers z Message transfer phase z Exchange of SDUs z Disconnect phase z Example: TCP, PPP n + 1 peer process n + 1 peer process send receive SDU Layer n connection-oriented service SDU Connectionless Transfer Service z No Connection setup, simply send SDU z Each message send independently z Must provide all address information per message z Simple & quick z Example: UDP, IP n + 1 peer process n + 1 peer process send receive SDU Layer n connectionless service Message Size and Structure z What message size and structure will a service model accept? z Different services impose restrictions on size & structure of data it will transfer z Single bit? Block of bytes? Byte stream? z Ex: Transfer of voice mail = 1 long message z Ex: Transfer of voice call = byte stream 1 voice mail= 1 message = entire sequence of speech samples (a) 1 call = sequence of 1-byte messages (b) Segmentation & Blocking z To accommodate arbitrary message size, a layer may have to deal with messages that are too long or too short for its protocol z Segmentation & Reassembly: a layer breaks long messages into smaller blocks and reassembles these at the destination z Blocking & Unblocking: a layer combines small messages into bigger blocks prior to transfer 1 long message 2 or more short messages 2 or more blocks 1 block Reliability & Sequencing z Reliability: Are messages or information stream delivered error-free and without loss or duplication? z Sequencing: Are messages or information stream delivered in order? z ARQ protocols combine error detection, retransmission, and sequence numbering to provide reliability & sequencing z Examples: TCP and HDLC Pacing and Flow Control z Messages can be lost if receiving system does not have sufficient buffering to store arriving messages z If destination layer-(n+1) does not retrieve its information fast enough, destination layer-n buffers may overflow z Pacing & Flow Control provide backpressure mechanisms that control transfer according to availability of buffers at the destination z Examples: TCP and HDLC Timing z Applications involving voice and video generate units of information that are related temporally z Destination application must reconstruct temporal relation in voice/video units z Network transfer introduces delay & jitter z Timing Recovery protocols use timestamps & sequence numbering to control the delay & jitter in delivered information z Examples: RTP & associated protocols in Voice over IP Multiplexing z Multiplexing enables multiple layer-(n+1) users to share a layer-n service z A multiplexing tag is required to identify specific users at the destination z Examples: UDP, IP Privacy, Integrity, & Authentication z Privacy: ensuring that information transferred cannot be read by others z Integrity: ensuring that information is not altered during transfer z Authentication: verifying that sender and/or receiver are who they claim to be z Security protocols provide these services and are discussed in Chapter 11 z Examples: IPSec, SSL End-to-End vs. Hop-by-Hop z A service feature can be provided by implementing a protocol z end-to-end across the network z across every hop in the network z Example: z Perform error control at every hop in the network or only between the source and destination? z Perform flow control between every hop in the network or only between source & destination? z We next consider the tradeoffs between the two approaches Error control in Data Link Layer Packets Packets (a) z Data Link operates over wire-like, Data link Data link layer Frames layer directly-connected A Physical Physical B systems layer layer z Frames can be corrupted or lost, but arrive in order (b) 1 1 z Data link performs 2 2 error-checking & 1 2 3 2 1 1 2 3 2 1 Medium retransmission 2 z Ensures error-free 1 A B packet transfer 1 Physical layer entity between two systems 2 Data link layer entity 3 Network layer entity Error Control in Transport Layer z Transport layer protocol (e.g. TCP) sends segments across network and performs end-to-end error checking & retransmission z Underlying network is assumed to be unreliable Messages Messages Segments Transport Transport layer layer Network Network Network Network layer layer layer layer Data link Data link Data link Data link layer layer layer layer End system End system Physical Physical A Physical Physical B layer layer layer layer Network z Segments can experience long delays, can be lost, or arrive out-of-order because packets can follow different paths across network z End-to-end error control protocol more difficult 1 2 2 1 C 3 2 2 1 1 End System 1 End System α 1 1 2 2 2 β 4 3 2 1 1 2 3 2 1 1 2 3 2 1 1 2 3 4 Medium 2 A B 1 Network 3 Network layer entity 4 Transport layer entity End-to-End Approach Preferred Hop-by-hop Hop-by-hop cannot ensure E2E correctness Data Data Data Data 1 2 3 4 5 Faster recovery ACK/ ACK/ ACK/ ACK/ NAK NAK NAK NAK Simple End-to-end inside the ACK/NAK network More scalable 1 2 3 4 5 if complexity at Data Data Data Data the edge Chapter 5 Peer-to-Peer Protocols and Data Link Layer ARQ Protocols and Reliable Data Transfer Automatic Repeat Request (ARQ) z Purpose: to ensure a sequence of information packets is delivered in order and without errors or duplications despite transmission errors & losses z We will look at: z Stop-and-Wait ARQ z Go-Back N ARQ z Selective Repeat ARQ z Basic elements of ARQ: z Error-detecting code with high error coverage z ACKs (positive acknowledgments z NAKs (negative acknowlegments) z Timeout mechanism Stop-and-Wait ARQ Transmit a frame, wait for ACK Error-free Packet packet Information frame Transmitter Receiver Timer set after (Process A) (Process B) each frame transmission Control frame Header CRC Information Header packet CRC Information frame Control frame: ACKs Need for Sequence Numbers (a) Frame 1 lost Time-out Time A Frame Frame Frame Frame 0 1 1 2 ACK ACK B (b) ACK lost Time-out Time A Frame Frame Frame Frame 0 1 1 2 ACK ACK ACK B z In cases (a) & (b) the transmitting station A acts the same way z But in case (b) the receiving station B accepts frame 1 twice z Question: How is the receiver to know the second frame is also frame 1? z Answer: Add frame sequence number in header z Slast is sequence number of most recent transmitted frame Sequence Numbers (c) Premature Time-out Time-out Time A Frame 0 Frame Frame Frame ACK 0 1 2 ACK B z The transmitting station A misinterprets duplicate ACKs z Incorrectly assumes second ACK acknowledges Frame 1 z Question: How is the receiver to know second ACK is for frame 0? z Answer: Add frame sequence number in ACK header z Rnext is sequence number of next frame expected by the receiver z Implicitly acknowledges receipt of all prior frames 1-Bit Sequence Numbering Suffices 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Rnext Slast Timer Transmitter Slast Receiver A B Rnext Global State: Error-free frame 0 (0,0) (0,1) (Slast, Rnext) arrives at receiver ACK for ACK for frame 0 frame 1 arrives at arrives at transmitter transmitter Error-free frame 1 arrives at receiver (1,0) (1,1) Stop-and-Wait ARQ Transmitter Receiver Ready state Always in Ready State z Await request from higher layer for z Wait for arrival of new frame packet transfer z When frame arrives, check for errors z When request arrives, transmit z If no errors detected and sequence frame with updated S and CRC last number is correct (Slast=Rnext), then z Go to Wait State z accept frame, Wait state z update Rnext, z Wait for ACK or timer to expire; z send ACK frame with Rnext, block requests from higher layer z deliver packet to higher layer z If timeout expires z If no errors