nsg-ethz/p4-learning

Questions about 11-Packet-Loss-Detection

xjywhu opened this issue · 5 comments

When I run the controller, when loss happend, the controller met the following error:
Traceback (most recent call last):
File "packet-loss-controller.py", line 251, in
controller.run_cpu_port_loop()
File "packet-loss-controller.py", line 240, in run_cpu_port_loop
sniff(iface=cpu_interfaces, prn=self.recv_msg_cpu)
File "/usr/lib/python2.7/dist-packages/scapy/sendrecv.py", line 620, in sniff
r = prn(p)
File "packet-loss-controller.py", line 233, in recv_msg_cpu
loss_header = LossHeader(packet.payload)
File "/usr/lib/python2.7/dist-packages/scapy/base_classes.py", line 223, in call
i.init(*args, **kargs)
File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 95, in init
self.dissect(_pkt)
File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 619, in dissect
s = self.do_dissect(s)
File "/usr/lib/python2.7/dist-packages/scapy/packet.py", line 587, in do_dissect
s, fval = f.getfield(self, s)
File "/usr/lib/python2.7/dist-packages/scapy/fields.py", line 732, in getfield
bytes = struct.unpack('!%dB' % nb_bytes , w)
struct.error: unpack requires a string argument of length 1

It seems it is a scapy problem. It might be that the scapy version you are using did some non backward compatible changes. Which version do you have?

It seems it is a scapy problem. It might be that the scapy version you are using did some non backward compatible changes. Which version do you have?

Thanks for your prompt reply, scapy version I am using is 2.3.3.

It seems it is a scapy problem. It might be that the scapy version you are using did some non backward compatible changes. Which version do you have?

Which version of scapy do I need to use?

Can you try with 2.4.4. Also I think that even with that it might crash. If so can you try replacing the line:

https://github.com/nsg-ethz/p4-learning/blob/master/exercises/11-Packet-Loss-Detection/solution/packet-loss-controller.py#L228

by:

loss_header = LossHeader(bytes(packet.payload))

If that is the problem I will update it. Right now I can not try myself.

I changed the line, that works, thanks a lot!!