Ak Tcpip Classppt
Ak Tcpip Classppt
Provides efficient, reliable, cost-effective service to processes in Application Layer using the services provided by the Network Layer. Provides a reliable service on top of the unreliable network.(is it needed?)
Reliable delivery service > Stream orientation as stream of bits. > Buffered Transfer > Virtual circuit connection > Unstructured stream - No record boundaries between data - The s and d must agree on stream format. > Full-Duplex connection
Provides buffering and flow control Takes care of lost packets, out of order, duplicates, long delays by Positive ACK Retransmission mechanism Isolates application program from network Hardware details Jargon
Segment = TCP packet Socket= source (address + port) + destination (address + port)
4
TCP FEATURES
Stream delivery Sending TCP
~ receives data as a stream of bytes from application process using sending buffer ~ make data to appropriate segments and transfer to network
Receiving TCP
~ receives segments using receiving buffer ~ reassemble segments to data and send data as a stream of bytes to application process
The sending process and the receiving process may not produce and consume data at the same speed, TCP needs buffers for storage. Both the buffers might vary in their size.
TCP groups sequence of bytes into a group of packets called SEGMENTS of varying size( default segment size is 536 bytes).
Send Buffers: The application gives the TCP layer some data to send. The data is put in a send buffer, where it stays until the data is ACKd. it has to stay, as it might need to be sent again! The TCP layer wont accept data from the application unless (or until) there is buffer space.
ACKs
A receiver doesnt have to acknowledge every segment except ACK segments. (It can acknowledge many segments with a single ACK segment). Each ACK can also contain outgoing data (piggybacking). Acknowledgements are delayed when the receiver has no data to send and is receiving an in-order segment ,say x+1, after acknowledging the xth segment. Delay can be until the next segment arrives or until a period of time. Prevents extra traffic out of ACK segments. When the segments come in order the ACK sent immediately by sending at least one ACK per two in-order segments. This prevents the unnecessary retransmission of packets.
8
ACKs
Immediate ACK sent when an out-of-order segment with sequence number higher than the expected arrives. This indirectly leads to fast retransmission. As soon as a missing segment arrives an ACK is sent to report the missing segment received. Immediate ACK when a duplicate segment is received. If a sender doesnt get an ACK after some time limit it resends the data. Each ACK is sent with sequence number so that the sender shall correctly associate ACKs with packets.
16
24
31
Source port
Destinati port
Sequence number Acknowledgement number HL Res Ctr Checksum Window Urgent ptr Paddg
31
The unit of data transfer b/w 2 devices using TCP is a segment. Source/Dest port: TCP port numbers to Identify applications at both ends of connection Sequence number: Identify position in senders byte stream. A 32 bit field defines the number assigned to the first byte of the data contained in this segment. First two sequence numbers used for connection establishment. [ it is not segment number but the offset of the byte within the total bytes to be sent from a process.] 10
Acknowledgement: identifies the number of the byte the receiver of this segment expects to receive next. Hlen: specifies the length of the segment header in 32 bit multiples. If there are no options, the Hlen = 5 (20 bytes). Can be between 5 and 15. Reserved 6bit field reserved for future use, set to 0 Ctrl: used to determine segment purpose with 6 different fields such as URG,ACK, PSH, RST, SYN and FIN Window Size: Advertises how much data this station is willing to accept. Maximum size is 65,535 bytes (216-1) Checksum: Verifies the integrity of the TCP header and data. It is mandatory. Follows the same procedure as per UDP. Pseudo header is attached with Protocol field being 6. Urgent pointer: Used with the URG flag to indicate where the urgent data starts in the data stream. Typically used with a file transfer abort during FTP or when pressing an interrupt key in telnet. Options: Max of 40 bytes field. Used for window scaling, SACK, timestamps, max segment size etc.
11
aida.poly.edu
mng.poly.edu
Send SYN
SYN (Seq No = x)
y, A SYN (SeqNo = ckNo = x + 1 )
ACK+SYN
(SeqNo = x
+1 , A c k N o
=y+1)
Initial sequence numbers (x, y) are chosen randomly (why??) Once connection established, data can flow in both directions, equally well. SYN FLOODING ATTACK DoS ??? and solution???
13
(3) and Y sends a FIN to X (passive close) (4) X ACKs the FIN.
14
Site 2
Rcv FIN segment Send ACK x=1 (inform app) 2 (app closes connection) Send FIN seq=y, ACK x+1 3 Receive ACK segment
App tells TCP to close, TCP sends remaining data & waits for ACK, then sends FIN 1 Site 2 TCP ACKs FIN, tells its application end of data 2 Site 2 sends FIN when its app closes connection (may be long delay (e.g. require human interaction). 3 Site 1 TCP ACKs FIN 4 ( signals 2 and 3 be combined hence made as 3-way close.)
15
Resetting Connections
Resetting connections is done by setting the RST flag When is the RST flag set?
Connection request arrives and no server process is waiting on the destination port Abort (Terminate) a connection due to abnormal situation. Causes the receiver to throw away buffered data. Receiver does not acknowledge the RST segment One side may discover that the TCP on the other side is idle for a long time. It sends an RST segment to destroy the connection.
16
PUSHING DATA - When delayed transmission and delayed delivery of data may not be acceptable by the application program. - To deliver the message as soon as possible without waiting for the window to be filled i.e., not to wait for more data to come. - TCP handles this by setting the push bit whenever an application program requests for a push operation.
17
TCP Buffers Both the client and server allocate buffers to hold incoming and outgoing data - The TCP layer does this. Both the client and server announce with every ACK how much buffer space remains (the Window field in a TCP segment is used for this ).
18
closing
opening
As per the acknowledgements from the receiver the window is opened or closed but should not shrunk. Probing - The window shall be shut down by sending the window size as 0. But the sender however sends a segment with one byte of data to prevent deadlock. Silly Window Syndrome Problem Using the network capacity very inefficiently by sending of data in very small segments.
19
21