tags:

views:

202

answers:

2

I am working on linux. I have a HTTP client which requests some data from the HTTP server. The HTTP client is written in C and HTTP server is written in perl. I want to simulate TCP re-transmission timeouts at the client end.

I assume that closing the socket gracefully would not result in client to re-transmit the requests.

So I tried the following scenario:

  1. Exit the Server as soon as it gets the HTTP GET request. However, I noticed that once the application exits, the socket is still closed gracefully. I see that the server initiates FIN.ACK messages towards the client even though the application has not called "close" on the socket. I have noticed this behaviour on a simple TCP server and client written in C program as well.

  2. Server does not send any response to the client's GET request. In this case I notice that there is still FIN, ACK sent by the server. Seems that in these cases the OS (linux) takes care of closing the socket with the peer. Is there any way to suppress this behaviour (using ioctl or setsockopt options) or any other way to simulate the TCP re-transmission timeouts.

Thanks.

+1  A: 

You could try setting firewall rules that block the packets going from the server to the client, which would cause the client to re-transmit the quests. On Linux, this would probably be done using iptables, but different distributions have different methods of controlling it.

qid
Thanks for your response.iptables might work. The only think I would have to keep in mind would be to block the outgoing packets after the TCP connection has been established (otherwise I would get TCP connection setup failures).
Achint Mehta
You could probably just block packets with the PSH (push) flag set, I believe that is the flag that indicates data is being sent. If I remember correctly the connection handshake is SYN, SYN+ACK, ACK, so the connection would still open.
qid
+1  A: 

This issue was previously discussed here

Aaron