470 likes | 587 Views
Ch 16 Protocols and Layering. Motivation. Explains why hardware along does not solve all communication problems, and shows why protocol software is also need Describes the concept of layering. The Need for Protocols. Communication hardware can transfer bits from point to another
E N D
Ch 16 Protocols and Layering Spring 2003
Motivation • Explains why hardware along does not solve all communication problems, and shows why protocol software is also need • Describes the concept of layering
The Need for Protocols • Communication hardware can transfer bits from point to another • Many problems can occur • Bits corrupted or destroyed • Entire packet lost • Packet duplicated • Packets delivered out of order
AP AP Protocol HW HW The Need for Protocols • Software handles low-level communication details and problems • Protocol is a set of rules to be used when exchanging messages • Most AP do not interact with net HW directly
Protocol • Specifies • Format of messages • Meaning of messages • Rules for exchange • Procedure for handling problems
Protocol Suites • Each protocol solves part of communication problem • Work well together; known as protocol suite /w/ • Make each protocol easier to design, analyze, implement, and test AP AP P1 Protocol … HW HW
A Plan for Protocol Design • Layering model • Vertically divides protocols into layers • Each layer devoted to one subproblem • To help protocol designers understand subparts of the communication problem • E.g.: ISO 7-layer reference model
The Seven Layers LAN
The Seven Layers • Layer 1: Physical • Gives the detailed spec. of underlying hardware • Layer 2: Data Link • Specify hardware frame format, medium access, and checksum computation • Layer 3: Network • Specify address assignment and packet forwarding • Layer 4: Transport • Specify how to handle details of reliable transfer
The Seven Layers • Layer 5: Session • Specifications for session establishment and security details • Layer 6: Presentation • Data representation and the translation • Layer 7: Application • Define how application programs, running on different end systems, pass messages to each other
Stacks: Layered Software • Protocol software follows layering model • One software module per layer • Modules cooperate • Incoming or outgoing data passes from one module to another • Entire set of modules known as stack
Ethernet header IP header TCP header Data Encapsulation FTP HTTP Telnet L7 Port 21 80 25 L4 TCP UDP Segment TCP header ICMP IGMP L3 IP IP header Datagram ARP RARP L2 MAC discard Frame Ethernet header
Data Encapsulation • Each layer • Places additional information in a header before sending data to a lower layer • Uses, and then removes, the header to process incoming packets (e.g., L2 checksum)
Data Encapsulation • Port number • An AP can be uniquely identified by (IP address, port number) pair • Assigned ranges • Numbers below 255 are for public applications • Numbers from 255 to 1023 are assigned to companies for marketable applications • Numbers above 1023 are unregulated • Bind: creates mapping between an AP and a port number
Scientific Basis for Layering Software implementing layer N at the destination receives exactly the message sent by software implementing layer N at the source
1 2 3 4 Techniques Protocols Use • For bit corruption • Parity bit • Frame checksum • CRC • For out-of-order delivery • Sequence numbers • For lost packets • Positive acknowledgement (ACK) and retransmission for time-out • Max. number of try Ack1
Techniques Protocols Use • Duplication • Sequence numbers • For replay (excessive delay) • A termination request arrives from an previous conversation may terminate a current conversation • Unique session ID • For data overrun • Flow control Bye
Flow Control • Needed because • Sending computer system faster than receiving computer • Sending application faster than receiving application • Related to buffering • Two forms • Stop-and-go • Sliding window
Stop-And-Go • Sending Side • Transmits one packet • Waits for signal from receiver • Receiving side • Receives and consumes packets • Transmits signal to sender • Inefficient
Sliding Window Flow Control 1 car v.s. 4 cars
Sliding Window Flow Control • Receiving side • Establishes multiple buffers and informs sender • Sending side • Transmits packets for all available buffers • Only waits if no signal arrives before transmission • Receiving side • Sends signals as packets arrive • Window tells how many packets can be sent • Window moves as acknowledgements arrive
Comparison of Flow Control • Stop-and-go • Slow • Useful only in special cases • Sliding window • Fast • Needed in high-speed network
Why Sliding Window? • Simultaneously • Increase throughput • Control flow • Speedup Tw = min(B, TG W) where • TW is sliding window throughput • B is underlying hardware bandwidth • TG is stop-and-go throughput • W is the window size
Congestion • Fundamental problem in networks • Caused by traffic, not hardware failure • Analogous to congestion on a highway • Principal cause of delay
Illustration of ArchitectureThat Can Experience Congestion • Multiple sources • Bottleneck
Congestion and Loss Modern network hardware works well; most packet loss results from congestion, not from hardware failure • Rate control (e.g. temporarily reducing WS)
The Art of Protocol Design • Protocol Design is “nontrivial” • Lots of Tradeoff • Size of “Sequence number” field • Balance between sliding window and congestion control
Exercise • 16.4
Frame Number (K bits) Source Address Destination Address Type of Frame ACK ..Data... CRC Data/ACK/NACK 02K-1 Frame number of a frame being acknowledged (piggybacking) Two Common Implementations of Sliding Window Protocol • Go-Back-N Protocol • Selective Repeat Protocol
(0,1,2,3) (0) 0 0(1,2,3) 1 0,1(2,3) (1) 2 0,1,2(3) (2) 3 0,1,2,3(-) (3) ACK 3 (4) (4,5,6,7) 4 4(5,6,7) 5 (5) 4,5(6,7) ACK 5 (6) (6,7,0,1) Sender Receiver Go-Back-N • receiver does not acknowledge each received frame explicitly Sequence number: 0-7 Window size=4 • Sender buffers all frames in the windows • frames are removed when ACKed
(0,1,2,3) (0) 0 0(1,2,3) 1 0 0,1(2,3) (1) 2 1 0,1,2(3) X (2) 3 ACK 1 0,1,2,3(-) 3 discard 2,3(4,5) 4 NAK 2 2,3,4(5) 4 discard (2,3,4,5) 2 2(3,4,5) 3 2 2,3(4,5) 4 3 2,3,4(5) 5 4 2,3,4,5(-) 5 Sender Receiver Go-Back-N (continued) • receiver always expects to receive frames in order Sequence number: 0-7 Window size=4
(0,1,2,3) (0) 0 0(1,2,3) 1 0 0,1(2,3) (1) 2 1 0,1,2(3) (2) 3 2 ACK 1 0,1,2,3(-) 3 discard 2,3(4,5) 4 NAK 3 2,3,4(5) 4 discard 3,4(5,6) (3,4,5,6) 3 3(4,5,6) 4 3 3,4(5,6) 5 4 3,4,5(6) 5 Sender Receiver Go-Back-N (continued) • frame damaged Sequence number: 0-7 Window size=4
(0,1,2,3) 0 (0) 0(1,2,3) 1 0 0,1(2,3) 2 (1) 1 0,1,2(3) (2) X ACK 1 Time out 2(3,4,5) (2,3,4,5) 2 2(3,4,5) 3 2 2,3(4,5) 4 3 2,3,4(5) 5 4 2,3,4,5(-) 5 Sender Receiver Go-Back-N (continued) • Frame timer Sequence number: 0-7 Window size=4
(0,1,2,3) 0 (0) 0(1,2,3) 1 0 0,1(2,3) 2 (1) 1 0,1,2(3) (2) X ACK 1 Time out 2(3,4,5) 3 2,3(4,5) (2,3,4,5) 2 3 discard 2(3,4,5) 3 2 2,3(4,5) NAK 2 4 2,3,4(5) 3 (2,3,4,5) 2 4 2(3,4,5) 3 2 2,3(4,5) Receiver Sender 3 Go-Back-N (continued) • Out of order + time out Sequence number: 0-7 Window size=4
Go-Back-N (continued) • ACK timer • a frame arriving should be ACKed within a period of time • use piggyback approach to ACK whenever possible • send a separate ACK frame in lieu of the piggyback ACK
Go-Back-N (continued) • Window size should be 2K-1 Station B Station A Send frames 0 through 7. t1 Receive frames 0 through 7 in order and send an acknowledgment for frames 7 t2 Window size=2K The piggyback acknowledgment gets delayed somewhere Receive frames 0 through 7 Since the receiver was expecting these number,it accept them as new frames,not recognizing them as duplicate Assume the frames were lost and resend frames 0 through 7. t3 t4
Go-Back-N (continued) • Window size should be 2K-1 Station B Station A Send frames 0 through 6. t1 Receive frames 0 through 6 in order and send an acknowledgment for frames 6 t2 Window size=2K-1 The piggyback acknowledgment gets delayed somewhere Receive frames 0 through 6 Since the receiver was expecting frame 7 it ignores them Assume the frames were lost and resend frames 0 through 6. t3 t4
Selective Repeat • Similarities to go-back-n • Frame format • sending window • use piggyback ACK whenever possible • not acknowledge every frame explicitly • use NAKs for damaged frames and out-of-order frames • Frame timer • ACK timer
Selective Repeat (continued) • Differences to go-back-n • Buffer arriving frames in receiving window until all predecessors received • Only the timed-out frame is resent when a frame timer expires • When a NAK is received, resend just the frame specified by the NAK • A piggyback ACK doesn’t necessary acknowledge the frame just received Receive sequential frames Send frames Receiving Window size=3 Sending Window size=3 7 7 0 0 6 1 6 1 5 2 5 2 4 3 4 3 Receive sequential frames Receive ACKs
(0,1,2,3) (0,1,2,3) 0 0(1,2,3) 1 0 0,1(2,3) (1,2,3,4) 2 1 0,1,2(3) (2,3,4,5) 3 X 0,1,2,3(-) ACK 1 3 (buffered) 2,3(4,5) 4 NAK 2 2,3,4(5) 5 4 (buffered) 2,3,4,5(-) 2 5 (buffered) 2,3,4,5(-) 2 (6,7,0,1) ACK 5 (6,7,0,1) Sender Receiver Selective Repeat (continued) • Frame lost Sending Window size=4 Receiving Window size=4
Selective Repeat (continued) • CRC error (0,1,2,3) (0,1,2,3) 0 Sending Window size=4 Receiving Window size=4 0(1,2,3) 1 0 0,1(2,3) (1,2,3,4) 2 1 0,1,2(3) (2,3,4,5) 3 2 (CRC error) 0,1,2,3(-) ACK 1 3 (buffered) 4 NAK 2 2,3(4,5) 2,3,4(5) 2 4 (buffered) 2,3,4(5) 5 2 2,3,4,5(-) (5,6,7,0) 5 (6,7,0,1) Sender Receiver
Selective Repeat (continued) • Receiving window size should be 2K-1 Station A Station B Receiving window size>2K-1 t1 Send frames 0 through3 Receive frames 0 through 3;advance window to include frames 4,5,6,7,and 0. t2 The acknowledgement gets lost. Assume the frames were lost and resend frames 0 through 3 t3 Receive frames 0 and assume incorrectly it is a new frame. t4 time time
Selective Repeat (continued) • Receiving window size should be 2K-1 Station A Station B Receiving window size>2K-1 Receive frames 0 through 3 and advance window to include frames 4-7. Receive frame 4 and send an acknowledgment to A. Advance window again to include frames 5,6,7, and 0. t1 Send frames 0 through 4 t2 The acknowledgement gets lost. Assume the frames were lost and resend frames 0 through 4 t3 Receive frames 0 and assume incorrectly it is a new frame. t4 time time