I would advise you not to tamper with the TCP protocol any other way than by adding sleeps. You've already mentioned the most common way of "forcing" the TCP protocol to put only one "send" in a packet : by adding a sleep between the sends (even a few milliseconds should be enough in most cases), you allow the TCP protocol to empty the send buffer, and send out a packet, then wait for the next "send" call that fills up the buffer again. The TCP protocol does not care about your different send calls - it only cares about what's in its send buffer at the moment, and tries to send that as fast as possible. It generally tries to optimize the stream as much as possible by putting as much data as possible into one packet. The thing is that TCP conecptually works with streams, and not with packets. If I try to send a larger packet (> 1024 bytes) then the other side of the application, the server, starts to read garbage from the socket and it usually crashes. Also, I have to use C for evaluation purposes. I have to some tests, so I have to send as fast as possible, so probably a delay won't be a solution. To make this question more clear: I'm sending 3 packets each millisecond. So, my question is, is there any way in C, or any way to send my packet so that the NIC doesn't send more than one of my packets in a TCP packet? I can also say this because when I send packets of 512 bytes, the NIC sends two of my packets in one TCP packet of 1460 (including garbage).īTW, I'm using ethereal to trace this and see all I'm telling you. Because if I use a small sleep between each packet, the NIC doesn't break any of my packets to fill its 1460 bytes. I know it's related to how fast I'm sending the packets. Then, the server only sees some of my packets, let's say 80 of my packets. I "guess" the NIC tries to fill a TCP packet with my bytes up to 1460, so that, it breaks one of my packets and send it in another TCP packet. Actually I try to send 100 packets of those. I use send() to send as many 1024 bytes packets as I can. Server_addr.sin_addr.s_addr = inet_addr("127.0.0.I have a problem sending TCP packets using C from one PC to another. Socket_desc = socket(AF_INET, SOCK_STREAM, 0) Memset(client_message, '\0', sizeof(client_message)) ![]() Memset(server_message, '\0', sizeof(server_message)) Struct sockaddr_in server_addr, client_addr Ĭhar server_message, client_message Int socket_desc, client_sock, client_size
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |