When I close the connection with uip_close I get the four segment termination protocol.
Unfortunately I'm not sure what you mean with "four segment termination protocol". Do you mean your second example?
1) Remote: FIN, ACK 2) uIP: ACK 3) uIP: FIN, ACK 4) Remote ACK
I have to admit that I don't know what that second ACK in 3) is for. I've seen it several times in different TCP descriptions. Unfortunately I never really understood what it is used for, as it is exactly the same ACK as 2).
Sending the same ACK twice doesn't really make sense to me. ;-)
OK, I think I understand. So this is the uIP workflow: (???) +-----+ |ESTAB| +-----+ | | CLOSE / snd FIN (from remote) | +------------+ | FIN WAIT-1 | +------------+ | | rcv FIN / snd ACK | +-----------+ | CLOSING | +-----------+ The state FIN WAIT-2 will not be considered?
Yes, that should be the workflow of uIP if it initiates the close and the remote host closes his end of the connection too.
In my opinion FIN WAIT-2 should only be considered if the remote host doesn't close his connection end immediately and only sends an ACK in response to uIPs FIN/ACK.
Regards, Marc