Open olijf opened 3 weeks ago
I have narrowed it down to the fact that you do not check if the sequence numbers are actually flipped around back to zero after reaching 255:
mac/init.py
There are several sequence counters:
macBeaconSequenceNumber
and macDataSequenceNumber
But these should be 0 <= number <= 255
otherwise they wont fit the ubyte
Maybe something like this works?
on line 1083: self.database.set("macBeaconSequenceNumber", sequence_number + 1 % 255)
I think it would be best to keep control of the max value of the sequence counters inside your database.py
otherwise the different layers are responsible for keeping track.
This works:
1013:self.database.set("macDataSequenceNumber", (sequence_number + 1) % 256)
1083:self.database.set("macBeaconSequenceNumber", (sequence_number + 1) % 256)
Pay attention to the (
and )
apparently %
takes precedence over +
in math.
Thank you for this fix, it has been applied and merged into main. I keep this issue open as a reminder for implementing better sequence number tracking.
Thank you! Could you maybe ask Romain to reply to my email? I really want to use WHAD for my thesis, but some things are just not working as I expect. They could either be because of bugs, or because of me. I would like to get in contact so I figure out what is the issue, but I do not have a current email address I think.
It seems that after sending several beacon frames the counter becomes > 255 and causes scapy to throw an exception.
I am trying to setup a Zigbee coordinator using the coordinator example, but I can not get any Zigbee lamps to join the network, they just keep exchanging beacon frames. Thats probably why the sequence counter got so high.
I have done some debugging but I can not find where the sequence counter is being tracked.
Below you can find the log.