25Jan/1124

F2R001A TCP

In this exercise, we will study the TCP protocol used in the TCP/IP architecture to correct errors that the network layer may have introduced during packet forwarding.
Question 1: In which OSI layer is  TCP  ?
TCP is a connection oriented protocol with 3 phases: Opening, Data Transfer and Closing. The 14th byte is made of control bits indicating which filed are useful in the header and may be used to indicate the nature of the message (opening, closing,…).

 

 

 

 

 

 

 

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             data                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

 

 

 

 

 

 

The opening phase consists in the exchange of 3 packets, the client opens the connection by sending a message with the bit SYN set to 1, the server answers with a message with the SYN and ACK control bits set to one and the client answers withthe ACK control bit set to 1. Both hosts have to maintain a context (i.e. information stored in computer’s memory) called TCB (Transmission Control Block). This structure contains useful information to guaranty that all the information is received by the other end in the correct order.
The connection is closed by the exchange of 4 messages. One host (client or server) sends a message with FIN control bit set, the other end acknowledges the message. After it sends another message with the FIN control bit set. The first host acknowledges this message.
Finite State Machine
We call RTT (Round Trip Time) the time between the transmission of the first bit of the message and the reception of the last bit of the corresponding acknowledgment.
Question 2 How many RTTs are needed to open a connection ?
Question 3 How many RTTs are needed to close a connection ?
The following Finite State Machine describes the different states of a connection. An active OPEN means that the host is initiating the connection (client) and a passive OPEN that the host is waiting for connection (server).

 

 

 

 

 

 

 

 

                              +---------+ ---------\      active OPEN
                              |  CLOSED |            \    -----------
                              +---------+<---------\   \   create TCB
                                |     ^              \   \  snd SYN
                   passive OPEN |     |   CLOSE        \   \
                   ------------ |     | ----------       \   \
                    create TCB  |     | delete TCB         \   \
                                V     |                      \   \
                              +---------+            CLOSE    |    \
                              |  LISTEN |          ---------- |     |
                              +---------+          delete TCB |     |
                   rcv SYN      |     |     SEND              |     |
                  -----------   |     |    -------            |     V
 +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
 |         |<-----------------           ------------------>|         |
 |   SYN   |                    rcv SYN                     |   SYN   |
 |   RCVD  |<-----------------------------------------------|   SENT  |
 |         |                    snd ACK                     |         |
 |         |------------------           -------------------|         |
 +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
   |           --------------   |     |   -----------
   |                  x         |     |     snd ACK
   |                            V     V
   |  CLOSE                   +---------+
   | -------                  |  ESTAB  |
   | snd FIN                  +---------+
   |                   CLOSE    |     |    rcv FIN
   V                  -------   |     |    -------
 +---------+          snd FIN  /       \   snd ACK          +---------+
 |  FIN    |<-----------------           ------------------>|  CLOSE  |
 | WAIT-1  |------------------                              |   WAIT  |
 +---------+          rcv FIN  \                            +---------+
   | rcv ACK of FIN   -------   |                            CLOSE  |
   | --------------   snd ACK   |                           ------- |
   V        x                   V                           snd FIN V
 +---------+                  +---------+                   +---------+
 |FINWAIT-2|                  | CLOSING |                   | LAST-ACK|
 +---------+                  +---------+                   +---------+
   |                rcv ACK of FIN |                 rcv ACK of FIN |
   |  rcv FIN       -------------- |    Timeout=2MSL -------------- |
   |  -------              x       V    ------------        x       V
    \ snd ACK                 +---------+delete TCB         +---------+
     ------------------------>|TIME WAIT|------------------>| CLOSED  |
                              +---------+                   +---------+

Question 4 Looking at the finite state machine, what happens if both the server and the client send a SYN message to the other one?

 

 

 

 

 

 

 

 

 

$  netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address    Foreign Address   State
tcp        0      0 localhost:56952  localhost:ldap    ESTABLISHED
tcp        0      0 localhost:ldap   localhost:40022   CLOSING
tcp        0      0 localhost:ldap   localhost:56952   ESTABLISHED

 

 

 

The previous command gives the state of TCP connections on a machine.
Question 5 Give an explanation of the CLOSING state for the second connection.
Question 6 Do routers in the network have to maintain states like TCB when a TCP connection is opened? Why ?
Question 7 In which conditions a TCB is created on a server ?
Question 8 In which condition a TCB is destroyed ?
Question 9 A malicious host decides to send plenty of SYN messages to a server, what may happen after a certain period of time ?
Packet Format
Question 10 The Ethernet frame imposes a SDU of 1500. In a IP-PDU, the header is 20 Byte long, what will be the SDU size of a TCP-PDU ?
Performances
During the opening phase, TCP exchanges a 32 bit sequence number in the SEQUENCE NUMBER field of the message header. Contrary to LAP-B or X.25,  TCP numbers the exchanged bytes, and the Acknowledgement Number field contains the next expected byte number.
Question 11 If we suppose a link speed of 100 MBit/s and a continuous transmission of information, how long will it take to use the 2^32 values of the sequence field.
Question 12 The CERN in Geneva opens a TCP connection with a laboratory located in Chicago to transfer information concerning LHC (Large Hadron Collider) experiments. A dedicated link at 100 MBit/s is used. How many unacknowledged messages have to be sent to continuously send TCP messages?
Question 13 CERN plans to increase the transmission speed to 1TBit/s, what will be the problem with the current version of TCP, especially with the sequence and acknowledge fields ?
Acknowledgment optimisation

RFC 793 gives the definition of the acknowledgement field:

 

 

 

 

Acknowledgment Number:  32 bits
If the ACK control bit is set this field contains the value of the
next sequence number the sender of the segment is expecting to
receive.

 

 

You can note that there is no negative acknowledgment, TCP will only positively acknowledge a correct sequence and will not give any feedback of incorrect sequences.
Question 14 in the following scheme, give the acknowledge field value
RFC 793 says:

 

 

 

 

Retransmission Timeout
Because of the variability of the networks that compose an
internetwork system and the wide range of uses of TCP connections the
retransmission timeout must be dynamically determined.  One procedure
for determining a retransmission time out is given here as an
illustration.
An Example Retransmission Timeout Procedure
Measure the elapsed time between sending a data octet with a
particular sequence number and receiving an acknowledgment that
covers that sequence number (segments sent do not have to match
segments received).  This measured elapsed time is the Round Trip
Time (RTT).  Next compute a Smoothed Round Trip Time (SRTT) as:
SRTT = ( ALPHA * SRTT ) + ((1-ALPHA) * RTT)
and based on this, compute the retransmission timeout (RTO) as:
RTO = min[UBOUND,max[LBOUND,(BETA*SRTT)]]
where UBOUND is an upper bound on the timeout (e.g., 1 minute),
LBOUND is a lower bound on the timeout (e.g., 1 second), ALPHA is
a smoothing factor (e.g., .8 to .9), and BETA is a delay variance
factor (e.g., 1.3 to 2.0).

 

 

Question 15 For what purpose RTO is used ? Why is it necessary to compute dynamically its value?
Question 16 When computing the timeout is it better to underestimate or overestimate the RTO value? Why?
All implementations of TCP make the assumption that when a sender receives 4 times the same acknowledgment value, this can be considered as a negative acknowledgement.
Question 17 Why this proposition increases TCP performance ?
Question 17 Which major assumption is made on the network  to allow this optimization ?

This content is published under the Attribution-Noncommercial-No Derivative Works 3.0 Unported license.

Tags: , ,

24 Responses to “F2R001A TCP”

  1. admin says:

    Question 1: In which OSI layer is  TCP  ?


    TCP is above IP and is used to control that all messages are received in a correct order, it is by definition a Tranport (L4) protocol.
  2. admin says:

    Question 2 How many RTTs are needed to open a connection ?
    It takes 1.5 RTT to open a connection: the client will be notified after one RTT and the server 1.5 RTTs after the client initiates it.
  3. admin says:

    Question 3 How many RTTs are needed to close a connection ?


    It takes two RTTs to close a connection
  4. admin says:

    Question 4 Looking at the finite state machine, what happens if both the server and the client send a SYN message to the other one?

    
    
                   client                      server

                CLOSED                   CLOSED
                CLOSED                   LISTEN
                              ----SYN--->  
                             <---SYN---  
                 SYN SENT              SYN SENT
                            ----ACK--->
                            <---ACK--- 
                  ESTAB                  ESTAB

  5. admin says:

    Question 5 Give an explanation of the CLOSING state for the second connection.
    The device has sent an FIN message currently not acknowledged (or lost)
  6. admin says:

    Question 6 Do routers in the network have to maintain states like TCB when a TCP connection is opened? Why ?


    No, TCB are just maintained in the client and server, router are working at layer 3 and IP is a datagram protocol so they just forward packets and ignore their content (e.g. TCP PDU).
  7. admin says:

    Question 7 In which conditions a TCB is created on a server ?
    Each time a SYN message is sent or received 
  8. admin says:

    Question 8 In which condition a TCB is destroyed ?


    After a Timeout of 2MSL when FIN message is acknowledged  or when the upper layer destroy the context
  9. admin says:

    Question 9 A malicious host decides to send plenty of SYN messages to a server, what may happen after a certain period of time ?


    Server memory can be saturated and server will crash
  10. admin says:

    Question 10 The Ethernet frame imposes a SDU of 1500. In a IP-PDU, the header is 20 Byte long, what will be the SDU size of a TCP-PDU ?


    The TCP header given at the beginning of the exam gives a TCP header size of 20 Bytes (to simplify the exercise we have omitted options which can lead to a TCP header of 60 Bytes). So the TCP-SDU size will be 1500-20-20=1460 Bytes 
  11. admin says:

    Question 11 If we suppose a link speed of 100 MBit/s and a continuous transmission of information, how long will it take to use the 2^32 values of the sequence field.




    Each message contains 1460 Bytes of information, the sequence field allows to number 2^32 Bytes, so this lead to $4 294 967 296/1 460=2 941 758.42 packets, almost  3.10^6  packets. For each packet, it takes 1500*8/100.10^6=120.10^-6 s. It takes about 360 s to go around the counter.

  12. admin says:

    Question 12 The CERN in Geneva opens a TCP connection with a laboratory located in Chicago to transfer information concerning LHC (Large Hadron Collider) experiments. A dedicated link at 100 MBit/s is used. How many unacknowledged messages have to be sent to continuously send TCP messages?
    Propagation delays is 50 ms. When a packet is fully sent it have to wait 2 propagation delays and the ack message to be acknowleged, so 2*50+40*8/100.10^6 s= 103.2 ms. SInce a packet is sent in 120ms, an anticipation window of two packets is enough. 
    • pablo says:

      Good evening professor, why do we say that there is a propagation delay of 50ms? is the duration of the acknowledgement message 40 ms? how did we obtain this value for the ack mesagge?Sorry to bother you in the holidays.Best regards

      • admin says:

        It is a common value, if you do a ping between France and US you should find something close to 50 to 100 ms:

        The TCP ack is about 40 Bytes (20 for IP and 20 for TCP).  In our case a TCP ack is a normal message without data.
  13. admin says:

    Question 13 CERN plans to increase the transmission speed to 1TBit/s, what will be the problem with the current version of TCP, especially with the sequence and acknowledge fields ?


    As seen before 2^32 is about 4.10^9 Bytes or 32.10^9 bits. So if the throughput is higher than 32.10^9/0.1= 320 Gbit/s the sequence field will be exhausted before getting the acknowledgment. If the sender continues to send information, sequence number will not be unique and we will have ambiguous ack field

    Some of you, propose to use the same trick as in HDLC and to force the receiver to send an ACK0 to avoid confusion. Here it will not work since the sending rate is too high and the propagation delays will make that this ACK will never reach in time the sender. The only possibility to avoid confusion is to force the sender to stop after sending the full window (minus 1 byte), but performances will be bad since the link will no be fully used

  14. admin says:

    Question 14 in the following scheme, give the acknowledge field value
    – ACK 1020

    – ACK 1050

    – ACK 1050

    – ACK 1050

    – ACK 1050



    • Hendrik says:

      Good morning professor. I do not understand why after the first ack, the number does not change. Could you please explain it?

      • admin says:

        Because TCP is a very optimistic protocol and never give bad news to the sender. TCP will just inform that until byte 1020 it was ok. Then due to anticipation protocol the sender continue to send packets, TCP will continue to acknowledge until byte 1020 it was ok. In fact TCP memorize out of sequence messages and when the gap is filled, TCP will acknowledge all data it has received. 

        The optimisation we show here is that when TCP says it is OK before X too many times it means that there is a problem after X and that sequence has to be sent again.
  15. admin says:

    Question 15 For what purpose RTO is used ? Why is it necessary to compute dynamically its value?


    TCP is other a datagram network. if both hosts are located on the same link RTT will be very short, if hosts use slow link and propagation delays are high, the RTT value will be high. It is impossible to have a unique value for any case. The delay in the network can also change due to congestion or routing changes

    Some of you said that the RTO value depends on the error rate of the link, this is not true the formula only depend of RTT (error rate is used by TCP to reduce transmission rate to avoid network congestions, but that’s another story)

  16. admin says:

    Question 16 When computing the timeout is it better to underestimate or overestimate the RTO value? Why?



    underestimate a RTT will lead to unnecessary send again the same information, this may saturate some part of the network. Overestimate will make transmission less efficient. The second solution is the best because it has only an impact to the users of the connection not all the users of the network.

    Some of you answered that it is better not to over or under estimate the RTO value. This will be of course the best solution, but in the previous question we saw that the transmission time may vary due to network congestions (packet stays longer in routers memory) or rerouting (less frequent). So it is impossible to have the RTT exact value.

  17. admin says:

    Question 17 Why this proposition increases TCP performance ?
    As stated before, it is better to overestimate RTO timer, duplicate ACK will allow to discover earlier a packet loss
  18. admin says:

    Question 18 Which major assumption is made on the network  to allow this optimization ?
    Packet should be received in the correct order, if a packet is de-sequenced more than 4 packets, it will generate a retransmission

    Some of you said that the receiver has also to acknowledge every message.

  19. Siratinee says:

    Q.11) In the class we calculated from 2^32/2^5 = 2^27 bits.So the time is 2^27/ 100*10^6 s.From the answer above, it means that this question is continuously from Q.10? 

    • admin says:

      Hi, I don’t remember 🙂 yes the previous question allowed us to know the data size un TCP-PDU

Leave a Reply

Your email address will not be published. Required fields are marked *