1

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?

4
  • 3
    Yes, it is. It's very hard to drop packets on a loopback connection.
    – rici
    Mar 26, 2015 at 3:48
  • 4
    if(rand() < RAND_MAX/8) /* don't send the packet */ else {send(...)}
    – user253751
    Mar 26, 2015 at 3:50
  • Thanks guys. @immibis ah ok i was thinking i could do something like that thanks
    – shawn a
    Mar 26, 2015 at 4:11
  • Check out clumsy, it sounds like it'll work for you. Mar 27, 2015 at 1:14

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.