Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 21 and 22 5/29/2019.

Similar presentations


Presentation on theme: "Lecture 21 and 22 5/29/2019."— Presentation transcript:

1 Lecture 21 and 22 5/29/2019

2 Overview TCP = Transmission Control Protocol
Connection-oriented protocol Provides a reliable unicast end-to-end byte stream over an unreliable internetwork. 5/29/2019

3 Connection-Oriented Before any data transfer, TCP establishes a connection: One TCP entity is waiting for a connection (“server”) The other TCP entity (“client”) contacts the server The actual procedure for setting up connections is more complex. Each connection is full duplex 5/29/2019

4 Reliable Byte stream is broken up into chunks which are called seg-ments Receiver sends acknowledgements (ACKs) for segments TCP maintains a timer. If an ACK is not received in time, the segment is retransmitted Detecting errors: TCP has checksums for header and data. Segments with invalid checksums are discarded Each byte that is transmitted has a sequence number 5/29/2019

5 TCP header fields Port Number:
A port number identifies the endpoint of a connection. A pair <IP address, port number> identifies one endpoint of a connection. Two pairs <client IP address, server port number> and <server IP address, server port number> identify a TCP connection. 5/29/2019

6 TCP overview TCP is the most widely used Internet protocol
Web, Peer-to-peer, FTP, telnet, … A two way, reliable, byte stream oriented end-to-end protocol Includes flow and congestion control Closely tied to the Internet Protocol (IP) A focus of intense study for many years. 5/29/2019

7 TCP Features Connection-oriented Byte-stream Reliable data transfer
app writes bytes TCP sends segments app reads bytes Reliable data transfer Full duplex Flow control: keep sender from overrunning receiver Congestion control: keep sender from overrunning network Application process W rite bytes TCP Send buffer Segment T ransmit segments Read Receive buffer 5/29/2019

8 TCP Format TCP segments have a 20 byte header with >= 0 bytes of data. 5/29/2019

9 Segment Format 5/29/2019

10 Segment Format Each connection identified with 4-tuple:
(SrcPort, SrcIPAddr, DsrPort, DstIPAddr) 5/29/2019

11 TCP header fields Sequence Number (SeqNo):
Sequence number is 32 bits long. So the range of SeqNo is 0 <= SeqNo <=  4.3 Gbyte Each sequence number identifies a byte in the byte stream Initial Sequence Number (ISN) of a connection is set during connection establishment 5/29/2019

12 TCP header fields Acknowledgement Number (AckNo):
Acknowledgements are piggybacked, I.e a segment from A -> B can contain an acknowledgement for a data sent in the B -> A direction A hosts uses the AckNo field to send acknowledgements. (If a host sends an AckNo in a segment it sets the “ACK flag”) The AckNo contains the next SeqNo that a hosts wants to receive Example: The acknowledgement for a segment with sequence numbers is AckNo=1501 5/29/2019

13 TCP header fields Acknowledge Number (cont’d) Example:
TCP uses the sliding window flow protocol (see CS 457) to regulate the flow of traffic from sender to receiver TCP uses the following variation of sliding window: no NACKs (Negative ACKnowledgement) only cumulative ACKs Example: Assume: Sender sends two segments with “ ” and “ ”, but receiver only gets the second segment. In this case, the receiver cannot acknowledge the second packet. It can only send AckNo=1 5/29/2019

14 TCP header fields Header Length ( 4bits):
Length of header in 32-bit words Note that TCP header has variable length (with minimum 20 bytes) 5/29/2019

15 TCP header fields Flag bits: URG: Urgent pointer is valid
If the bit is set, the following bytes contain an urgent message in the range: SeqNo <= urgent message <= SeqNo+urgent pointer ACK: Acknowledgement Number is valid PSH: PUSH Flag Notification from sender to the receiver that the receiver should pass all data that it has to the application. Normally set by sender when the sender’s buffer is empty 5/29/2019

16 TCP header fields Flag bits: RST: Reset the connection
The flag causes the receiver to reset the connection Receiver of a RST terminates the connection and indicates higher layer application about the reset SYN: Synchronize sequence numbers Sent in the first packet when initiating a connection FIN: Sender is finished with sending Used for closing a connection Both sides of a connection must send a FIN 5/29/2019

17 TCP header fields Window Size: TCP Checksum: Urgent Pointer:
Each side of the connection advertises the window size Window size is the maximum number of bytes that a receiver can accept. Maximum window size is 216-1= bytes TCP Checksum: TCP checksum covers over both TCP header and TCP data (also covers some parts of the IP header) Urgent Pointer: Only valid if URG flag is set 5/29/2019

18 TCP Connection-oriented
Sets up the connection prior to data transmission SYN and 3-way handshake Guarantees delivery of data Sender holds a copy of the data for retransmission if necessary Receiver ACKS specific byte positions in the stream so sender can resend from any byte position 5/29/2019

19 TCP Connection Establishment
TCP uses a three-way handshake to open a connection: (1) ACTIVE OPEN: Client sends a segment with SYN bit set * port number of client initial sequence number (ISN) of client (2) PASSIVE OPEN: Server responds with a segment with initial sequence number of server ACK for ISN of client (3) Client acknowledges by sending a segment with: ACK ISN of server (* counts as one byte) 5/29/2019

20 Connection Establishment
Active participant Passive participant (client) (server) SYN, SequenceNum = x y , + 1 SYN + ACK, SequenceNum = x Acknowledgment = ACK, Acknowledgment = y + 1 5/29/2019

21 Connection Termination
Active participant Passive participant (server) (client) FIN, SequenceNum = x + 1 x Acknowledgment = y FIN, SequenceNum= Acknowledgment = y + 1 5/29/2019

22 UDP 5/29/2019

23 User datagram format 5/29/2019

24 Example 14.1 The following is a dump of a UDP header in hexadecimal format. a. What is the source port number? b. What is the destination port number? c. What is the total length of the user datagram? d. What is the length of the data? e. Is the packet directed from a client to a server or vice versa? f. What is the client process? 5/29/2019

25 Example 14.1 Continued Solution
a. The source port number is the first four hexadecimal digits (CB84)16 or b. The destination port number is the second four hexadecimal digits (000D)16 or 13. c. The third four hexadecimal digits (001C)16 define the length of the whole UDP packet as 28 bytes. d. The length of the data is the length of the whole packet minus the length of the header, or 28 – 8 = 20 bytes. e. Since the destination port number is 13 (well-known port), the packet is from the client to the server. f. The client process is the Daytime (see Table 14.1). 5/29/2019

26 5/29/2019

27 Figure 14.5 Encapsulation and decapsulation
5/29/2019

28 Figure 14.7 Multiplexing and demultiplexing
5/29/2019

29 UDP APPLICATION A client-server application such as DNS uses the services of UDP because a client needs to send a short request to a server and to receive a quick response from it. The request and response can each fit in one user datagram. Since only one message is exchanged in each direction, the connectionless feature is not an issue; the client or server does not worry that messages are delivered out of order. 5/29/2019

30 Example A client-server application such as SMTP, which is used in electronic mail, cannot use the services of UDP because a user can send a long message, which may include multimedia (images, audio, or video). If the application uses UDP and the message does not fit in one single user datagram, the message must be split by the application into different user datagrams. Here the connectionless service may create problems. The user datagrams may arrive and be delivered to the receiver application out of order. The receiver application may not be able to reorder the pieces. This means the connectionless service has a disadvantage for an application program that sends long messages. 5/29/2019

31 Example Assume we are downloading a very large text file from the Internet. We definitely need to use a transport layer that provides reliable service. We don’t want part of the file to be missing or corrupted when we open the file. The delay created between the delivery of the parts are not an overriding concern for us; we wait until the whole file is composed before looking at it. In this case, UDP is not a suitable transport layer. 5/29/2019

32 Example Assume we are watching a real-time stream video on our computer. Such a program is considered a long file; it is divided into many small parts and broadcast in real time. The parts of the message are sent one after another. If the transport layer is supposed to resend a corrupted or lost frame, the synchronizing of the whole transmission may be lost. The viewer suddenly sees a blank screen and needs to wait until the second transmission arrives. This is not tolerable. However, if each small part of the screen is sent using one single user datagram, the receiving UDP can easily ignore the corrupted or lost packet and deliver the rest to the application program. That part of the screen is blank for a very short period of the time, which most viewers do not even notice. However, video cannot be viewed out of order, so streaming audio, video, and voice applications that run over UDP must reorder or drop frames that are out of sequence. 5/29/2019


Download ppt "Lecture 21 and 22 5/29/2019."

Similar presentations


Ads by Google