RSS

Established TCP connection

22 Dec

    TCP connection is connected protocol. We will take a closer look at the states  and how to handled basic TCP protocol.

    To guaranteed the safe connection. We need to established the connection until close session. Detail:

    1. Established connection(3-way handshake)

    2. Transmitted Data

    3. Close connection (4-way handshake)

    4. Established connection:

      clip_image001

       

      To established TCP connection, it’s always initiated with 3-way handshake, which establishes and negotiates(đàm phán) the actual connection over sending data.

      Before begin 3-way handshake. We have one listening connection on server. So, server need to register one static connection on one static port connection . This is passive connection and listen connection from client.

       

    tcp      6 117 SYN_SENT src=192.168.1.5 dst=192.168.1.35 sport=1031 \

         dport=23 [UNREPLIED] src=192.168.1.35 dst=192.168.1.5 sport=23 \

         dport=1031 use=1

     

    Way-1: Client send SYN packet to server . This is new connection and could be block if don’t register by firewall. The SYN_SENT is flag set.

     

    tcp      6 57 SYN_RECV src=192.168.1.5 dst=192.168.1.35 sport=1031 \

         dport=23 src=192.168.1.35 dst=192.168.1.5 sport=23 dport=1031 \

         use=1

     

    Way-2: After than, Server will feedback  corresponding SYN_RECV packet. This is accepted from server to client . Client will receive and tell " ready send" to end of 3-way handshake.

     

    tcp      6 431999 ESTABLISHED src=192.168.1.5 dst=192.168.1.35 \

         sport=1031 dport=23 src=192.168.1.35 dst=192.168.1.5 \

         sport=23 dport=1031 use=1

      

    Way-3: Client will send established flag. After more packets, the connection will also become [ASSURED]

     

    Close Connection:

    clip_image002

      

    Ending of connection, stations always using the 4-way-handshake. One station will send FIN packet to done connection. Stepping follow picture. After that station stop send and wait other station ending session. In other station, it do that, too. After that, 2 station ending with together.

    References:

    http://faqs.org

    written by hotdream1990

     
    Leave a comment

    Posted by on December 22, 2010 in Java, TCP/IP

     

    Tags: ,

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s