Presentation on theme: "Transportation Layer (2). TCP full duplex data: – bi-directional data flow in same connection – MSS: maximum segment size connection-oriented: – handshaking."— Presentation transcript:
TCP full duplex data: – bi-directional data flow in same connection – MSS: maximum segment size connection-oriented: – handshaking (exchange of control msgs) init’s sender, receiver state before data exchange flow controlled: – sender will not overwhelm receiver point-to-point: – one sender, one receiver reliable, in-order byte steam: – no “message boundaries” pipelined: – TCP congestion and flow control set window size send & receive buffers
TCP segment structure source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number Receive window Urg data pnter checksum F SR PAU head len not used Options (variable length) URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) # bytes rcvr willing to accept counting by bytes of data (not segments!) Internet checksum (as in UDP)
TCP Connection Setup – Three-Way Handshake Connection initiator (the client) – Chooses unique seqno x and sends req-conn(x) Connection respondent (the server) – Upon receiving req-conn(x) Chooses its own unique identifier, y Sends ack-conn(y,x+1) Upon receiving ack-conn(y,x+1), client responds – With ack-conn(x+1,y+1) SYN (SEQ=x) SEQ=x+1, ACK=y+1) SYN (SEQ=y, ACK=x+1) Con. Set up Con. Set up A B
TCP connection set up The initial sequence number is picked based on the clock The clock ticks every 4 us
TCP Connection Management: establish a connection TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: – seq. #s – buffers, flow control info client: connection initiator server: contacted by client Three-way handshake: Step 1: client end system sends TCP SYN control segment to server – specifies initial seq # Step 2: server end system receives SYN, replies with SYNACK control segment – ACKs received SYN – allocates buffers – specifies server receiver initial seq. # Step 3: client replies with an ACK segment
TCP connection set up When setting up the connection, a connection is considered set up by B when B is sure that (0) B knows about the connection (1) A knows about the connection and (2) A knows that B is about to open the connection. Similar does A.
TCP Connection Close How about the close of connections? Can we achieve: When closing the connection, a connection is considered closed by B when B is sure that (0) B knows about the closing (1) A knows about the closing and (2) A knows that B is about to close the connection. Similar does A.
TCP connection close Three way handshake: A sends disconnection request (DR) to B. B replies with an ACK1. A sends an ACK2 for the ACK1, and releases the connection. When B receives the ACK2, he releases the connection. DR ACK2 ACK1 Con. close Con. close A B
Connection close The problem is the DR and ACK can be lost What if ACK2 is lost? If B does not receive ACK2, he won’t release the connection, because he is not sure whether A knows he is about to close the connection. He will keep on resending ACK1. But A is gone. Different from setting up a connection. When A is up, keeping on resending will generate a reply somehow. DR ACK2 ACK1 Con. close Con. close A B lost
Connection close So, three-way handshaking doesn’t work. Should we ask A to wait until received ACK3 from B? DR ACK2 ACK1 Con. close Con. close A B ACK3
Connection close What if ACK3 is lost? Adding ACK4? Apparently this can go on and on forever. The net effect is, neither of A and B can release the connection, if they want to release the connection gracefully. DR ACK2 ACK1 Con. close Con. close A B ACK3 lost
Modified three-way handshake: client closes socket: Step 1: client end system sends TCP FIN control segment to server Step 2: server receives FIN, replies with ACK. Sends FIN. TCP Connection Management: close a connection client FIN server ACK FIN close closed time wait Step 3: client receives FIN, replies with ACK. Enters “time wait” - will respond with ACK to received FINs Step 4: server, receives ACK. Connection closed. Socket programming interface close() vs shutdown() closed
TCP Seq. #’s and ACKs time Host A Host B Seq=42, ACK=79, data = ‘C’ Seq=79, ACK=43, data = ‘C’ Seq=43, ACK=80 User types ‘C’ host ACKs receipt of echoed ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ simple telnet scenario Seq. #’s: byte stream “number”of first byte in segment’s data ACKs: seq # of next byte expected from other side – cumulative ACK
TCP SYN/FIN Sequence # TCP SYN/FIN packets consume one sequence number For simplification, seq # counts pkts numbers In reality, it is byte counts client server SYN(J) SYN/ACK(K,J+1) ACK(K+1) FIN(M) ACK(M+1) FIN(N) ACK(N+1) DATA(J+1) ACK(J+2)
Data transmission Theoretically, for every packet sent for which the sender expects an ACK, – A timer is started What is the timeout duration? – When timer expires, this packet retransmitted – This applies to both data packets and control packets SYN and FIN – Note that ACK is cumulative Receiver – Accept out-of-order packets – Respond by acking last pkt received in order
Host A Seq=92, 8 bytes data ACK=100 loss timeout time lost ACK scenario Host B X Seq=92, 8 bytes data ACK=100 Host A Seq=100, 20 bytes data ACK=100 Seq=92 timeout time premature timeout, cumulative ACKs Host B Seq=92, 8 bytes data ACK=120 Seq=92, 8 bytes data Seq=100 timeout ACK=120
Your consent to our cookies if you continue to use this website.