This is our old Q&A Site. Please post any new questions and answers at

For the dissector I'm creating I have to dissect 11 bits from two bytes. The bytes in the hex dump are:

CF 81

which is the following in binary:

1100 1111 1000 0001

However, I need the bytes organized as:

81 CF

So I can get the bits as:

1000 0001 1100 1111

Where the bolded bits are the bits of interest. My attempt was to store the two bytes in a separate variable using the tvbuf:bitfield() method. Then, after extracting the 11 bits desired, adding them to the display tree with tree:add_le() method. However, I am not getting the proper value.

Thank you for your consideration!

asked 14 Dec '16, 16:03

Irfan%20Hossain's gravatar image

Irfan Hossain
accept rate: 0%

Are you having trouble getting the data in the dissection tree correctly or in your local variable correctly?

If the former then you should be able to use treeitem:add_packet_field with an encoding of ENC_LITTLE_ENDIAN to tell Wireshark to flip the bytes. Of course you'd want the ProtoField to be a ftypes.UINT16 and you'd presumably want to give it a mask of 0x7FF (so Wireshark will use only the lower 11 bits in calculating the value).

permanent link

answered 04 Jan '17, 06:27

JeffMorriss's gravatar image

JeffMorriss ♦
accept rate: 27%

Thank you for your answer! The original problem was fixed a different way due to the data organization, but this fixed another issue I had with endianess. Thanks!

(04 Jan '17, 09:13) Irfan Hossain
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 14 Dec '16, 16:03

question was seen: 1,363 times

last updated: 04 Jan '17, 09:13

p​o​w​e​r​e​d by O​S​Q​A