I have a simple C program that binds a socket so that it can
receive and send UDP packets. It uses recvfrom
to receive packets, and
shortly after receiving one, it constructs and sends a reply
packet, using sendto
in the obvious way, sending to the same
address and port that recvfrom
reported.
This program worked perfectly in initial testing, when the packets were coming in and going out over a regular Ethernet interface, eth0. But now I'm trying to use it over a PPP interface, ppp0, and for some reason it's not working.
sendto
is not reporting any errors, but tcpdump is not showing
the packets going out. (It is showing the packets coming in, so
I'm pretty sure tcpdump is working.)
And I have an existing program that's doing essentially the same thing, but it works properly under all circumstances, on all interfaces. I haven't yet worked out how the existing program might be setting up its sockets or its send/receive logic differently, that allows it to work while my new, simpler program fails.
Some of the packets are large (approaching MTU), but plenty of them are small (<100 bytes), and none of them are getting through, so I don't think it's an MTU problem.
Can anyone think of anything that would cause a sent packet to fail to go out in this way? (I'm not saying it has anything to do with ppp in particular; that it fails under ppp for me may be a coincidence, or it may be a key part of the problem.)
Sorry I can't post the actual code; it's at work and I'm at home. The relevant part looks something like this:
struct sockaddr_in addr;
socklen_t addrlen = sizeof(addr);
char buf[1600];
int r, r2;
r = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &addrlen);
/* ... */
r2 = sendto(sock, buf2, n2, 0, (struct sockaddr *)&addr, addrlen);
(If you need to see a more complete example, I can post that tomorrow.)