-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprotocol.tex
More file actions
493 lines (411 loc) · 24.3 KB
/
protocol.tex
File metadata and controls
493 lines (411 loc) · 24.3 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
%!TEX root=main.tex
\chapter{Protocol}
\label{chap:protocol}
\section{Experimenter messages}
OpenFlow experimenter messages have the following structure:
\scriptsize\begin{verbatim}
struct ofp_experimenter_header {
struct ofp_header header; /* Type OFPT_EXPERIMENTER. */
uint32_t experimenter; /* Experimenter ID */
uint32_t exp_type; /* Experimenter defined. */
/* Experimenter-defined arbitrary additional data. */
};
OFP_ASSERT(sizeof(struct ofp_experimenter_header) == 16);
\end{verbatim}\normalsize
OpenState experimenter messages have \texttt{type} field in \texttt{ofp\_header} set to \texttt{OFPT\_EXPERIMENTER}. \texttt{experimenter} field is set to \texttt{0xBEBABEBA} and \texttt{exp\_type} field is set to one of the following types:
\scriptsize\begin{verbatim}
enum ofp_exp_messages {
OFPT_EXP_STATE_MOD = 0,
};
\end{verbatim}\normalsize
\subsection{State modification messages}
\label{sec:msg_set_state_proto}
Configurations and modifications to the state table from the controller are performed with the State Modification message.
This message is an OpenState experimenter messages with \texttt{exp\_type} field set to \texttt{OFPT\_EXP\_STATE\_MOD}.
\scriptsize\begin{verbatim}
/*
* Structure of the state modification message.
*/
struct ofp_exp_msg_state_mod {
struct ofp_experimenter_header header;
uint8_t command;
uint8_t pad;
uint8_t payload[];
};
\end{verbatim}\normalsize
The \texttt{payload} structure depends on the value of \texttt{command} field. The differences between the seven commands are explained in section \ref{sec:msg_set_state}.
\scriptsize\begin{verbatim}
/*
* Possible values for 'command' field in ofp_exp_msg_state_mod
*/
enum ofp_exp_msg_state_mod_commands {
OFPSC_STATEFUL_TABLE_CONFIG = 0,
OFPSC_SET_L_EXTRACTOR,
OFPSC_SET_U_EXTRACTOR,
OFPSC_SET_FLOW_STATE,
OFPSC_DEL_FLOW_STATE,
OFPSC_SET_GLOBAL_STATE,
OFPSC_RESET_GLOBAL_STATE
};
\end{verbatim}\normalsize
\paragraph{Stateful table configuration}\mbox{}\\
To configure a stage as stateful the controller sends a \texttt{OFPT\_EXP\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_STATEFUL\_TABLE\_CONFIG} and a \texttt{payload} structure as defined by \texttt{ofp\_exp\_stateful\_table\_config}. During packet processing a stateful stage retrievs the flow state and adds it to the packet header. If state is \texttt{NULL}, no state field is appended.
\scriptsize\begin{verbatim}
struct ofp_exp_stateful_table_config {
uint8_t table_id;
uint8_t stateful;
};
\end{verbatim}\normalsize
The \texttt{table\_id} field specifies the table to be modified.
\\
The \texttt{stateful} field allows to configure the stage: \texttt{0} value makes the stage stateless, any value different from \texttt{0} makes it stateful.
\paragraph{Lookup/Update scope configuration}\mbox{}\\
An \texttt{OFPT\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_SET\_L\_EXTRACTOR} or
\\
\texttt{OFPSC\_SET\_U\_EXTRACTOR} must have a \texttt{payload} structure as defined by \texttt{ofp\_exp\_set\_extractor}.
\scriptsize\begin{verbatim}
/*
* Max number of fields for the key extractor vector
*/
#define OFPSC_MAX_FIELD_COUNT 6
struct ofp_exp_set_extractor {
uint8_t table_id;
uint8_t pad[3];
uint32_t field_count;
uint32_t fields[OFPSC_MAX_FIELD_COUNT];
};
\end{verbatim}\normalsize
The \texttt{table\_id} field specifies the table to be modified.
\\
The \texttt{field\_count} field specifies the number of fields provided in \texttt{fields[]}, which contains the vector of TLV fields composing the key extractor.
\comment{Luca, Davide}{who decides OFPSC\_MAX\_FIELD\_COUNT and OFPSC\_MAX\_KEY\_LEN? Should they be configurable?}
\paragraph{Set flow state message}\mbox{}\\
An \texttt{OFPT\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_SET\_FLOW\_STATE} has a \texttt{payload} structure as defined by \texttt{ofp\_exp\_set\_flow\_state}.
\scriptsize\begin{verbatim}
/*
* Number of bytes composing the state key.
*/
#define OFPSC_MAX_KEY_LEN 48
struct ofp_exp_set_flow_state {
uint8_t table_id;
uint8_t pad[3];
uint32_t key_len;
uint32_t state;
uint32_t state_mask;
uint32_t hard_rollback;
uint32_t idle_rollback;
uint32_t hard_timeout;
uint32_t idle_timeout;
uint8_t key[OFPSC_MAX_KEY_LEN];
};
\end{verbatim}\normalsize
The \texttt{table\_id} field specifies the table to be modified.
\\
The \texttt{key\_len} field specifies the key size (number of bytes) of the key provided in \texttt{key[]}.
\\
The \texttt{state} field contains the state to be inserted (or updated) in the state table.
\\
The \texttt{state\_mask} field specifies which bits of the state should be modified. A \texttt{state\_mask} with value \texttt{0xFFFFFFFFFFFFFFFF} indicates that the \texttt{state} field should be entirely overwritten.
\\
\texttt{hard\_timeout} and \texttt{idle\_timeout} fields specifiy the number of microseconds before state is rollbacked to \texttt{hard\_rollback} and \texttt{idle\_rollback}, respectively.
\\
The \texttt{key} field contains the key used to access the state table, splitted in bytes (e.g: ip 10.0.0.1 is stored as [10,0,0,1]).
\paragraph{Delete flow state message}\mbox{}\\
An \texttt{OFPT\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_DEL\_FLOW\_STATE} has a \texttt{payload} structure as defined by \texttt{ofp\_exp\_del\_flow\_state}.
\scriptsize\begin{verbatim}
/*
* Number of bytes composing the state key.
*/
#define OFPSC_MAX_KEY_LEN 48
struct ofp_exp_del_flow_state {
uint8_t table_id;
uint8_t pad[3];
uint32_t key_len;
uint8_t key[OFPSC_MAX_KEY_LEN];
};
\end{verbatim}\normalsize
The \texttt{table\_id} field specifies the table to be modified.
\\
The \texttt{key\_len} field specifies the key size (number of bytes) of the key provided in \texttt{key[]}.
\\
The \texttt{state} field contains the state to be inserted (or updated) in the state table.
\\
The \texttt{state\_mask} field specifies which bits of the state should be modified. A \texttt{state\_mask} with value \texttt{0xFFFFFFFFFFFFFFFF} indicates that the \texttt{state} field should be entirely overwritten.
\\
The \texttt{key} field contains the key used to access the state table, splitted in bytes (e.g: ip 10.0.0.1 is stored as [10,0,0,1]).
\paragraph{Checks and Errors}\mbox{}\\
\begin{itemize}
\item When \texttt{command} field is set to \texttt{OFPSC\_SET\_L\_EXTRACTOR} or \texttt{OFPSC\_SET\_U\_EXTRACTOR}, \texttt{field\_count} must be consistent with the number of fields provided in \texttt{fields[]} and should be always greater than 0, otherwise the switch must return an \texttt{ofp\_error\_msg} with \texttt{OFPET\_BAD\_REQUEST} type and \texttt{OFPBRC\_BAD\_LEN} code at message unpack time.
\item When \texttt{command} field is set to \texttt{OFPSC\_SET\_FLOW\_STATE} or \texttt{OFPSC\_DEL\_FLOW\_STATE}, \texttt{key\_count} field must be consistent with the length of the key provided in \texttt{key[]} and should be always greater than 0, otherwise the switch must return an \texttt{ofp\_error\_msg} with \texttt{OFPET\_BAD\_REQUEST} type and \texttt{OFPBRC\_BAD\_LEN} code at message unpack time.
\item When \texttt{command} field is set to \texttt{OFPSC\_SET\_FLOW\_STATE} or \texttt{OFPSC\_DEL\_FLOW\_STATE}, \texttt{key\_count} field must be consistent with the number of bytes of the update-scope fields (previously configured with an \texttt{OFPSC\_SET\_U\_EXTRACTOR} command). This check is performed at message execution time.
\comment{Luca, Davide}{Should we inform the controller about this error?}
\comment{Carmelo}{Yes, the controller should be informed}
\item Lookup-scope and update-scope should provide keys with same length. This check should be performed by the switch when a message with \texttt{command} field set to \texttt{OFPSC\_SET\_L\_EXTRACTOR} or \texttt{OFPSC\_SET\_U\_EXTRACTOR} is received: if the other extractor has already been configured, the new extractor key must have the same length. This check is performed at message execution time.
\comment{Luca, Davide}{Should we inform the controller about this error?}
\comment{Carmelo}{Yes, we should}
\item When \texttt{command} field is set to \texttt{OFPSC\_SET\_FLOW\_STATE} or \texttt{OFPSC\_DEL\_FLOW\_STATE}, \texttt{table\_id} field must have a value less or equal than the number of pipeline’s tables, otherwise the switch must return an \texttt{ofp\_error\_msg} with \texttt{OFPET\_BAD\_REQUEST} type and \texttt{OFPBRC\_BAD\_TABLE\_ID} code. This check is performed at message unpack time (since the number of table is fixed).
\end{itemize}
\paragraph{Global state modification message}\mbox{}\\
An \texttt{OFPT\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_SET\_GLOBAL\_STATE} has a \texttt{payload} structure as defined by \texttt{ofp\_exp\_set\_global\_state}.
\scriptsize\begin{verbatim}
struct ofp_exp_set_global_state {
uint32_t flag;
uint32_t flag_mask;
};
\end{verbatim}\normalsize
The \texttt{flag} field specifies the new value of global states.
\\
The \texttt{flag\_mask} field specifies which bits of the global state should be modified. A \texttt{flag\_mask} with value \texttt{0xFFFFFFFF} indicates that the global state field should be entirely overwritten.
\paragraph{Global state reset message}\mbox{}\\
An \texttt{OFPT\_STATE\_MOD} message with \texttt{command} field set to \texttt{OFPSC\_RESET\_GLOBAL\_STATE} has an empty \texttt{payload}.
This message reset the global state value to \texttt{OFP\_GLOBAL\_STATES\_DEFAULT}.
\scriptsize\begin{verbatim}
#define OFP_GLOBAL_STATES_DEFAULT 0
\end{verbatim}\normalsize
\comment{Luca e Davide}{Does the OFP\_GLOBAL\_STATES\_DEFAULT be configurable by a controller message?}
\section{Experimenter actions}
OpenFlow experimenter actions have the following structure:
\scriptsize\begin{verbatim}
struct ofp_action_experimenter_header {
uint16_t type; /* OFPAT_EXPERIMENTER. */
uint16_t len; /* Length is a multiple of 8. */
uint32_t experimenter; /* Experimenter ID */
/* Experimenter-defined arbitrary additional data. */
};
OFP_ASSERT(sizeof(struct ofp_action_experimenter_header) == 8);
\end{verbatim}\normalsize
OpenState experimenter actions have the following structure:
\scriptsize\begin{verbatim}
struct ofp_openstate_action_experimenter_header {
struct ofp_action_experimenter_header header;
uint32_t act_type;
uint8_t pad[4];
};
OFP_ASSERT(sizeof(struct ofp_openstate_action_experimenter_header) == 16);
\end{verbatim}\normalsize
\texttt{type} field and \texttt{experimenter} field in \texttt{ofp\_action\_experimenter\_header} are set to \texttt{OFPAT\_EXPERIMENTER} and \texttt{0xBEBABEBA} respectively.
\\
\texttt{act\_type} field is set to one of the following values:
\scriptsize\begin{verbatim}
enum ofp_exp_actions {
OFPAT_EXP_SET_STATE = 0,
OFPAT_EXP_SET_FLAG
};
\end{verbatim}\normalsize
\subsection{Set-state Action}
\label{sec:act_set_state_proto}
This action is an OpenState experimenter action with \texttt{act\_type} field set to \texttt{OFPAT\_EXP\_SET\_STATE}. This action allows to set flow states in a particulare stage of the pipeline. The following structure describes the body of the set-state action:
\scriptsize\begin{verbatim}
/*
* Action structure for OFPAT_EXP_SET_STATE.
*/
struct ofp_exp_action_set_state {
struct ofp_openstate_action_experimenter_header header;
uint32_t state; /* State instance. */
uint32_t state_mask; /* State mask */
uint8_t table_id; /*Stage destination*/
uint8_t pad[3];
uint32_t hard_rollback;
uint32_t idle_rollback;
uint32_t hard_timeout;
uint32_t idle_timeout;
uint8_t pad2[4]; /* Align to 64-bits. */
};
OFP_ASSERT(sizeof(struct ofp_exp_action_set_state) == 48);
\end{verbatim}\normalsize
The \texttt{state} field is used to set the value to be inserted (or updated) in the state table.
\\
The \texttt{state\_mask} field specifies which bits of the \texttt{state} field should be modified. A \texttt{state\_mask} with value \texttt{0xFFFFFFFF} indicates that the \texttt{state} field must be entirely overwritten.
\\
The \texttt{table\_id} field specifies the target stage of the state update action.
\\
\texttt{hard\_timeout} and \texttt{idle\_timeout} fields specifiy the number of microseconds before state is rollbacked to \texttt{hard\_rollback} and \texttt{idle\_rollback}, respectively.
\paragraph{Checks and Errors}\mbox{}\\
\begin{itemize}
\item Set-state action should be called only on stateful stage. This check is performed at action execution time because the flow-mod message with a set-state action could be received by the switch before configuring a stage as stateful. The important thing is that the stage is stateful at action execution time (since the number of table is fixed).
\comment{Luca, Davide}{Should we inform the controller about this error?}
\comment{Carmelo}{I think it's better to check if the stage is stateful ad message unpack time. It's more natural to think that the controller first configure the stages, and then installs the flow entries.}
\item Set-state action should be performed onto a stage with \texttt{stage\_id} less or equal than the number of pipeline’s tables, otherwise the switch must return an \texttt{ofp\_error\_msg} with \texttt{OFPET\_BAD\_REQUEST} type and \texttt{OFPBRC\_BAD\_TABLE\_ID} code. This check is performed at message unpack time (the number of table is fixed, so installing a flow with a wrong action does not make sense).
\end{itemize}
\paragraph{Priority}\mbox{}\\
Actions in an action set are applied in the order specified in the OpenFlow specification, regardless of the order that they were added to the set.
If we want to perform set-state action before some other action of the same stage alters its header fields (potentially the fields of the update-key), we should define the highest possible priority for the set-state action.
The problem is that an experimenter action OFPAT\_EXPERIMENTER has an unique priority (specified in ofsoftswitch13): we cannot differentiate the priority of two experimenter actions and we cannot change the priority of an experimenter action itself.
The switch may support arbitrary action execution order through the Apply-Actions instruction (instead of Write-Actions).
If the above assumption is legitimate, the programmer must use the apply-action (instead of write-action) taking care of actions order to guarantee priorities of OF specifications.
\subsection{Set-flag action}
\label{sec:set_flag_action_proto}
This action is an OpenState experimenter action with \texttt{act\_type} field set to \texttt{OFPAT\_EXP\_SET\_FLAG}. This action allows to set global states. The following structure describes the body of the set-flag action:
\scriptsize\begin{verbatim}
/*
* Action structure for OFPAT_EXP_SET_FLAG
*/
struct ofp_exp_action_set_flag {
struct ofp_openstate_action_experimenter_header header;
uint32_t flag; /* Flag value */
uint32_t flag_mask; /* Flag mask */
};
OFP_ASSERT(sizeof(struct ofp_exp_action_set_flag) == 24);
\end{verbatim}\normalsize
The \texttt{flag} field specifies the new value of global states.
\\
The \texttt{flag\_mask} field specifies which bits of the global state should be modified. A \texttt{flag\_mask} with value \texttt{0xFFFFFFFF} indicates that the global state field should be entirely overwritten.
\section{Match fields}
The OpenState Experimenter flow match fields are standard OpenFlow Extensible Match OXM TLV. The standard flow match field structure consist of an header (\texttt{oxm\_class}, \texttt{oxm\_field}, \texttt{oxm\_hasmask} and \texttt{oxm\_length}) and a body.
\\
The \texttt{oxm\_class} must be set to \texttt{OFPXMC\_EXPERIMENTER}.
\\
The \texttt{oxm\_field} can have the following values:
\scriptsize\begin{verbatim}
enum oxm_exp_match_fields {
OFPXMT_EXP_FLAGS, /* Global States */
OFPXMT_EXP_STATE /* Flow State */
};
\end{verbatim}\normalsize
The first four bytes of the OXM TLV’s body contains the OpenState's experimenter identifier \texttt{0xBEBABEBA}. The usual \texttt{oxm\_value} and \texttt{oxm\_mask} start from the fifth byte.
\subsection{State Match Field}
\label{sec:match_state}
The experimenter \texttt{OFPXMT\_EXP\_STATE} field is used in the flow table in order to match on the state value defined in the virtual packet header field, which is returned by a state table in a stateful stage. It is a 32 bit field.
\\
\texttt{OFPXMT\_EXP\_STATE} is maskable, so it is possible to match it either exactly or with wildcards. A 0 bit in the mask means i-th state's bit is ``do not care'', while a 1 bit value means ``exact match''.
\scriptsize\begin{verbatim}
/*
* Flow state field definition
*/
#define OXM_EXP_STATE OXM_HEADER (0xFFFF, 1, 8)
#define OXM_EXP_STATE_W OXM_HEADER_W (0xFFFF, 1, 6)
\end{verbatim}\normalsize
\subsection{Flags match field}
\label{section:oxm_of_flags}
Right after the packet headers are parsed, the global states are retrieved and written in the flags field. \texttt{OXM\_EXP\_FLAGS} is a field with mask, so it is possible to match it either exactly or with wildcards. A 0 bit in the mask means i-th flags value is ``do not care'', while a 1 bit value means ``exact match''.
\scriptsize\begin{verbatim}
/* Global States */
#define OXM_EXP_FLAGS OXM_HEADER (0xFFFF, 0, 8)
#define OXM_EXP_FLAGS_W OXM_HEADER_W (0xFFFF, 0, 6)
\end{verbatim}\normalsize
Example match:
\scriptsize\begin{verbatim}
flags=(4,5)
\end{verbatim}\normalsize
This command allows to match over \texttt{*****************************1*0} flags configuration (4 in binary is 100 and the mask 5 is 101 that is exact match on LSB 1 (0 value) and LSB 3 (1 value) and ``don’t care'' over all the other flags. In order to perform an exact match on flags value no mask is required.
\\
Example match:
\scriptsize\begin{verbatim}
flags=4
\end{verbatim}\normalsize
NB: this match is very different from the previous one. With this command we are matching over \texttt{00000000000000000000000000000100} flags configuration, so it is an exact match.
\section{Experimenter Statistics Message}
\label{sec:msg_state_stats_proto}
While the system is running, the controller may request information from the datapath using the \texttt{OFPT\_MULTIPART\_REQUEST} message:
\scriptsize\begin{verbatim}
struct ofp_multipart_request {
struct ofp_header header;
uint16_t type; /* One of the OFPMP_* constants. */
uint16_t flags; /* OFPMPF_REQ_* flags. */
uint8_t pad[4];
uint8_t body[0]; /* Body of the request. */
};
OFP_ASSERT(sizeof(struct ofp_multipart_request) == 16);
enum ofp_multipart_request_flags {
OFPMPF_REQ_MORE = 1 << 0 /* More requests to follow. */
};
\end{verbatim}\normalsize
The switch responds with one or more \texttt{OFPT\_MULTIPART\_REPLY} messages:
\scriptsize\begin{verbatim}
struct ofp_multipart_reply {
struct ofp_header header;
uint16_t type; /* One of the OFPMP_* constants. */
uint16_t flags; /* OFPMPF_REPLY_* flags. */
uint8_t pad[4];
uint8_t body[0]; /* Body of the reply. */
};
OFP_ASSERT(sizeof(struct ofp_multipart_reply) == 16);
enum ofp_multipart_reply_flags {
OFPMPF_REPLY_MORE = 1 << 0 /* More replies to follow. */
};
\end{verbatim}\normalsize
The \texttt{flags} field is set to 0x0001 if more requests/replies will follow the first one.
An OpenFlow experimenter multipart messages have the \texttt{type} field set to \texttt{OFPMP\_EXPERIMENTER} (in both \texttt{ofp\_multipart\_request} and \texttt{ofp\_multipart\_reply}) and the first bytes of the request and reply bodies have the following structure:
\scriptsize\begin{verbatim}
/* Body for ofp_multipart_request/reply of type OFPMP_EXPERIMENTER. */
struct ofp_experimenter_stats_header {
uint32_t experimenter; /* Experimenter ID */
uint32_t exp_type; /* Experimenter defined. */
/* Experimenter-defined arbitrary additional data. */
};
OFP_ASSERT(sizeof(struct ofp_experimenter_stats_header) == 8);
\end{verbatim}\normalsize
All the OpenState experimenter multipart messages have the \texttt{experimenter} field set to \texttt{0xBEBABEBA} and \texttt{exp\_type} field is set to one of the following types:
\scriptsize\begin{verbatim}
enum ofp_stats_extension_commands {
OFPMP_EXP_STATE_STATS,
OFPMP_EXP_FLAGS_STATS
};
\end{verbatim}\normalsize
\subsection{State statistics message}
The State statistics message is an OpenState's multipart experimenter message having as \texttt{exp\_type} field the value \texttt{OFPMP\_EXP\_STATE\_STATS}.
This message is used by the controller to get statistics from either all the state tables or a single one. Furthermore, it is possible to retrieve information about a set of state entries that satisfy a specific key.
\scriptsize\begin{verbatim}
/* Body for ofp_multipart_request of type OFPMP_EXP_STATE_STATS. */
struct ofp_exp_state_stats_request {
struct ofp_experimenter_stats_header header;
uint8_t table_id; /* ID of table to read (from ofp_table_stats),
OFPTT_ALL for all tables. */
uint8_t get_from_state;
uint8_t pad[2]; /* Align to 64 bits. */
uint32_t state;
struct ofp_match match; /* Fields to match. Variable size. */
};
OFP_ASSERT(sizeof(struct ofp_exp_state_stats_request) == 24);
/* Body of reply to OFPMP_EXP_STATE_STATS request. */
struct ofp_exp_state_stats_reply{
struct ofp_experimenter_stats_header header;
struct ofp_exp_state_stats *stats;
};
\end{verbatim}\normalsize
In both the messages, you have to specify the experimenter ID and the multipart experimenter type as specified in the structure \texttt{ofp\_experimenter\_stats\_header}.
\\\\In the request message, the \texttt{table\_id} field specifies the table to be queried and the \texttt{match} fields are used to selectively extract specific state entries.
\\\\If \texttt{get\_from\_state} field is different from 1, this message queries the state table for obtaining entries in a specific \texttt{state}. If \texttt{get\_from\_state} is 0, \texttt{state} field is ignored.
The reply to a \texttt{OFPMP\_EXP\_STATE\_STATS} multipart request consists of an array of the following:
\scriptsize\begin{verbatim}
/*Structure of a single state statistic*/
struct ofp_exp_state_stats {
uint16_t length; /* Length of this entry. */
uint8_t table_id; /* ID of table flow came from. */
uint8_t pad;
uint32_t field_count; /*number of extractor fields*/
uint32_t fields[OFPSC_MAX_FIELD_COUNT]; /*extractor fields*/
struct ofp_exp_state_entry entry;
/* Description of fields. Variable size. */
};
OFP_ASSERT(sizeof(struct ofp_exp_state_stats) == 88);
/*Structure of a single state entry*/
struct ofp_exp_state_entry{
uint32_t key_len;
uint8_t key[OFPSC_MAX_KEY_LEN];
uint32_t state;
};
OFP_ASSERT(sizeof(struct ofp_exp_state_entry) == 56);
\end{verbatim}\normalsize
If more than one entry match the request, multiple \texttt{ofp\_exp\_state\_stats} will be appended to the message.
The length of a single \texttt{ofp\_exp\_state\_stats} is stored in the \texttt{length} field, the \texttt{table\_id} field specifies the source table, the \texttt{field\_count} specifies the number of extractor field stored in the \texttt{fields} field and the \texttt{entry} field specifies the state entry: \texttt{key}, \texttt{key\_len} and \texttt{state}.
\subsection{Global states statistics message}
\label{sec:msg_global_stats_proto}
The Global states statistics message is an OpenState's multipart experimenter message having as \texttt{exp\_type} field the value \texttt{OFPMP\_EXP\_FLAGS\_STATS}.
It is used by the controller to retrieve the global states value of a specific datapath.
\scriptsize\begin{verbatim}
/* Body for ofp_multipart_request of type OFPMP_EXP_FLAGS_STATS. */
struct ofp_exp_global_state_stats_request {
struct ofp_experimenter_stats_header header;
};
OFP_ASSERT(sizeof(struct ofp_exp_global_state_stats_request) == 8);
/* Body of reply to OFPMP_EXP_FLAGS_STATS request. */
struct ofp_exp_global_state_stats {
struct ofp_experimenter_stats_header header;
uint8_t pad[4];
uint32_t global_states;
};
OFP_ASSERT(sizeof(struct ofp_exp_global_state_stats) == 16);
\end{verbatim}\normalsize
In both the messages, you have to specify the experimenter ID and the multipart experimenter type as specified in the structure \texttt{ofp\_experimenter\_stats\_header}.
The request message has an empty body, instead the reply message has as \texttt{global\_states} value a 32 bit long field that specifies the current global states value.