Giter Club home page Giter Club logo

Comments (2)

saylenty avatar saylenty commented on July 19, 2024

Let's have a look at the "dpkt" source code.
There are a lot of classes that allows us to work with many type of the packets: TCP, UDP, HTTP, Radius and the like.
All of them inherits dpkt.Packet class which actually determines byte order.
Here is the answer (from dpkt.py):
-----//------
class Packet(object):

Base packet class, with metaclass magic to generate members from self.hdr.
hdr should be defined as a list of (name, structfmt, default) tuples
__byte_order__ can be set to override the default ('>')

-----//------
byte_order field determines either big-endian or little-endian byte order should be used.
The default byte order for dpkt is set in _MetaPacket class line 37:
-----//------

t.__hdr_fmt__ = getattr(t, 'byte_order', '>') + ''.join([x[1] for x in st])

-----//------
To sum up, "dpkt" takes care about byte ordering and it uses big-endian (which is default network byte order) format as a default byte order.

Some more info could be found here:

https://en.wikipedia.org/wiki/Endianness
http://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/
Official python documentation: https://docs.python.org/2/library/struct.html#struct-alignment

@kbandla or @brifordwylie please, have a look at the answer and close the issue if the answer is full and correct.

from dpkt.

kbandla avatar kbandla commented on July 19, 2024

Yup this is the right answer. I tagged this issue with documentation so that we can add this to the docs later.

from dpkt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.