1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
== VM instructions
=== instructions_type
these are the instructions type
==== fix_checksum_ipv4
This command will fix ipv4 checksum header
[source,python]
----
{
ins_name : string ,"fix_checksum_ipv4" ## this command will recalculate the ipv4 checksum
pkt_offset : uint16_t, number, ## the offset into the packet when the ipv4 header is located
}
----
==== flow_man_simple
This command will allocate and manipulate flow object data
For example, allocate a flow variable and object from 10.0.0.1-10.0.0.10
[source,python]
----
{
ins_name: string, "flow_man_simple" ## increment a flow variable
flow_varible_name: string "name_of_varible" # internal software will allocate the object for this, the name should be unique
object_size : uint16_t #size of the variable 1,2,4,8 ( max uint64)
Operation : "inc","dec","random" # the command could be inc from min-max start at init
# decrement
# random
split_by_core : true/false ##do we want to split the range by cores
init_value : number, size of object_size (max uint64)
min_value : number, size of object_size (max uint64)
max_value : number, size of object_size (max uint64)
}
----
==== write_to_pkt
This command will copy flow varible into packet offset
[source,c]
----
tmp_pkt_data = (flow_var +add_value)
if (big_edian){
(varible_size )pkt[pkt_offset] =swap(tmp_pkt_data);
}
----
[source,python]
----
{
ins_name : string , "write_to_pkt" ##
flow_varible_name : string "name_of_varible" # flow varible value to copy from
pkt_offset : uint16_t # the offset into the packet to copy the varible
add_value : 0 (size_of_the_varible)# when writing add this value
big_edian : bool default true # swap varible when copy yo packet
}
----
=== Examples
=== Examples1
an examples to a programs that change src_ip in specific range for one core
range of src_ip 10.0.0.1-10.0.0.10 start from 10.0.0.7
update ipv4 checksum
ip offset is in 14
offset
[ 6 - dest mac 0
6 - src mac 6
2 network 12
ip[0] 14
ip[4] 18
ip[8]-TTL,Protocol 22
ip[12]-src_ip 26
ip[12]-dest_ip 30
}
The program
[source,python]
----
[
{
ins_name : "flow_data_inc"
flow_varible_name : "src_ip"
object_size : 1
operaqtion : "inc"
split_by_core : false # one core
init_value : 7
min_value : 1
max_value : 10
} ,
{
ins_name : "write_to_pkt"
flow_varible_name : "src_ip"
pkt_offset : 26,
add_value : 0 ,
big_edian : true
},
{
ins_name : "fix_checksum_ipv4"
pkt_offset : 14
}
]
----
=== Examples2
an examples to a programs that change src_ip and dest_ip in specific range for one core
range of src_ip 10.0.0.1-10.0.0.10 start from 10.0.0.7
range of dest_ip 48.0.0.1-48.0.0.10 start from 48.0.0.7
update ipv4 checksum
ip offset is in 14
offset
[ 6 - dest mac 0
6 - src mac 6
2 network 12
ip[0] 14
ip[4] 18
ip[8]-TTL,Protocol 22
ip[12]-src_ip 26
ip[12]-dest_ip 30
}
The program
[source,python]
----
[
{
ins_name : "flow_data_inc"
flow_varible_name : "src_ip"
object_size : 1
operaqtion : "inc"
split_by_core : false # one core
init_value : 7
min_value : 1
max_value : 10
} ,
{
ins_name : "write_to_pkt"
flow_varible_name : "src_ip"
pkt_offset : 26,
add_value : 0 ,
big_edian : true
},
{
ins_name : "write_to_pkt"
flow_varible_name : "src_ip"
pkt_offset : 30,
add_value : 0 ,
big_edian : true
},
{
ins_name : "fix_checksum_ipv4"
pkt_offset : 14
}
]
----
=== Considerations
==== Control-Plain check
- Verify that packet offset into fix_checksum_ipv4 is less that pkt_size - min_ip_header
- There is no stream that are orphaned (not started at startup and nobody call them)
==== Data-Plain check
- Convert the commands to a VM compress command
- Allocate flow memory per flow for each stream (currently add the memory in each offset)
- VM runner at startup/ each packet
|