0

I need to send a sequence of packets from min to max ethernet size to verify hardware. Would be best to use scapy since that's the tool of choice for existing tests.

Is there a way to have scapy to send a sequence of packets of incrementing length?

Using the [x,y] form for length seems to only change header field values, not data length.

pak=(Ether()/IP(len=[100,101])

It is possible to create a large pcap file with all the required packets and read from that, but I was hoping for something more lightweight.

seacoder
  • 514
  • 5
  • 11

1 Answers1

0

You could do something like

packets = (Ether()/IP()/Raw(load=b"\x00" * i) for i in range(1000))
sendp(packets)

to send packets with a payload from 0 to 1000. The lengths will be computed automatically

Cukic0d
  • 5,111
  • 2
  • 19
  • 48
  • Great.. just what I was looking for. I did have to make one small change to the load syntax since the "\x00" was adding 4 bytes at a time. By using (load='0' * i) instead, it works perfectly. Thanks! – seacoder Feb 04 '21 at 14:22
  • You're right I forgot the trailing `b`. It should have been b`\x00` haha. Glad I could help – Cukic0d Feb 04 '21 at 16:01