Malformed packets

374 views
Skip to first unread message

Kal_Torak

unread,
May 7, 2012, 1:52:30 PM5/7/12
to lidgren-ne...@googlegroups.com
I'm getting malformed packet errors more frequently than I would expect, given my relatively simple setup.
The usual form is "Malformed Packet,  state payload length: 1460 (or similar very large size),  bytes left: 6 or 7 (ish)"

It seems to be happening to about 1% of messages,  and I don't know how to go about debugging that.

Some of my net code is using Write/ReadAllFields,  I don't know how solidly reliable that is.  I'm using different types of objects,  including custom structs and native integral types.

Any suggestions?

lidgren

unread,
May 10, 2012, 3:19:50 AM5/10/12
to lidgren-ne...@googlegroups.com
Are you sending messages larger than MTU? Sounds like a problem with the fragmentation code... I'll try have a look asap.

I don't think write/readallfields is to blame; it uses the normal read/write methods and any mismatch would not result in a malformed packet anyway.

--michael

Kal_Torak

unread,
May 10, 2012, 5:18:11 AM5/10/12
to lidgren-ne...@googlegroups.com
One thing I'm doing that I'm not 100% sure of is reading out data as a byte array from a message, in this fashion,
//I first read out a few items using Readblah(),  then I do this on the remaining payload:
outMsg.Write(msg.ReadBytes(msg.LengthBytes - msg.PositionInBytes));

I see a comment on PositionInBytes that mentions bits in the first byte may be used.  However,  since it only happens occasionally, this doesn't sound like it's the problem.

Also,  the message that the error is occuring on is one where I'm sending a Double using Write/ReadAll.  Which means basically that the message size is very small when the malformed error happens.

lidgren

unread,
May 11, 2012, 4:30:55 AM5/11/12
to lidgren-ne...@googlegroups.com
Actually the unit test fails too. I'll have a look.


On Monday, 7 May 2012 19:52:30 UTC+2, Kal_Torak wrote:

Free, The All Powerful

unread,
May 11, 2012, 5:36:02 AM5/11/12
to lidgren-ne...@googlegroups.com

Off topic, but I heard from a fellow programmer about unit tests. Would you he able to link me any solid documentation/tutorials on them so that I could learn about them?

lidgren

unread,
May 11, 2012, 8:38:15 AM5/11/12
to lidgren-ne...@googlegroups.com

http://en.wikipedia.org/wiki/Unit_testing 

;-)

I don't use any special unit testing library; just a separate project with some basic tests.

--michael
Reply all
Reply to author
Forward
0 new messages