Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Client Socket Interactions During Slow Start

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Client_Socket Interfaces (TCP Slow Start)

Client Node Internet EventStudio System Designer 6


Client Net
Client App Network 25-May-13 15:32 (Page 1)

This sequence diagram was generated with EventStudio System Designer (http://www.EventHelix.com/EventStudio).

TCP is an end to end protocol which operates over the heterogeneous Internet. TCP has no advance knowledge of the
network characteristics, thus it has to adjust its behavior according to the current state of the network. TCP has built in support
for congestion control. Congestion control ensures that TCP does not pump data at a rate higher than what the network can
handle.

In this sequence diagram we will analyse "Slow start", an important part of the congestion control mechanisms built right into
TCP. As the name suggests, "Slow Start" starts slowly, increasing its window size as it gains confidence about the networks
throughput.

Socket initialization
Server awaits client socket connections.

Client socket initialization

create Client Socket Client Application creates Socket

Closed The socket is created in the Closed state


seq_num = 0 Initial sequence number is set to 0

Active_Open Application wishes to communicate with a destination server using a


TCP connection. The application opens a socket for the connection in
active mode. In this mode, a TCP connection will be attempted with the
server.
Typically, the client will use a well known port number to communicate
with the remote Server. For example, HTTP uses port 80.
Client initiated three way handshake to
establish a TCP connection
SYN Client sets the SYN bit in the TCP header to request a TCP connection.
src = Client_Port, The sequence number field is set to 0. Since the SYN bit is set, this
dst = Server_Port, sequence number is used as the initial sequence number
seq_num = 0

SYN Sent Socket transitions to the SYN Sent state


SYN+ACK Client receives the "SYN+ACK" TCP segment
src = Server_Port,
dst = Client_Port,
seq_num = 100,
ack_num = 1,
window = 65535

ACK Client now acknowledges the first segment, thus completing the three
src = Client_Port, way handshake. The receive window is set to 5000. Ack sequence
dst = Server_Port, number is set to 101, this means that the next expected sequence
ack_num = 101, number is 101.
window = 5000

Established At this point, the client assumes that the TCP connection has been
established

A TCP connection starts in the "Slow Start" state. In this state, TCP adjusts its transmission rate based on the rate at which
the acknowledgements are received from the other end.

TCP Slow start is implemented using two variables, viz cwnd (Congestion Window)and ssthresh (Slow Start Threshold).
Client_Socket Interfaces (TCP Slow Start)
Client Node Internet EventStudio System Designer 6
Client Net
Client App Client Socket Network 25-May-13 15:32 (Page 2)

cwnd is a self imposed transmit window restriction at the sender end. cwnd will increase as TCP gains more confidence on
the network's ability to handle traffic. ssthresh is the threshold for determining the point at which TCP exits slow start. If cwnd
increases beyond ssthresh, the TCP session in that direction is considered to be out of slow start phase

TCP slow start


cwnd = 512 (1 segment) Client maintains a congestion window (cwnd). Initially the window is set
to lower of the maximum TCP segment size and receiver's allowed
window size. In most cases the segment size is smaller than receiver
window, thus cwnd is set to the maximum TCP segment size (512 in this
example)
Note here that cwnd implements a transmitter end flow control. The
receiver advertised window implements a receiver enforced flow control.
ssthresh = 65535 TCP connections start with ssthresh set to 64K. This variable will be
used to determine the point at which TCP exits slow start
Slow Start Client end TCP connection moves to slow start state
Data Client application sends 5120 bytes of data to the socket
size = 5120

Roundtrip #1 of data transmission


TCP Segment The first TCP segment is sent with a sequence number of 1. This is the
seq_num = 1, sequence number for the first byte in the segment.
len = 512

ACK Client receives the acknowledgement for the first TCP data segment
ack_num = 513

cwnd = 1024 (2 segments) As the TCP session is in slow start, receipt of an acknowledgement
increments the congestion window by one 1 segment.

Roundtrip #2 of data transmission


TCP Segment Since the congestion window has increased to 2, TCP can now send two
seq_num = 513, segments without waiting for an ack
len = 512

TCP Segment
seq_num = 1025,
len = 512

ACK
ack_num = 1537

cwnd = 1536 (3 segments) Receipt for ack again moves the congestion window

Roundtrip #3 of data transmission


TCP Segment Now three segments can be sent without waiting for an ack
seq_num = 1537,
len = 512

TCP Segment
seq_num = 2049,
len = 512
Client_Socket Interfaces (TCP Slow Start)
Client Node Internet EventStudio System Designer 6
Client Net
Client App Client Socket Network 25-May-13 15:32 (Page 3)

TCP Segment
seq_num = 2561,
len = 512

ACK The TCP acknowlegements again increment cwnd. This time two acks
ack_num = 2561 are received, so cwnd will get incremented by 2

cwnd = 2048 (4 segments)

ACK
ack_num = 3073

cwnd = 2560 (5 segments)

TCP Segment Since cwnd has reached 5 segments, TCP is allowed to send 5
seq_num = 3073, segments without waiting for the ack
len = 512

Roundtrip #4 of data transmission


TCP Segment
seq_num = 3585,
len = 512

TCP Segment
seq_num = _4097,
len = 512

TCP Segment
seq_num = _4609,
len = 512

TCP Segment
seq_num = _5121,
len = 512

ACK Three acknowledgements will be received for the 5 TCP segments. Now
ack_num = 4097 the cwnd has almost started increasing geometrically for every round trip
between the client and the server.
cwnd = 3072 (6 segments)

ACK
ack_num = 5121

cwnd = 3584 (7 segments)

ACK
ack_num = 5633

cwnd = 4096 (8 segments)

Roundtrip #5 of data transmission


TCP Segment This time 8 TCP segments are sent
TCP Segment
Client_Socket Interfaces (TCP Slow Start)
Client Node Internet EventStudio System Designer 6
Client Net
Client App Client Socket Network 25-May-13 15:32 (Page 4)

TCP Segment
TCP Segment
TCP Segment
TCP Segment
TCP Segment
TCP Segment
ACK Now four acks will be received, thus moving cwnd even more quickly
cwnd = 4608 (9 segments)

ACK
cwnd = 5120 (10 segments)

ACK
cwnd = 5630 (11 segments)

ACK
cwnd = 6144 (12 segments)

Within a few more roundtrip interactions cwnd will


exceed ssthresh. At this point the session will be
considered out of slow start. Note that the TCP
connection from the client side is out of slow start
but the server end is still in slow start as it has not
sent any data to the client.

Exiting slow start signifies that the TCP connection


has reached an equilibrium state where the
congestion window closely matches the networks
capacity. From this point on, the congestion
window will not move geometrically. cwnd will move
linearly once the connection is out of slow start.

Congestion Avoidance Once slow start ends, the session enters congestion avoidance state.
This will be discussed in a subsequent article.

Client closes TCP connection

Client to server TCP connection release


Close Client application wishes to release the TCP connection
FIN Client sends a TCP segment with the FIN bit set in the TCP header
FIN Wait 1 Client changes state to FIN Wait 1 state
ACK Client receives the ACK
FIN Wait 2 Client changes state to FIN Wait 2. In this state, the TCP connection
from the client to server is closed. Client now waits close of TCP
connection from the server end
Client_Socket Interfaces (TCP Slow Start)
Client Node Internet EventStudio System Designer 6
Client Net
Client App Client Socket Network 25-May-13 15:32 (Page 5)

Server to client TCP connection release


FIN Client receives FIN
ACK Client sends ACK
Close_Timer Client starts a timer to handle scenarios where the last ack has been lost
and server resends FIN
Time Wait Client waits in Time Wait state to handle a FIN retry
Close_Timer Close timer has expired. Thus the client end connection can be closed
too.
Closed

delete

This sequence diagram was generated with EventStudio System Designer (http://www.EventHelix.com/EventStudio).

You might also like