# Making sense of multiple packets containing dup data

**URL:** <https://www.ruby-forum.com/t/making-sense-of-multiple-packets-containing-dup-data/171767>\
**Category:** Ruby\
**Created:** [July 8, 2009, 10:04pm UTC](https://www.ruby-forum.com/t/making-sense-of-multiple-packets-containing-dup-data/171767 "2009-07-08T22:04:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![owossoborn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f19dbf/32.png) [@owossoborn](https://www.ruby-forum.com/u/owossoborn)\
**Post date:** [July 8, 2009, 10:04pm UTC](https://www.ruby-forum.com/t/making-sense-of-multiple-packets-containing-dup-data/171767/1 "2009-07-08T22:04:03Z")

</div>

I’m currently working on a query app for Battlefield 2142 and I’m  
running into some troubles when I’m receiving multiple UDP packets from  
a server. When there’s only one packet, I can decipher it without much  
trouble, as it’s rather predictable. However, when the data has to  
arrive in multiple packets things get much tougher, here’s why:

- If it’s at the end of one packet and in the midst of transferring a  
piece of data (e.g. a player’s ID, a player’s name, etc) it will  
re-write that entire piece of data in the next packet, even the part  
that was previously written in the last packet.

- Different parts of the packet are categorized, e.g. players\_ precedes  
all of the player names, scores\_ precedes player scores, etc. However,  
if it’s in the midst of reporting players\_ at the end of a packet, it  
will re-write players\_ again at the start of the next packet. This tends  
to make it difficult for me to have a pattern for parsing the packets as  
they can vary a bit between each query.

I’ve tossed together a basic script to query several servers and output  
the results so you can see what it looks like when there’s varying  
amounts of packets:

[http://pastie.org/539099.txt](http://pastie.org/539099.txt)

I’ve only been programming for a few days, so excuse any terrible coding  
practices in there 😉

Any assistance would be tremendously appreciated!
