Raw packet generator, intended to be used with Jool's graybox testing framework.
mvn packageNeeds an adjacent file named address.properties that contains the default IPv4 and IPv6 header addresses. (You can find a sample in this directory; it contains defaults that make sense for graybox's normal tests.)
java -jar target/PktGenerator-<version>.jar [<PD>]<PD> is the path to a "Packet Descriptor" file. If absent, PktGenerator will try to read the description from the clipboard.
The PD format is a sequence of
packet <NAME>[: <DESCRIPTION>]
<HEADER 1>
<HEADER 2>
<HEADER 3>
...
<HEADER N>
Where <NAME> is the packet name (its file will be named "<NAME>.pkt"), <DESCRIPTION> is a single-line packet descriptor for user consumption (ignored by the parser), and <HEADER> is a packet component.
"Headers" are formatted like
<LENGTH> <TYPE> [<OVERRIDES>]
I'm not going to document all the override options; they're probably self-explanatory. See the header fields (example).
Example packet descriptor:
packet potato: Simple correct IPv4 packet length'd 1233
20 IPv4
8 UDP
1205 Payload
packet tomato: DF and TCP destination port have been tweaked
20 IPv4 df:false
20 TCP dst:1234
1205 Payload
packet lettuce: Simple IPv6 ICMP error
# This is a comment.
# "ttl--" and "swap" are "shortcuts"; see below.
40 IPv6 ttl-- swap
8 ICMPv6 type:2 code:0 mtu:1420
40 IPv6 dst:64:ff9b::203.0.113.24
8 UDP
4 Payload
Shortcuts:
| Name | Available in | Description |
|---|---|---|
ttl-- |
IPv4, IPv6 | Decrement TTL (or Hop Limit) from its default |
swap |
IPv4, IPv6, UDP, TCP | Exchange source and destination field values |
!df |
IPv4 | Set DF as the opposite of its current value |
file:<path-to-file> |
Payload | Copy file content to payload value |
length |
ICMPv4, ICMPv6 | "Destination Unreachable" length value (see) |
mtu |
ICMPv4, ICMPv6 | "Destination Unreachable" next-hop MTU value (see) |
offset |
Payload | I don't remember |