简体   繁体   中英

UDP not dropping any packets

I have a C# client and C++ server program that use UDP to communicate. For now i'm simply using 127.0.0.1 (localhost) to simulate the communication on one machine.

The problem is that no UDP packets were dropped my 10,000 packet test between the client and server on the same machine, so i don't know how to write the code for retransmission because i can't get it to drop a packet, but it will happen in a real scenario between a client and server on separate machines.

Is it not dropping any packets because the client and server are on the same machine?

UDP does not usualy drops packet on same machine. Instead of using rand() function approach you can do another trick. Send large packets from the sender and receive in smaller chunks in the receiver code. And use sleep function after every receive. So one the pipe gets full, you may notice packet drops

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM