* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download CSC 335 Data Communications and Networking I
SIP extensions for the IP Multimedia Subsystem wikipedia , lookup
Computer network wikipedia , lookup
Remote Desktop Services wikipedia , lookup
Zero-configuration networking wikipedia , lookup
Deep packet inspection wikipedia , lookup
Cracking of wireless networks wikipedia , lookup
Quality of service wikipedia , lookup
TCP congestion control wikipedia , lookup
Recursive InterNetwork Architecture (RINA) wikipedia , lookup
CSC 581 Communication Networks II Chapter 8b: Transport Layer Dr. Cheer-Sun Yang TOPICS • OSI Transport Services, design, protocols • Example Protocols: TCP, UDP • Client-Server Model and Socket Programming 2 Reliable Sequencing Network Service • Assume arbitrary length message • Assume virtually 100% reliable delivery by network service – e.g. reliable packet switched network using X.25 – e.g. frame relay using LAPF control protocol – e.g. IEEE 802.3 using connection oriented LLC service • Transport service is end to end protocol between two systems on same network 3 Reliable Sequencing Network Service • It is important because IP or other network layer protocols do no guarantee reliable service. Transport protocols must provide acknowledgements and timers to make sure that all of a user’s data are sent and received. 4 TCP is not the OSI Transport Layer Protocol • TCP is designed and developed by the DoD to run on top of IP for providing connection-oriented transport layer services. • OSI transport layer protocol is a generic redesign of transport layer protocol which includes more functions than TCP. 5 OSI vs. TCP • OSI transport services include a more complete set of services • TCP is not identical to OSI transport protocol in terms of the PDU format, and even some terms. For example, TCP calls its PDU a segment; OSI calls its PDU a TPDU; TCP identifies its application using a port number, OSI uses a Transport Service Access Point(TSAP). We will summarize the comparison at the end of this unit of slides. 6 Issues in OSI Transport Protocols • • • • • • • Establishing a Connection Releasing a connection Addressing Quality of Service (QoS) Multiplexing Flow Control and Buffering Crash Recovery 7 Addressing • Target user specified by: – User identification: Transport Service Access Point (TSAP) – Machine identification: Network layer address, such as IP address, identifies a host 8 Finding Addresses • Four methods – Know address ahead of time • e.g. collection of network device stats – Well known addresses – Name server – Sending process request to well known address 9 QoS • Another way to look at the transport service is to regard its primary function as enhancing the QoS provided by the network layer. • If the network layer is impeccable, the transport layer has an easy job. • If the network layer is unreliable, the transport layer has to bridge the gap between what the user wants and the network layer provides. 10 QoS • What is QoS? It is characterized by a list of QoS parameters which can be negotiated at the connection establishment time. • It is specified by users at the user layer. • It is up to the transport layer to examine them and determine whether or not it can provide the required service. 11 QoS Parameters • • • • • • • • Connection establishment delay Connection establishment failure probability Throughput Transit delay Residual error ratio Protection Priority Resilience 12 Comparison with Data Link Layer • Similarity: both layers are focusing on how information is exchanged between two entities • Difference:Data link layer defines communications between stations with a physical connection, whereas transport layer protocols define communications between sites with a logical connection. • Two kinds of transport layer protocols: connection-oriented and connection-less. 13 Transport Layer Characteristics • Reliable: flow control and error recovery are provided • Two kinds: connection-oriented or connection-less • Example: Transmission Control Protocol(TCP), User Datagram Protocol(UDP) • Transport layer is the lowest layer which provides end-to-end services. The lower three protocols defines how network operates. 14 Transport Layer Functions • Logical connection establishment – the transport layer provides the “connection” the user perceives. • A user can log on to computers at remote sites, giving them the impression that they are connected. • But the connection is not a physical one as exists when connecting wires or making phone calls (using circuit switching). 15 Transport Layer Functions(cont’d) • It is similar to a secretary whose function is to place calls in behalf of an executive. The secretary gets the executive’s request, makes the call, and reaches the desired person, thus making the connection. • The executive then proceeds to have the conversation independent of the trouble that the secretary may have had in finding the desired person. 16 Transport Layer Functions(cont’d) • The connection management defines the rules that allow two users to begin talking with one another as if they were connected directly. The function of defining and setting up the connection is referred to as handshaking. 17 Transport Layer Functions(cont’d) • Graceful connection termination • The secretary may have to finish the connection by taking down some important information such as client’s address, checking the executive’s schedule for making a future appointment. • There are other functions. 18 Connection Oriented Transport Protocol Mechanisms • Example: Transmission Control Protocol(TCP) 19 Connection-less Transport Protocol Mechanisms • No connection-establishment • Datagram delivery • User Datagram Protocol(UDP) 20 Motivations • Why do we still need transport layer running on top of network layer? – They have similar connection-oriented and connection-less services. – They both provide addressing and flow-control 21 The answers are… • What happens if the network layer provides connection-oriented but unreliable service? Suppose that it frequently loses packets? What happens if routers crash all the time? • Users have no control over the subnet, so they cannot solve the problem of poor service by using better routers or putting more error handling in the data link layer. • So another layer is added to provide better quality of service(QoS). 22 Transport Layer Functions • Establishment of connectionless or connectionoriented communication • Addressing • Flow Control (transport layer) • Error detection (transport layer) • Interface with upper layers • Multiplexing • Quality of Service (QoS) In general, a transport layer protocol must provide reliable communications between end users. 23 0 8 16 31 Source IP Address Destination IP Address 00000000 Protocol = 17 Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication UDP Length 24 Figure 8.17 Application Application byte stream byte stream segments Transmitter Receiver Send buffer Receive buffer ACKs Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 25 Figure 8.18 Transmitter Receiver Send Window Receive Window Slast+Wa-1 ... Octets transmitted Slast and ACKed ... Srecent Rlast Rlast+WR+1 ... Rnext Rnew Slast+Ws-1 Slast oldest unacknowledged octet Srecent highest-numbered transmitted octet Slast+Wa-1 highest-numbered octet that can be transmitted Slast+Ws-1 highest-numbered octet that can be accepted from the application Rlast highest-numbered octet not yet read by the application Rnext next expected octet Rnew highest numbered octet received correctly Rlast+WR-1 highest-numbered octet that can be accommodated in receive buffer Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 26 Figure 8.19 TCP Header 27 0 4 10 16 Source Port 24 31 Destination Port Sequence Number Acknowledgement Number Header Length UAP R S F R C S S Y I GKH T NN Reserved Checksum Window Size Urgent Pointer Options Padding Data Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 28 Figure 8.20 0 8 16 31 Source IP Address Destination IP Address 00000000 Protocol = 6 TCP Segment Length Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 29 Figure 8.21 TCP Mechanisms (1) • Connection establishment – Three way handshake – Between pairs of ports – One port can connect to multiple destinations 30 TCP Mechanisms (2) • Data transfer – Logical stream of octets – Octets numbered modulo 223 – Flow control by credit allocation of number of octets – Data buffered at transmitter and receiver – Congestion control 31 TCP Mechanisms (3) • Connection termination – Graceful close – TCP users issues CLOSE primitive – Transport entity sets FIN flag on last segment sent – Abrupt termination by ABORT primitive • Entity abandons all attempts to send or receive data • RST segment transmitted 32 Host A Host B Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 33 Figure 8.22 Host A Host B Delayed segment with Seq_no = n+2 will be accepted Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 34 Figure 8.23 Host B (Server) Host A (Client) socket bind listen accept (blocks) socket connect (blocks) connect returns write read (blocks) accept returns read (blocks) read returns write read (blocks) read returns Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 35 Figure 8.24 Host A Host B t0 t1 t2 t3 t4 Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 36 Figure 8.25 Data 20 bytes of TCP header 20 bytes of IP header TCP Header IP Header Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 37 Figure 8.26 Host A Host B Deliver 150 bytes Copyright 2000 McGraw-Hill LeonGarcia and Widjaja Communication 38 Figure 8.27 CLOSED passive open, create TCB applic. close LISTEN SYN_RCVD applic. close, send FIN receive SYN, send ACK SYN_SENT applic. close or timeout, delete TCB ESTABLISHED CLOSE_WAIT FIN_WAIT_1 CLOSING LAST_ACK FIN_WAIT_2 2MSL timeout delete TCB Copyright 2000 McGraw-Hill LeonTIME_WAIT Garcia and Widjaja Communication 39 Figure 8.28 Flow Control • Credit Mechanism • A credit, stored in the segment’s window field, specifies the maximum number of bytes the entity (node) sending this segment can receive and buffer from the other entity (node). 40 Congestion Control • There are problems that the flow control mechanism cannot solve. • Assume that the previous discussion showed that the window sizes (credits) were adjusted based only on what A or B can handle. It didn’t take into account what might be in between. • What happens that A and B both are connected to others with T-1 links but use a link capable to transmit 64 kbps between A and B? 41 Congestion Window • Due to Jacobson [1988]- Jacobson’s algorithm • TCP is enhanced to allow a sending entity to respond to congestion links and to alter the number of segments it can send. 42 Congestion Window • We will focus on the transmission from A to B. • A maintains a congestion window that specifies the number of bytes it thinks it can send without causing or adding to congestion. • If the congestion window’s capacity is larger than A’s credit then A will still not send more than the credit allows. • Otherwise, A uses the congestion window’s value to determine how many segments to send. 43 Congestion Window • How can A determine when congestion exists? – Timeout mechanism • How does A respond to congestion? – reduce the size of the congestion window by half; resend; if timeout occurs again, the window size is reduced by half again. 44 Congestion Window • If the congestion is alleviated, A will increase the congestion window size and recalculate the sending window size. • Consequently, A will reduce the congestion window much more quickly than it will increase it. • A remaining question… 45 Congestion Window • How is the initial congestion window size determined? • It is similar to the recovery procedure after congestion. 46 Initial Value • A will reduce the congestion window much more quickly than it will increase it. • The startup procedure is called a slow start. 47 Window Management • Slow start – Actual window= MIN[credit, congested window] – Start connection with congested window size=1 – Increment congested window(cwnd) at each ACK, to some max • Dynamic windows sizing on congestion – When a timeout occurs – Set slow start threshold to half current congestion window • ssthresh=cwnd/2 – Set cwnd = 1 and slow start until cwnd=ssthresh • Increasing cwnd by 1 for every ACK 48 – For cwnd >=ssthresh, increase cwnd by 1 for each RTT Congestion Control • RFC 1122, Requirements for Internet hosts • Retransmission timer management – To control a lost or discard segment, TCP employs a retransmission timer which handles the retransmission time, the waiting time for an ACK of a segment. – For each connection, TCP maintains a variable, RTT, that is the best estimate of the current round trip time to the destination in question. When a segment is sent, a timer is started. 49 Congestion Control • When a timer is created, two situations can occur: – If an ACK is received for this particular segment before the timer goes off, the timer is destroyed. – If the timer goes off before the ACK is received, the segment is retransmitted and the timer is reset. 50 Calculation of the Retransmission Time • Retransmission = 2 * RTT • RTT: estimated Round-Trip Time 51 Calculation of RTT • RTT = * previous RTT + (1 - ) * current RTT • is usually set to 90%. 52 Karn’s Algorithm • Suppose that a segment is not acknowledged during the retransmission period and it is therefore retransmitted. When the sending TCP receives an ACK for this segment, it does not know if the ACK is for the original segment or for the retransmitted one. The value of the new RTT therefore must be calculated based on the departure of the segment. 53 Karn’s Algorithm • Do not consider the RTT of a retransmitted segment in the calculation of the new RTT. • Do not update the value of the RTT until you send a segment and receive an ACK without the need for retransmission. 54 Karn’s Algorithm • If a segment is re-transmitted, the ACK arriving may be: – For the first copy of the segment • RTT longer than expected – For second copy • • • • No way to tell Do not measure RTT for re-transmitted segments Calculate backoff when re-transmission occurs Use backoff RTO until ACK arrives for segment that has not been re-transmitted 55 Conceptual TCP Primitives • • • • • • Open - request Send - request Deliver - indication Accept - indication Terminate – confirm Etc. 56 Send • If no push or close TCP entity transmits at its own convenience • Data buffered at transmit buffer • May construct segment per data batch • May wait for certain amount of data 57 Deliver • In absence of push, deliver data at own convenience • May deliver as each in order segment received • May buffer data from more than one segment 58 Accept • Segments may arrive out of order • In order – Only accept segments in order – Discard out of order segments • In windows – Accept all segments within receive window 59 Retransmit • TCP maintains queue of segments transmitted but not acknowledged • TCP will retransmit if not ACKed in given time – First only – Batch – Individual 60 Acknowledgement • Immediate • Cumulative 61 UDP • User datagram protocol (UDP) runs on top of IP. • RFC 768 • Connectionless service for application level procedures – Unreliable – Delivery and duplication control not guaranteed • Reduced overhead • There is no formal mechanism for acknowledging errors or a provision for flow control or segment sequencing. 62 UDP Uses • • • • Inward data collection Outward data dissemination Request-Response Real time application 63 UDP Header 64 OSI vs. TCP • • • • • • Segment Types Important Data Graceful Termination Piggyback acknowledgement Sequencing Flow Control 65 Socket Programming • • • • • Sockets Client/Server Model Socket Data Structure Socket Commands Examples: Client Program, Server Program 66 Sockets • A socket is a UNIX construct and is the basis for UNIX networking services. • A socket is similar to an envelop in which information can be stored. 67 68 Client/Server Model An example of file transfer: • User requests a file. • Client sends request to the server on behalf of the user. • Server receives a request from a client and analyzes it. • Server copies a file from its auxiliary storage. • Server transmits contents of the file back to the client. • Client gets files’s contents from the server and make it accessible to the user. 69 Socket Data Structures 70 Socket Data Structures 71 Socket Data Structures 72 Socket Data Structures 73 RFCs regarding TCP & UDP • Transmission Control Protocol – Connection oriented – RFC 793 • User Datagram Protocol (UDP) – Connectionless – RFC 768 74 Suggested Reading • Sections 8.4 (UDP), 8.5 (TCP) • RFC793 (TCP) 768 (UDP) 1112 (Host Extensions for Multicasting) 75