3
votes

Let's say I have a simple TCP connection w/ a client and a server. The client sends some data to the server, and the server sends something back to the client after doing some processing w/ the original data.

I am not 100% on how the flow of packets would work in this situation using a stop and wait protocol. When the client sends the original data to the server, does the server send an ACK and the new data at the same time (same packet?), or are these sent separately?

From examples I have seen online, I'm not able to understand fully when a server sends data back to a client in relation to when it sends an ACK.

Thank you!

1

1 Answers

1
votes

If the server has some data already queued up to send back to the client, it can use TCP piggybacking so that (the server's ack of the client's packet) and (some of the server's reply data) share a single packet. That makes the protocol a bit more efficient, as fewer packets have to be sent back to the client.

If the server doesn't have any of its own application-level data to send back at the time it wants to send the ACK packet, then the ACK packet will go back to the client as a stand-alone packet. (In a stop-and-wait protocol, the server probably wouldn't have any application-level data ready to send back yet, since the ACK is supposed to go back to the client as soon as the client's packet is received, and in this case the server app doesn't generate any data until after it has done its processing of the received client data)