TCP/UDP Questions/Problems

October 12, 2017


  1. Which transport protocol will you use for developing an application which is based on wireless networks such as 802.11?

    (Ans: Since 802.11 is an unreliable medium, the preferred transport layer protocol is TCP unless the application itself does not require reliability.)

  2. What is the demultiplexing field in UDP or TCP?

    (Ans: Destination Port)

  3. If the path from the source to the destination has the following MTUs on the links of the path – 1500, 1500, 3100, 576, 1500, 3100 – what is the size of the MSS in TCP?

    (Ans: Path MTU is the minimum MTU of the path – 576. MSS is 576-40 = 536.)

  4. An application uses UDP to send 7000 bytes of data in a single message on a path with MTU = 1500 and there is an error in one of the fragments transmitted. The application is a reliable application and so retransmits the 7000B again. How much more data is transmitted by this application as compared to it using TCP as the transport protocol?

    (Ans: UDP transmits 14000B – since this will be split into segments of 1460 and there will be five segments and only one is lost, TCP transmits 8460B – i.e., 5540B more data is transmitted by UDP)

  5. What is the problem with estimating RTT when a segment is retransmitted?

    (Ans: There is no way to decide whether the ack. received is to the first or second transmission. In one case we have an unnecessarily long timeout interval keeping the line idle and in the other we have a shorter time interval than the real one. This leads to too many retransmissions and so adds to the congestion.)

  6. When a retransmission timeout occurs, what does Karn's algorithm propose that TCP should do?

    (Ans: Karn's algorithm states that no RTT estimate should be made with this sample. Instead, the timeout should be exponentially backed off and a retransmission made.)

  7. What is the purpose of the URG bit in TCP?

    (Ans: URG is set to indicate that the segment carries out-of-order data.)

  8. What is the purpose of the PSH bit in TCP?

    (Ans: PSH bit is set to indicate that there should be no buffering for the data in question. Typically used by interactive applications.)

  9. The segments of data sent in a new connection have 100B, 200B, 300B, 200B and 100B. The acknowledgments received are 101, 101, 601, 601 and 901 without a retransmission timeout. What is the order in which the datagrams may have been received?

    (Ans: The first segment should return an ack of 101 since it is the next expected in-sequence byte. When it is received again, it means that the second segment has not reached but some other segment has reached the receiver. You cannot tell which segment yet. When the next segment's ack comes and it is 601, you know that 600B have been received in sequence. This means that the second and third segments have been received and so on. )

  10. Why does TCP header have a header length field whereas UDP does not?

    (Ans: Because TCP has options unlike UDP.)

  11. Which of client and server does active and passive TCP socket open?

    (Ans: The server opens a listening socket and just waits for connections – therefore it is called passive open (look up the meaning of passive vs active in the dictionary). The client actually initiates the connection through the 3-way handshake and so is called active open.)

  12. Why are ports used in UDP and TCP and not process IDs of the client/server processes?

    (Ans: Process IDs need not be same when run across machines or even within one machine across different times. Thus, they cannot be used to identify a server process by a client trying to reach it.)

  13. What is the difference between window and MSS in TCP?

    (Ans: Window is the buffer space available in the receiver – it represents the maximum amount of data that can be transmitted to the receiver without getting any ack. MSS represents the maximum amount of data that can be sent in a single segment.)

  14. What are the contents of the pseudo header used in UDP and TCP checksum calculations and why?

    (Ans: )

  15. What is the method for TCP to open a connection?

    (Ans: Open uses 3-way SYN handshake and Close uses 3-way FIN handshake.)

  16. Give an example of an application where UDP is better than TCP? Why?

(Ans: An application which requires less latency and no reliability such as video streaming

where the loss of a single datagram does not affect the user experience)

  1. When does a source get an ICMP_DEST_UNREACH/NET_UNREACH message?

(Ans: Whenever a router does not find a matching entry for the destination IP address)

  1. An operating system sets the DF bit to 1 by default. What ICMP message is sent if the datagram size is more than the Path MTU?

    (Ans: ICMP_DEST_UNREACH/DF_BIT_IS_SET_BUT_FRAG_NEEDED)

  2. Given the topology and H1 tries to ping H3, what ICMP message does it get as reply?

  3. A fragment is lost due to noise on the path to the destination. What ICMP message, if any, does the source get?

    (Ans: It gets the ICMP message TIME_EXCEEDED/REASSEMBLY TIMER EXPIRED)

  4. If a datagram is lost due to noise, what ICMP message, if any, does the source get?

    (Ans: It does not get any ICMP message)

  5. Given the topology and the routing table entries, what happens when H1 tries to ping to the machine with a host IP not found?

  6. What is a well-known port number?

    (Ans: The port number of a standard application whose port is decided by IANA)

  7. How is the port number of a client connection obtained?

    (Ans: The kernel gives the next available free port no as the client port)

  8. Can a server have the port number decided by the operating system? Give the reason.

    (Ans: The server needs the port no. to be fixed. So, the kernel cannot give the port to a server)

  9. A client is trying to reach a web server on a system. But, at the time the client is connecting, the web server process has crashed. What, if any , ICMP message will be sent to the client?

    (Ans: ICMP_DEST_UNREACH/PORT_UNREACH)

  10. How is a socket defined?

    (Ans: The 5-tuple (SIP, DIP, SP, DP and Proto))

  11. What is the difference between message-oriented and stream-oriented services?

    (Ans: The message oriented service delivers the messages as given to the network layer whereas the stream-oriented protocol can combine/divide the messages given by the application before giving to the network layer)

  12. What is sliding window used for?

    (Ans: Flow control)

  13. What type of ack does TCP use? What is the advantage of this type of ack?

    (Ans: Cumulative ack. Advantage is that when acks are lost, segments/acks are reordered, it allows an application to infer the data that has been delivered without explicit acks for every segment. It allows for delayed acks that combine ack for multiple received segments also)

  14. What does the Nagle algorithm state that the receiver should do when the window size becomes zero?

    (Ans: The receiver should wait until either half the receive-buffer is free or 1MSS is free.)

  15. The user application gives the following data to TCP soon after the connection is established, with each data coming after 2ms gap: 10B, 200B, 300B, 1000B, 250B. The RTT is 10ms. How many segments are sent out by TCP if MSS = 1460B? What about if RTT = 20ms?

    (Ans: Using Nagle algorithm, after the first segment is sent, we wait until the ack. comes back before sending the data. Since RTT is 10ms and by the time 6ms from transmission of 10B is past, there is more than 1MSS of data, a segment of 1460B is sent. When the ack for 10B comes back, the remaining 290B is sent. If RTT is 20ms also, the same thing will happen.)

  16. What are the slow start and congestion avoidance phases of TCP transmission?

    (Ans: Slow start is the first phase of data transmission on a TCP connection. When TCP encounters a retransmission timeout, it enters the congestion avoidance phase by reducing its congestion window to half the previous value.)

  17. A receiver of a connection has advertised a window of 64MSS. The sender sends 40 MSS of data at one point of time. It finds that the retransmission timeout occurs at this point of time, what happens at this time? How does the sender proceed with its transmission?

    (Ans: The cwnd is reduced to 32MSS – since the cwnd is exponentially increased, it must have reached 64MSS for 40MSS of data to be transmitted without an ack. It enters congestion avoidance phase and therefore uses additive increase. It increases cwnd to 33MSS when all outstanding acks are received and so on.)

  18. If we have congestion in a router, how does TCP congestion algorithm reduce congestion?

    (Ans: TCP uses the multiplicative decrease to reduce congestion immediately and then the additive increase to add data slowly to the network rather than at a shot.)

  19. If we have congestion in a router, can it be reduced if the only traffic going through it is UDP traffic?

    (Ans: UDP is an unreliable, connectionless transport layer protocol that does not have any congestion control algorithm. So, unless the routers implement some congestion control at the network layer, there is nothing that can be done about congestion due to UDP traffic.)

  20. A client connects to a server and the window advertised by the server during the 3-way SYN handshake is 8KB. MSS=1KB and RTT=60ms for this connection. Assume the client experiences an RTO at time 240ms. After that, there is no RTO. Given this information, plot the maximum amount of data that the client can send (in terms of MSS) as a function of time up to 600ms. (Hint: Use the TCP congestion control algorithm to do this)

  21. A client application connects to a server application with PathMTU=540 and RTT=20ms. Assume that some data had already been exchanged and the connection was idle for some time before the following data is given by the application. The data written to the socket is given below with time mentioned in parentheses and with P indicating that PSH bit is set: 300 (0), 200 (2, P), 100 (8), 600 (12), 30 (16, P), 1000 (18), 2000(22). How many segments are sent overall? For each segment, clearly state the time at which it is sent and the amount of data in the segment.

  22. A TCP client receives data from the application of lengths 1000B, 1000B, 230B, 1000B, 950B and 1200B at 3ms intervals soon after the connection is established. The RTT of the connection is 5ms. The PathMTU of the connection is 540B. Given that the server advertised a window of length 1000B and the fact that the Nagle algorithm is enabled and the TCP congestion algorithm is in use, give the time line clearly marking the time at which segments are sent, their size, when the acks are received and explain how you arrived at the answer.

  23. A student is working at a system in AI lab and has done an SSH to the NFS server. Since her work is not done at lunch time, she leaves for lunch at 1pm. She has classes all the way up to 6pm. At 4:30pm, there is a power shut down. The UPS in the lab is not working and so the lab system simply powers o ff without any proper shut down. What are the various TCP messages that go between the AI lab system and the NFS server after the student leaves? At what time are they sent? Who sends the request and who replies? What are the replies? Assume that all TCP parameters are set to standard values. (Hint: Think about the keepalive messages)