UDP—User Datagram Protocol

Click here to load reader

download UDP—User Datagram Protocol

of 91

  • date post

  • Category


  • view

  • download


Embed Size (px)


UDP—User Datagram Protocol. An unreliable, connectionless transport layer protocol UDP format. See picture Two additional functions beyond IP: - PowerPoint PPT Presentation

Transcript of UDP—User Datagram Protocol

  • UDPUser Datagram ProtocolAn unreliable, connectionless transport layer protocolUDP format. See picture Two additional functions beyond IP:Demultiplexing: deliver to different upper layer entities such as DNS, RTP, SNMP based on the destination port # in the header. i.e., UDP can support multiple applications in the same end systems.(Optionally) check the integrity of entire UDP. (recall IP only checks the integrity of IP header.)If source does not want to compute checksum, fill checksum with all 0s.If compute checksum and the checksum happens to be 0s, then fill all 1s.UDP checksum computation is similar to IP checksum, with two more:Add extra 0s to entire datagram if not multiple of 16 bits.Add pseudoheader to the beginning of datagram. UDP pseudoheader

  • Source Port Destination PortUDP Length UDP ChecksumData0 16 31Figure 8.16UDP datagramBack to UDPUser Datagram Protocol

  • 0 0 0 0 0 0 0 0 Protocol = 17 UDP LengthSource IP AddressDestination IP Address0 8 16 31Figure 8.17UDP pseudoheader1.Pseudoheader is to ensure that the datagram has indeed reached the correct destination host and port.2. The padding of 0s and pseudoheader is only for the computation of checksum and not be transmitted.Back to UDPUser Datagram Protocol

  • TCPtransmission control protocolTCP functionalityProvides connection-oriented, reliable, in-sequence, byte-stream serviceProvides a logical full-duplex (two way) connectionProvides flow-control by advertised window.Provides congestion control by congestion window.Support multiple applications in the same end systems.TCP establishes connection by setting up variables that are used in two peer TCP entities. Most important variables are initial sequence numbers.TCP uses Selective Repeat ARQ.TCP terminates each direction of connection independently, allowing data to continue flowing in one direction after closing the other direction.TCP does not keep messages boundaries and treats data as byte stream. e.g, when source sends out two chunks of data with length 400 and 600 bytes, the receiver may receive data in chunks of 300, 400, and 300 bytes, or 100 and 900 bytes.

  • TCP operationsTCP delivers byte stream.See pictureTCP deals with old packets from old connections by several methods. See pictureTCP uses sliding-window to implement reliable transfer of byte stream. See pictureTCP uses advertised window for flow control.Adaptive timer: tout = tRTT+4dRTT , tRTT(new) = tRTT(old) +(1-)n , dRTT(new)=dRTT(old) + (1-)(n-tRTT)Where n is the time from transmitting a segment until receiving its ACK. , are in 0 to 1 with being 7/8 and being typically. tRTT is mean round-trip-time, dRTT is average of deviation.TCP uses congestion window for congestion control. See picture

  • byte streamSend buffersegmentsReceive bufferbyte streamApplicationApplicationACKsTransmitterReceiverFigure 8.18TCP byte stream

  • Figure 8.23Back to TCP operationsQuestion: How does TCP prevent old packets of old connections? An old segment could not be distinguished from current ones Using long (32 bit) sequence numberRandom initial sequence number-- set a timer at the end of a connection to clear all lost packets from this connection. As a result, that an old packet from an old connection conflicts with packets in current connection is very low!!

  • Back to TCP operationsOctetstransmittedand ACKedRlast highest-numbered octet not yet read by the applicationRnext next expected octetRnew highest numbered octet receivedcorrectlyRlast+WR-1 highest-numbered octet that can be accommodated in receive bufferTransmitterReceiverReceive WindowSlastSlast+WS-1...Send WindowSrecentRnext......Slast+WA-1RlastRlast+WR+1Slast oldest unacknowledged octetSrecent highest-numbered transmitted octetSlast+WA-1 highest-numbered octet that can be transmittedSlast+WS-1 highest-numbered octet that can be accepted from the applicationRnewFigure 8.19TCP uses Selective-Repeat ARQNote: 1. Rnew highest bytes received correctly, which are out-of sequence bytes.2. Advertised window WA: Srecent Slast WA =WR ( Rnew Rlast) Advertised window

  • Congestionwindow10515200Round-trip timesSlowstartCongestionavoidanceCongestion occursThresholdFigure 7.63Back to TCP operationsDynamics of TCP congestion window

  • TCP protocolTCP segment See Segment formatTCP pseudoheader. See pseudoheaderTCP connection establishment. See establishmentClient-server application See socketTCP Data transferSliding window with window sliding on byte basisFlow control and piggybacking See flow controlTCP connection terminationAfter receiving ACK for previous data, but no more data to send, the TCP will terminate the connection in its direction by issuing an FIN segment. Graceful terminationTCP state transition diagram

  • Source Port Destination PortSequence NumberAcknowledgement NumberChecksum Urgent PointerOptions Padding0 4 10 16 24 31URGACKPSHRSTSYNFINHeaderLengthReserved(Advertised) Window SizeDataFigure 8.20Back to TCP protocolTCP segment format1.SYN: request to set a connection. 2. RST: tell the receiver to abort the connection.3. FIN: tell receiver this is the final segment, no more data, i.e, close the connection in this direction.4. ACK: tell the receiver (or sender) that the value is the field of acknowledgment number is valid.5. PSH: tell the receiving TCP entity to pass the data to the application immediately.6. URG: tell the receiver that the Urgent Pointer is valid.

    Urgent Pointer: this pointer added to the sequence number points to the last byte of the Urgent Data, (the data that needs immediately delivery).

  • 0 0 0 0 0 0 0 0 Protocol = 6 TCP Segment LengthSource IP AddressDestination IP Address0 8 16 31Figure 8.21Back to TCP protocolTCP pseudoheaderThe padding of 0s and pseudoheader is only used in computationof checksum but not be transmitted, as in UDP checksum.

  • Host AHost BSYN, Seq_no = xSYN, Seq_no = y, ACK, Ack_no = x+1Seq_no = x+1, ACK, Ack_no = y+1Figure 8.22Back to TCP protocolThree-way handshake to set up connectionRandom initial SNInitial SNs in two directions are different3. Initial SNs for two connections are different.4. It should be clear here thatwhat setting up connection means: both A and B know that they will exchange data, and go into ready state to send and receive data. Most important is that they agree upon the initial SNs.

  • Host A (Client)Host B (Server)SYN, Seq_no = xSYN, Seq_no = y, ACK, Ack_no = x+1Seq_no = x+1, ACK, Ack_no = y+1socketbindlistenaccept (blocks)socketconnect (blocks)connect returnsaccept returnsread (blocks)writeread (blocks)read returnswriteread (blocks)read returnsrequest messagereply messageFigure 8.24Back to TCP protocol

  • Host AHost BSeq_no = 2000, Ack_no = 1, Win = 1024, Data = 2000-3023Seq_no = 1, Ack_no = 4048, Win = 512, Data = 1-128Seq_no = 3024, Ack_no = 1, Win = 1024, Data = 3024-4047Seq_no = 4048, Ack_no = 129, Win = 1024, Data = 4048-4559t1t2t3t4Seq_no = 1, Ack_no = 2000, Win = 2048, No Datat0Figure 8.25Back to TCP protocolTCP window flow control

  • Back to TCP protocolFIN, seq = 5086ACK = 5087Data (150 bytes), seq. = 303, ACK = 5087FIN, seq. =453, ACK = 5087ACK = 454Host AHost BACK = 453Figure 8.27TCP graceful terminationQuestion: is terminationeasier than establishment?Or to say, is it possiblethat a connection is closed when both of two parties confirm with each other?No, Saying goodbyeis hard to do.Famous blue-red armies problem.

  • CLOSEDLISTENSYN_RCVDESTABLISHEDCLOSINGTIME_WAITSYN_SENTFIN_WAIT_1CLOSE_WAITLAST_ACKFIN_WAIT_2active open,create TCB send SYNpassive open,create TCBsend SYNreceive SYN,send SYN, ACKreceiveRSTreceiveACKreceive SYN, ACK,send ACKapplic.close,sendFINapplic. close,send FINreceive FIN,send ACKreceive FINsend ACKreceive FIN, ACKsend ACKreceiveACKreceive FINsend ACKreceiveACKapplic. closesend FINreceiveACKapplic. closeor timeout,delete TCB2MSL timeoutdelete TCBreceive SYN,send ACKapplic.closeFigure 8.28Thick lines: normal client statesDashed lines: normal server statesBack to TCP protocol

  • Sequence number wraparound and timestampsOriginal TCP specification for MSL (Maximum Segment Lifetime) is 2 minutes.How long will it take to wrap around 32 bit sequence number when 232=4,294,967,296 bytes have been sent (maximum window size=231)T-1 line, (2328)/(1.544 106) = 6 hoursT-3 line, (2328)/(45 106) = 12 minutesOC-48 line, (2328)/(2.4 109) = 14 seconds !!!When sequence number wrap around, the wraparounded sequence number will confuse with previous sequence number.Solution: optional timestamp field (32 bits) in TCP header, thus, 232232=264 is big enough right now.

  • Internet routing protocolsAutonomous system (AS)A set of routers or networks technically administrated by a single organization.No restriction that an AS must run a single routing protocolOnly requirement is that from outside, an AS presents a consistent picture of which ASs are reachable through