Write a program that prints the default TCP, UDP, and SCTP send and receive buffer sizes and run it on the systems to which you have access.
Modify Figure 1.5 as follows: Before calling connect, call getsockopt to obtain the socket receive buffer size and MSS. Print both values. After connect returns success, fetch these same two socket options and print their values. Have the values changed? Why? Run the program connecting to a server on your local network and also run the program connecting to a server on a remote network. Does the MSS change? Why? You should also run the program on any different hosts to which you have access.
Start with our TCP server from Figures 5.2 and 5.3 and our TCP client from Figures 5.4 and 5.5. Modify the client main function to set the SO_LINGER socket option before calling exit, setting l_onoff to 1 and l_linger to 0. Start the server and then start the client. Type in a line or two at the client to verify the operation, and then terminate the client by entering your EOF character. What happens? After you terminate the client, run netstat on the client host and see if the socket goes through the TIME_WAIT state.
Assume two TCP clients start at about the same time. Both set the SO_REUSEADDR socket option and then call bind with the same local IP address and the same local port (say 1500). But, one client connects to 188.8.131.52 port 7000 and the second connects to 184.108.40.206 (same peer IP address) but port 8000. Describe the race condition that occurs.
Obtain the source code for the examples in this book (see the Preface) and compile the sock program (Section C.3). First, classify your host as (a) no multicast support, (b) multicast support but SO_REUSEPORT not provided, or (c) multicast support and SO_REUSEPORT provided. Try to start multiple instances of the sock program as a TCP server (-s command-line option) on the same port, binding the wildcard address, one of your host's interface addresses, and the loopback address. Do you need to specify the SO_REUSEADDR option (the -A command-line option)? Use netstat to see the listening sockets.
Continue the previous example, but start a UDP server (-u command-line option) and try to start two instances, both binding the same local IP address and port. If your implementation supports SO_REUSEPORT, try using it (-T command-line option).
Many versions of the ping program have a -d flag to enable the SO_DEBUG socket option. What does this do?
Continuing the example at the end of our discussion of the TCP_NODELAY socket option, assume that a client performs two writes: the first of 4 bytes and the second of 396 bytes. Also assume that the server's delayed ACK time is 100 ms, the RTT between the client and server is 100 ms, and the server's processing time for the client's request is 50 ms. Draw a timeline that shows the interaction of the Nagle algorithm with delayed ACKs.
Redo the previous exercise, assuming the TCP_NODELAY socket option is set.
Redo Exercises 7.8 assuming the process calls writev one time, for both the 4-byte buffer and the 396-byte buffer.
Read RFC 1122 [Braden 1989] to determine the recommended interval for delayed ACKs.
Where does our server in Figures 5.2 and 5.3 spend most of its time? Assume the server sets the SO_KEEPALIVE socket option, there is no data being exchanged across the connection, and the client host crashes and does not reboot. What happens?
Where does our client in Figures 5.4 and 5.5 spend most of its time? Assume the client sets the SO_KEEPALIVE socket option, there is no data being exchanged across the connection, and the server host crashes and does not reboot. What happens?
Where does our client in Figures 5.4 and 6.13 spend most of its time? Assume the client sets the SO_KEEPALIVE socket option, there is no data being exchanged across the connection, and the server host crashes and does not reboot. What happens?
Assume both a client and server set the SO_KEEPALIVE socket option. Connectivity is maintained between the two peers, but there is no application data exchanged across the connection. When the keep-alive timer expires every two hours, how many TCP segments are exchanged across the connection?
Almost all implementations define the constant SO_ACCEPTCONN in the <sys/socket.h> header, but we have not described this option. Read [Lanciani 1996] to find out why this option exists.