p4lang / ptf

Packet Test Framework
Apache License 2.0
144 stars 99 forks source link

Unify test packet payload and allow for manual control #167

Open sborkows opened 2 years ago

sborkows commented 2 years ago

PTF provides a lot of very convenient functions to form test packets (simple_*_packet())

One thing that they do not allow is specifying the actual payload. Not only that, different functions use different payload for whatever reason.

For example, simple_tcp_packet uses:

pkt = pkt / codecs.decode("".join(["%02x" % (x % 256) for x in range(pktlen - len(pkt))]), "hex")

whereas simple_tcpv6_packet uses:

pkt /= "D" * (pktlen - len(pkt))

This makes direct comparisons a little difficult.

Here are two things which can changed:

NexSabre commented 2 years ago

Good idea 👍 The code of the testutils.py is in many places redundant. In the beginning, we can extract a "payload method", and standardize it.