630 likes | 1.71k Views
Recall: TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow ) client: connection initiator Socket clientSocket = new Socket("hostname","port number"); server: contacted by client
E N D
Recall:TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s buffers, flow control info (e.g. RcvWindow) client: connection initiator Socket clientSocket = new Socket("hostname","port number"); server: contacted by client Socket connectionSocket = welcomeSocket.accept(); Three way handshake: Step 1:client host sends TCP SYN segment to server specifies initial seq # no data Step 2:server host receives SYN, replies with SYNACK segment server allocates buffers specifies server initial seq. # Step 3: client receives SYNACK, replies with ACK segment, which may contain data TCP Connection Management Transport Layer
Closing a connection: client closes socket:clientSocket.close(); Step 1:client end system sends TCP FIN control segment to server Step 2:server receives FIN, replies with ACK. Closes connection, sends FIN. client server close FIN ACK close FIN ACK timed wait closed TCP Connection Management (cont.) Transport Layer
Step 3:client receives FIN, replies with ACK. Enters “timed wait” - will respond with ACK to received FINs Step 4:server, receives ACK. Connection closed. Note:with small modification, can handle simultaneous FINs. TCP Connection Management (cont.) client server closing FIN ACK closing FIN ACK timed wait closed closed Transport Layer
TCP Packets TCP adds “sessions” or “connections” to the bare IP protocol: Flags: Transport Layer
(SYN, C-Seq, 0) (SYN|ACK, S-Seq, C-Seq+1) (ACK, C-Seq+1, S-Seq+1) The 3-way handshake Labels below give (Flags, Seq#, Ack#): • To establish connection, client must prove that it received the SYN|ACK packet! • SYN|ACK packet routed to system with source address from first SYN packet • Since based on routing, only secure back to the subnet of the source Server Client Transport Layer
With fake Src: (SYN, C-Seq, 0) To fake Src: (SYN|ACK, S-Seq, C-Seq+1) (ACK, C-Seq+1, Predict-S-Seq+1) SYN Issues – Predictability • Sequence numbers should be unpredictable • Most systems today select random values that meet some necessary conditions • Otherwise: Client Server Data pretending to come from fake Src Particularly dangerous when “fake Src” is a trusted IP address Transport Layer
Half-open conn S-Seq1 (SYN, C-Seq3, 0) (SYN, C-Seq1, 0) (SYN, C-Seq2, 0) (SYN|ACK, S-Seq3, C-Seq3+1) (SYN|ACK, S-Seq2, C-Seq2+1) (SYN|ACK, S-Seq1, C-Seq1+1) Half-open conn S-Seq2 Half-open conn S-Seq3 . . . . . . SYN Issues – SYN Flooding Server Data Structures • DoS isn’t due to traffic volume but to resource exhaustion (memory) in the server O.S. • Early network stacks had a severely limited number of half-open structures available • Can spoof SRC address with non-existent host Client Server Transport Layer
TCP Limitations • provides strict ordering of information • result: Head of Line Blocking (HOL) problem • what is needed in many cases, is only partial ordering of data • byte oriented nature….inconvenience for telephony signaling • no built-in support for multi-homed IP hosts • vulnerability to SYN flooding attacks Transport Layer