UDP
A UDP header consists of:
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-------------------------------+-------------------------------+
| Source Port | Destination Port |
+-------------------------------+-------------------------------+
| Length | Checksum |
+-------------------------------+-------------------------------+16-bit source port (
UDP#sport),16-bit destination port (
UDP#dport),16-bit length (
UDP#length),16-bit checksum (
UDP#checksum),and a body (
UDP#body).
A UDP header may be built this way:
pg> PacketGen::Header::UDP.new(dport: 53, sport: 65053)
=> ---- PacketGen::Header::UDP ------------------------------------------
Int16 sport: 65053 (0xfe1d)
Int16 dport: 53 (0x0035)
Int16 length: 8 (0x0008)
Int16 checksum: 0 (0x0000)A UDP over IP packet may be created this way:
checksum and length fields may be computed by Header::UDP#calc_sum and Header::UDP#calc_length respectively. All checksum and length fields from this packet may by computed at once using pkt.calc:
See also http://rubydoc.info/gems/packetgen/PacketGen/Header/UDP.
Last updated