300 likes | 422 Views
15-441 Computer Networking. Introduction of Transport Protocols. Transport Protocols. Network provides best-effort delivery Transport at end -systems implement many functions. 7. 7. 6. 6. 5. 5. Transport. Transport. IP. IP. IP. Datalink. 2. 2. Datalink. Physical. 1. 1.
E N D
15-441 Computer Networking Introduction of Transport Protocols
Transport Protocols • Network provides best-effort delivery • Transport at end-systems implement many functions 7 7 6 6 5 5 Transport Transport IP IP IP Datalink 2 2 Datalink Physical 1 1 Physical router
Minimum Transport Protocol Function • Multiplexing/de-multiplexing for multiple applications • How does the protocol stack know what application should receive a packet? • Why not using process ID?
Multiplexing using Ports • Transport layer uses the port in the transport header to identify the application socket. • (Destination IP, destination port) identifies the destination • Port numbers 0-1023 are well-known port numbers • In UDP packets delivered at a socket can come from multiple sources (connectionless). • Why do we need a source port number? • Needed to return a packet! • Flip source and destination (IP, port) pairs
User Datagram Protocol (UDP) Source Port Dest. Port • Still connectionless datagram • Multiplexing/demultiplexing • port numbers = connection/application endpoint • End-to-end reliability through optional end-to-end checksum. • protects against data corruption errors between source and destination (links, switches/routers, bus) • does not protect against packet loss, duplication or reordering • checksum is very simple so it can be implemented efficiently in software Length D. Checksum
Using UDP • Examples: • remote procedure calls • multimedia • distributed computing communication libraries • Use the port addressing provided by UDP • implement their own reliability, flow control, ordering, congestion control
More Transport Protocol Functions • Multiplexing/de-multiplexing for multiple applications • Error control • Hide unreliability of the network layer from applications • Many types of errors: corruption, loss, duplication, reordering. • End-to-end flow control • Avoid flooding the receiver • Congestion control • Avoid flooding the network • Connection management • Logical end-to-end connection • Connection state to optimize performance
Problems to Be Solved by Error Control At Transport Layer • Best effort network layer • Packets can get corrupted • Packets can get lost • Packets can get re-ordered
Mechanisms used For Error Control • Packets can get corrupted • CRC or Checksum to detect, retransmission to recover • Error correction code to recover • Packets can get lost • Sequence number to detect • Acknowledgement + Timeout to detect, retransmission to recover • Packets can get re-ordered • Sequence number to detect, receiver buffer to re-order
Sliding Window Protocol: Sender • Each packet has a sequence number • Assume infinite sequence numbers for simplicity • Sender maintains a window of sequence numbers • SWS (sender window size) – maximum number of packets that can be sent without receiving an ACK • LAR (last ACK received) • LFS (last frame sent) Acknowledged packets Packets not acknowledged yet LFS seq. numbers LAR
1 frame 1 frame 2 1 2 3 frame 3 1 2 3 1 2 3 4 frame 4 ACK 1 ACK 2 1 2 3 4 5 frame 5 Example • Assume SWS = 3 Sender Receiver Note: usually ACK contains the sequence number of the first packet in sequence expected by receiver
Sliding Window Protocol: Receiver • Receiver maintains a window of sequence numbers • RWS (receiver window size) – maximum number of out-of-sequence packets that can received • LFR (last frame received) – last frame received in sequence • LAF (last acceptable frame) • LAF – LFR <= RWS
Sliding Window Protocol: Receiver • Let seqNum be the sequence number of arriving packet • If (seqNum <= LFR) or (seqNum >= LAF) • Discard packet • Else • Accept packet • ACK largest sequence number seqNumToAck, such that all packets with sequence numbers <= seqNumToAck were received Packets in sequence Packets out-of-sequence LAF seq. numbers LFR
Sender/Receiver State Sender Receiver Next expected Max acceptable Max ACK received Next seqnum … … … … Sender window Receiver window Sent & Acked Sent Not Acked Received & Acked Acceptable Packet OK to Send Not Usable Not Usable
Lecture 16: Transport Protocols Sequence Numbers • How large do sequence numbers need to be? • Must be able to detect wrap-around • Depends on sender/receiver window size • E.g. • Max seq = 7, send win=recv win=7 • If pkts 0..6 are sent succesfully and all acks lost • Receiver expects 7,0..5, sender retransmits old 0..6!!! • Max sequence must be send window + recv window
Lecture 16: Transport Protocols Cumulative ACK + Go-Back-N Retransmission • On reception of new ACK (i.e. ACK for something that was not acked earlier) • Increase sequence of max ACK received • Send next packet • On reception of new in-order data packet (next expected) • Hand packet to application • Send cumulative ACK – acknowledges reception of all packets up to sequence number • Increase sequence of max acceptable packet
Lecture 16: Transport Protocols Loss Recovery • On reception of out-of-order packet • Send nothing (wait for source to timeout) • Cumulative ACK (helps source identify loss) • Timeout (Go-Back-N recovery) • Set timer upon transmission of packet • Retransmit all unacknowledged packets • Performance during loss recovery • No longer have an entire window in transit • Can have much more clever loss recovery
Lecture 16: Transport Protocols Go-Back-N in Action
Lecture 16: Transport Protocols Receiver individually acknowledges all correctly received pkts Buffers packets, as needed, for eventual in-order delivery to upper layer Sender only resends packets for which ACK not received Sender timer for each unACKed packet Sender window N consecutive seq #’s Again limits seq #s of sent, unACKed packets Selective Ack + Selective Repeat
Lecture 16: Transport Protocols Selective Repeat: Sender, Receiver Windows
Lecture 16: Transport Protocols Summary of ARQ Protocols • Mechanisms: • Sequence number • Timeout • Acknowledgement • Sender window: fill the pipe • Receiver window: handle out-of-order delivery
Many Nuances • What type of acknowledgements? • Selective acknowledgement • Cumulative acknowledgement • Negative acknowledgement • How big should be the timeout value, SWS, RWS, sequence number field? • Reliability mechanism used to implement other functions: flow control, congestion control • Function overloading introduces ambiguity and complexity
Transmission Control Protocol (TCP) • The most utilized transport protocol • Provides a bidirectional reliable byte stream service • Made specific design decisions that have tradeoffs • Ports for multiplexing and-demultiplexing • Error control • Each byte (not a packet) has a sequence number • 32 bits sequence number space • Cumulative ack + Go-Back-N • Flow control • Receiver gives send a window size to limit range of bytes that sender can send • 16 bits window size • Congestion control (next lecture) • What is the key difference between this and flow control? • Why is it more difficult to implement congestion control than flow control? • Connection management (next lecture)
Sequence Number Space • Each byte in byte stream is numbered. • 32 bit value • Wraps around • Initial values selected at start up time • TCP breaks up the byte stream in packets (“segments”) • Packet size is limited to the Maximum Segment Size • Each segment has a sequence number. • Indicates where it fits in the byte stream 13450 14950 16050 17550 segment 8 segment 9 segment 10
Bidirectional Communication Send bytes 1000:2000 • Each Side of Connection can Send and Receive • What this Means • Maintain different sequence numbers for each direction • Single segment can contain new data for one direction, plus acknowledgement for other • But some contain only data & others only acknowledgement Ack bytes 1000:2000 Send bytes 40000:42000 Ack bytes 40000:42000
Window Flow Control: Send Side Packet Received Packet Sent Source Port Dest. Port Source Port Dest. Port Sequence Number Sequence Number Acknowledgment Acknowledgment HL/Flags Window HL/Flags Window D. Checksum Urgent Pointer D. Checksum Urgent Pointer Options.. Options.. App write acknowledged sent to be sent outside window
TCP Flow Control • Sliding window protocol • For window size n, can send up to n bytes without receiving an acknowledgement • When the data are acknowledged then the window slides forward • Each packet advertises a window size • Indicates number of bytes the sender is prepared to receive • Original TCP always sent entire window • Congestion control now limits this
Must retain for possible retransmission Window Flow Control: Send Side window Sent but not acked Not yet sent Sent and acked Next to be sent
Window Flow Control: Receive Side Receive buffer Acked but not delivered to user Not yet acked window
Maximum Window Size • Mechanism for receiver to exert flow control • Prevent sender from overwhelming receiver’s buffering & processing capacity • Max. transmission rate = window size / round trip time • Mechanism to Guarantee Receive Buffer Does Not Overflow Receive buffer Acked but not delivered to user Not yet acked window