mhrivnak at hrivnak.org
Mon Jul 11 01:33:38 CEST 2011
In order to find the end of the packet, include a field that is the
packet length. This is what IP packets do to find the end of their
And the TCP header (see "data offset") does the same:
Of course in both cases they are specifying the header length, not
including a data payload. However, it sounds like you might not have
a payload, so your entire packet might consist of header-like data.
On Sun, Jul 10, 2011 at 4:59 PM, Littlefield, Tyler <tyler at tysdomain.com> wrote:
> Hello all:
> I'm working on a server that will need to parse packets sent from a client,
> and construct it's own packets.
> The setup is something like this: the first two bytes is the type of the
> So, lets say we have a packet set to connect. There are two types of connect
> packet: a auth packet and a connect packet.
> The connect packet then has two bytes with the type, another byte that notes
> that it is a connect packet, and 4 bytes that contains the version of the
> The auth packet has the two bytes that tells what packet it is, one byte
> denoting that it is an auth packet, then the username, a NULL character, and
> a password and a NULL character.
> With all of this said, I'm kind of curious how I would 1) parse out
> something like this (I am using twisted, so it'll just be passed to my
> Receive function), and how I get the length of the packet with multiple NULL
> values. I'm also looking to build a packet and send it back out, is there
> something that will allow me to designate two bytes, set individual bits,
> then put it altogether in a packet to be sent out?
> Take care,
> my website:
> my blog:
> skype: st8amnd127
> My programs don't have bugs; they're randomly added features!
More information about the Python-list