blob: f477c0bab38076dc3a6763c400528159c0dafda0 [file] [log] [blame]
Ting Xuce4b6452022-04-24 06:14:25 +00001.. _packetforge_doc:
2
3Packetforge for generic flow
4============================
5
6Packetforge is a tool to support generic flow. Since the input format of
7generic flow is hard to read and create, packetforge can help to create
8generic flow rules using a format of naming protocols (like Scapy) or json
9profile. Packetforge is built based on a parsegraph, users can modify the
10graph nodes and edges if needed.
11
12Command examples
13----------------
14
15::
16
17 $ python flow_create.py --add -p "mac()/ipv4(src=1.1.1.1,dst=2.2.2.2)/udp()"
18 -a "redirect-to-queue 3" -i 1
19
20 $ python flow_create.py --add
21 --pattern "mac()/ipv4(src=1.1.1.1,dst=2.2.2.2)/udp()"
22 --actions "redirect-to-queue 3" --interface 1
23
24 $ python flow_create.py --del -i 1 -I 0
25
26 $ python flow_create.py --del --interface 1 --flow-index 0
27
28Naming format input. There are two operations, add and delete flow rules.
29For add, it needs three parameters. Pattern is similar to Scapy protocols.
30Actions is the same as vnet/flow command. Interface is the device to which
31we want to add the flow rule. For delete, flow index is the index of the
32flow rule we want to delete. We can get the index number when we add the
33flow or use command to show the existed flow entry in CLI.
34
35::
36
37 $ python flow_create.py --add -f "./flow_rule_examples/mac_ipv4.json" -i 1
38
39 $ python flow_create.py --add --file "./flow_rule_examples/mac_ipv4.json"
40 --interface 1
41
42 $ python flow_create.py --add -f "./flow_rule_examples/mac_ipv4.json"
43 -a "redirect-to-queue 3" -i 1
44
45Json profile format input. This command takes a json profile as parameter.
46In the json profile, there will be protocols and their fields and values.
47Users can define spec and mask for each field. Actions can be added in the
48profile directly, otherwise "-a" option should be added in the command to
49specify actions. The example can be found in parsegraph/samples folder.
50Users can create their own json files according to examples and Spec.
51
52::
53
54 $ show flow entry
55
56It is a vnet/flow command, used in VPP CLI. It can show the added flow rules
57after using the above commands. Users can get the flow index with this command
58and use it to delete the flow rule.
59
60ParseGraph
61----------
62
63Packetforge is built based on a ParseGraph. The ParseGraph is constructed
64with nodes and edges. Nodes are protocols, including information about
65protocol's name, fields and default values. Edges are the relationship
66between two protocols, including some actions needed when connecting two
67protocols. For example, change the mac header ethertype to 0x0800 when
68connecting mac and ipv4. More details are in the Spec in parsegraph folder.
69Users can build the ParseGraph following the spec by themselves, like
70adding a new protocol. If NIC supports the new protocol, the rule can be
71created. Otherwise, it will return error.