UDP packets not being recieved

This is my panda code:

self.__Manager = QueuedConnectionManager()
self.__UdpReader = QueuedConnectionReader(self.__Manager, 0)
self.__UdpReader.setRawMode(True)
self.__UdpReader.addConnection(self.__Manager.openUDPConnection(15100))

and then I run this every frame:


def CheckUDP(self):
	
	if (self.__UdpReader.dataAvailable()):
		dg = Datagram()
		while (self.__UdpReader.getData(dg)):
			packetId = unpack("i", dg.getMessage()[0:4])[0]
			print(packetId)
[insert code here]

Weird problem… I’m supposed to be receiving 3 types of packets from my other host, but I only receive one type in panda.

However, with the following python program, I receive all of the packets:

from struct import *
from socket import *

buffer = 102400


UDPSock = socket(AF_INET, SOCK_DGRAM)
UDPSock.bind(("0.0.0.0", 15100))


while 1:
	data,addr = UDPSock.recvfrom(buffer)
	packetId = unpack("i", data[0:4])
	print(packetId)


UDPSock.close()

So what am I doing wrong in Panda?
I need the raw mode setting because the packets checksums are bogus, don’t ask me why, but the data is perfectly fine though.
Anyway… this is surely something I’m doing wrong in panda, not in the program that is sending the data to Panda since my other test program works fine.

That is indeed really strange. I don’t see anything obviously wrong in your code. Is there anything unique about that packets you are not receiving? Weird that you would be receiving some packets but not all of them, and weirder still that it would only be losing certain kinds of packets.

David

I might have left out one detail, as I thought it would just derail the discussion.

The panda code worked fine previously for all 3 types of packets, but I just received a new version of the program that spams me with UDP packets.

This new version changed the packets that i’m not receiving in such a way that they are padded to fit a certain size, but previously their size would be dynamic.
The packet that is working the same in both versions was not changed.

Size in new version - Packet 1: 1436 bytes
Size in old version - Packet 1: 36-1156 bytes

Size in new version - Packet 2: 1148 bytes
Size in old version - Packet 2: 28 bytes

Size in new version - Packet 3: 20 bytes
Size in old version - Packet 3: 20 bytes

As you can see, the size of the new packets is much bigger… Could it be that panda is for example limited to 1024 byte packages by default? I doubt it but then again, I can’t think of anything else.

I realize it’s tempting to blame the other program, but since my little python sockets guy has no problems with either of the versions I just can’t find it in me to not suspect a problem with my panda setup.

I just confirmed my suspicions.
I was doing the size testing in my little python sockets guy, but when I tried printing out the sizes in panda (with the old version where I receive “all” the packets) I cap out at 1016…

So… There seems to be a size cap of 1024? Can I extend this cap?

Okay… I just took a look at the panda source…

And I don’t like what I see… at all.

// This determines the size of the read buffer used to read UDP
// packets.  It places a limit on the maximum receivable size of a UDP
// packet (although it doesn't limit TCP packets at all).  However,
// there's no real reason this can't be set arbitrarily large,
// although there's not much point in making it larger than the system
// MTU, which also limits the maximum size of a UDP packet.
static const int maximum_udp_datagram = 1024;

So I have to recompile panda for this to work???

Shoot, you’re right. Guess we’ve never needed to send a UDP packet larger than 1024 bytes before. The Ethernet convention is generally 1500 bytes MTU, so I’m not really sure why we don’t have that value defined to 1500 by default.

I’ll make that change now, and maybe Josh can pick it up for an upcoming release.

David

Sweet. This fix was included in panda 1.5.1!

Thanks a lot guys! :slight_smile: