second try
[vsorcdistro/.git] / ryu / doc / source / app / ofctl_rest.rst
1 ******************
2 ryu.app.ofctl_rest
3 ******************
4
5 ryu.app.ofctl_rest provides REST APIs for retrieving the switch stats
6 and Updating the switch stats.
7 This application helps you debug your application and get various statistics.
8
9 This application supports OpenFlow version 1.0, 1.2, 1.3, 1.4 and 1.5.
10
11 .. contents::
12    :depth: 3
13
14
15 Retrieve the switch stats
16 =========================
17
18 Get all switches
19 ----------------
20
21     Get the list of all switches which connected to the controller.
22
23     Usage:
24
25         ======= ================
26         Method  GET
27         URI     /stats/switches
28         ======= ================
29
30     Response message body:
31
32         ========== =================== ========
33         Attribute  Description         Example
34         ========== =================== ========
35         dpid       Datapath ID         1
36         ========== =================== ========
37
38     Example of use::
39
40         $ curl -X GET http://localhost:8080/stats/switches
41
42     .. code-block:: javascript
43
44         [
45           1,
46           2,
47           3
48         ]
49
50     .. NOTE::
51
52        The result of the REST command is formatted for easy viewing.
53
54
55 Get the desc stats
56 ------------------
57
58     Get the desc stats of the switch which specified with Datapath ID in URI.
59
60     Usage:
61
62         ======= ===================
63         Method  GET
64         URI     /stats/desc/<dpid>
65         ======= ===================
66
67     Response message body:
68
69         =========== ======================================= ================
70         Attribute   Description                             Example
71         =========== ======================================= ================
72         dpid        Datapath ID                             "1"
73         mfr_desc    Manufacturer description                "Nicira, Inc.",
74         hw_desc     Hardware description                    "Open vSwitch",
75         sw_desc     Software description                    "2.3.90",
76         serial_num  Serial number                           "None",
77         dp_desc     Human readable description of datapath  "None"
78         =========== ======================================= ================
79
80     Example of use::
81
82         $ curl -X GET http://localhost:8080/stats/desc/1
83
84     .. code-block:: javascript
85
86         {
87           "1": {
88             "mfr_desc": "Nicira, Inc.",
89             "hw_desc": "Open vSwitch",
90             "sw_desc": "2.3.90",
91             "serial_num": "None",
92             "dp_desc": "None"
93           }
94         }
95
96
97 .. _get-all-flows-stats:
98
99 Get all flows stats
100 -------------------
101
102     Get all flows stats of the switch which specified with Datapath ID in URI.
103
104     Usage:
105
106         ======= ===================
107         Method  GET
108         URI     /stats/flow/<dpid>
109         ======= ===================
110
111     Response message body(OpenFlow1.3 or earlier):
112
113         ============== ============================================================ ===============
114         Attribute      Description                                                  Example
115         ============== ============================================================ ===============
116         dpid           Datapath ID                                                  "1"
117         length         Length of this entry                                         88
118         table_id       Table ID                                                     0
119         duration_sec   Time flow has been alive in seconds                          2
120         duration_nsec  Time flow has been alive in nanoseconds beyond duration_sec  6.76e+08
121         priority       Priority of the entry                                        11111
122         idle_timeout   Number of seconds idle before expiration                     0
123         hard_timeout   Number of seconds before expiration                          0
124         flags          Bitmap of OFPFF_* flags                                      1
125         cookie         Opaque controller-issued identifier                          1
126         packet_count   Number of packets in flow                                    0
127         byte_count     Number of bytes in flow                                      0
128         match          Fields to match                                              {"in_port": 1}
129         actions        Instruction set                                              ["OUTPUT:2"]
130         ============== ============================================================ ===============
131
132     Response message body(OpenFlow1.4 or later):
133
134         ============== ============================================================ ========================================
135         Attribute      Description                                                  Example
136         ============== ============================================================ ========================================
137         dpid           Datapath ID                                                  "1"
138         length         Length of this entry                                         88
139         table_id       Table ID                                                     0
140         duration_sec   Time flow has been alive in seconds                          2
141         duration_nsec  Time flow has been alive in nanoseconds beyond duration_sec  6.76e+08
142         priority       Priority of the entry                                        11111
143         idle_timeout   Number of seconds idle before expiration                     0
144         hard_timeout   Number of seconds before expiration                          0
145         flags          Bitmap of OFPFF_* flags                                      1
146         cookie         Opaque controller-issued identifier                          1
147         packet_count   Number of packets in flow                                    0
148         byte_count     Number of bytes in flow                                      0
149         importance     Eviction precedence                                          0
150         match          Fields to match                                              {"eth_type": 2054}
151         instructions   struct ofp_instruction_header                                [{"type":GOTO_TABLE", "table_id":1}]
152         ============== ============================================================ ========================================
153
154     Example of use::
155
156         $ curl -X GET http://localhost:8080/stats/flow/1
157
158     Response (OpenFlow1.3 or earlier):
159
160     .. code-block:: javascript
161
162         {
163           "1": [
164             {
165               "length": 88,
166               "table_id": 0,
167               "duration_sec": 2,
168               "duration_nsec": 6.76e+08,
169               "priority": 11111,
170               "idle_timeout": 0,
171               "hard_timeout": 0,
172               "flags": 1,
173               "cookie": 1,
174               "packet_count": 0,
175               "byte_count": 0,
176               "match": {
177                 "in_port": 1
178               },
179               "actions": [
180                 "OUTPUT:2"
181               ]
182             }
183           ]
184         }
185
186     Response (OpenFlow1.4 or later):
187
188     .. code-block:: javascript
189
190         {
191            "1": [
192              {
193                "length": 88,
194                "table_id": 0,
195                "duration_sec": 2,
196                "duration_nsec": 6.76e+08,
197                "priority": 11111,
198                "idle_timeout": 0,
199                "hard_timeout": 0,
200                "flags": 1,
201                "cookie": 1,
202                "packet_count": 0,
203                "byte_count": 0,
204                "match": {
205                  "eth_type": 2054
206                },
207                "importance": 0,
208                "instructions": [
209                  {
210                    "type": "APPLY_ACTIONS",
211                    "actions": [
212                      {
213                        "port": 2,
214                        "max_len": 0,
215                        "type": "OUTPUT"
216                      }
217                    ]
218                  }
219                ]
220              }
221            ]
222        }
223
224
225 .. _get-flows-stats-filtered:
226
227 Get flows stats filtered by fields
228 ----------------------------------
229
230     Get flows stats of the switch filtered by the OFPFlowStats fields.
231     This is POST method version of :ref:`get-all-flows-stats`.
232
233     Usage:
234
235         ======= ===================
236         Method  POST
237         URI     /stats/flow/<dpid>
238         ======= ===================
239
240     Request message body:
241
242         ============ ================================================================== =============== ===============
243         Attribute    Description                                                        Example         Default
244         ============ ================================================================== =============== ===============
245         table_id     Table ID (int)                                                     0               OFPTT_ALL
246         out_port     Require matching entries to include this as an output port (int)   2               OFPP_ANY
247         out_group    Require matching entries to include this as an output group (int)  1               OFPG_ANY
248         cookie       Require matching entries to contain this cookie value (int)        1               0
249         cookie_mask  Mask used to restrict the cookie bits that must match (int)        1               0
250         match        Fields to match (dict)                                             {"in_port": 1}  {} #wildcarded
251         priority     Priority of the entry (int) (See Note)                             11111           #wildcarded
252         ============ ================================================================== =============== ===============
253
254         .. NOTE::
255
256            OpenFlow Spec does not allow to filter flow entries by priority,
257            but when with a large amount of flow entries, filtering by priority
258            is convenient to get statistics efficiently.
259            So, this app provides priority field for filtering.
260
261
262     Response message body:
263         The same as :ref:`get-all-flows-stats`
264
265     Example of use::
266
267         $ curl -X POST -d '{
268              "table_id": 0,
269              "out_port": 2,
270              "cookie": 1,
271              "cookie_mask": 1,
272              "match":{
273                  "in_port":1
274              }
275          }' http://localhost:8080/stats/flow/1
276
277     Response (OpenFlow1.3 or earlier):
278
279     .. code-block:: javascript
280
281         {
282           "1": [
283             {
284               "length": 88,
285               "table_id": 0,
286               "duration_sec": 2,
287               "duration_nsec": 6.76e+08,
288               "priority": 11111,
289               "idle_timeout": 0,
290               "hard_timeout": 0,
291               "flags": 1,
292               "cookie": 1,
293               "packet_count": 0,
294               "byte_count": 0,
295               "match": {
296                 "in_port": 1
297               },
298               "actions": [
299                 "OUTPUT:2"
300               ]
301             }
302           ]
303         }
304
305     Response (OpenFlow1.4 or later):
306
307     .. code-block:: javascript
308
309         {
310            "1": [
311              {
312                "length": 88,
313                "table_id": 0,
314                "duration_sec": 2,
315                "duration_nsec": 6.76e+08,
316                "priority": 11111,
317                "idle_timeout": 0,
318                "hard_timeout": 0,
319                "flags": 1,
320                "cookie": 1,
321                "packet_count": 0,
322                "byte_count": 0,
323                "match": {
324                  "eth_type": 2054
325                },
326                "importance": 0,
327                "instructions": [
328                  {
329                    "type": "APPLY_ACTIONS",
330                    "actions": [
331                      {
332                        "port": 2,
333                        "max_len": 0,
334                        "type": "OUTPUT"
335                      }
336                    ]
337                  }
338                ]
339              }
340            ]
341        }
342
343
344
345 .. _get-aggregate-flow-stats:
346
347 Get aggregate flow stats
348 ------------------------
349
350     Get aggregate flow stats of the switch which specified with Datapath ID in URI.
351
352     Usage:
353
354         ======= ============================
355         Method  GET
356         URI     /stats/aggregateflow/<dpid>
357         ======= ============================
358
359     Response message body:
360
361         ============= =========================== ========
362         Attribute     Description                 Example
363         ============= =========================== ========
364         dpid          Datapath ID                 "1"
365         packet_count  Number of packets in flows  18
366         byte_count    Number of bytes in flows    756
367         flow_count    Number of flows             3
368         ============= =========================== ========
369
370     Example of use::
371
372         $ curl -X GET http://localhost:8080/stats/aggregateflow/1
373
374     .. code-block:: javascript
375
376         {
377           "1": [
378             {
379               "packet_count": 18,
380               "byte_count": 756,
381               "flow_count": 3
382             }
383           ]
384         }
385
386
387 Get aggregate flow stats filtered by fields
388 -------------------------------------------
389
390     Get aggregate flow stats of the switch filtered by the OFPAggregateStats fields.
391     This is POST method version of :ref:`get-aggregate-flow-stats`.
392
393     Usage:
394
395         ======= ============================
396         Method  POST
397         URI     /stats/aggregateflow/<dpid>
398         ======= ============================
399
400     Request message body:
401
402         ============ ================================================================== =============== ===============
403         Attribute    Description                                                        Example         Default
404         ============ ================================================================== =============== ===============
405         table_id     Table ID (int)                                                     0               OFPTT_ALL
406         out_port     Require matching entries to include this as an output port (int)   2               OFPP_ANY
407         out_group    Require matching entries to include this as an output group (int)  1               OFPG_ANY
408         cookie       Require matching entries to contain this cookie value (int)        1               0
409         cookie_mask  Mask used to restrict the cookie bits that must match (int)        1               0
410         match        Fields to match (dict)                                             {"in_port": 1}  {} #wildcarded
411         ============ ================================================================== =============== ===============
412
413     Response message body:
414         The same as :ref:`get-aggregate-flow-stats`
415
416     Example of use::
417
418         $ curl -X POST -d '{
419              "table_id": 0,
420              "out_port": 2,
421              "cookie": 1,
422              "cookie_mask": 1,
423              "match":{
424                  "in_port":1
425              }
426          }' http://localhost:8080/stats/aggregateflow/1
427
428     .. code-block:: javascript
429
430         {
431           "1": [
432             {
433               "packet_count": 18,
434               "byte_count": 756,
435               "flow_count": 3
436             }
437           ]
438         }
439
440
441 Get table stats
442 ---------------
443
444     Get table stats of the switch which specified with Datapath ID in URI.
445
446     Usage:
447
448         ======= ===================
449         Method  GET
450         URI     /stats/table/<dpid>
451         ======= ===================
452
453     Response message body(OpenFlow1.0):
454
455         =============== ============================================================ ============
456         Attribute       Description                                                  Example
457         =============== ============================================================ ============
458         dpid            Datapath ID                                                  "1"
459         table_id        Table ID                                                     0
460         name            Name of Table                                                "classifier"
461         max_entries     Max number of entries supported                              1e+06
462         wildcards       Bitmap of OFPFW_* wildcards that are supported by the table  ["IN_PORT","DL_VLAN"]
463         active_count    Number of active entries                                     0
464         lookup_count    Number of packets looked up in table                         8
465         matched_count   Number of packets that hit table                             0
466         =============== ============================================================ ============
467
468     Response message body(OpenFlow1.2):
469
470         =============== ============================================================ ====================
471         Attribute       Description                                                  Example
472         =============== ============================================================ ====================
473         dpid            Datapath ID                                                  "1"
474         table_id        Table ID                                                     0
475         name            Name of Table                                                "classifier"
476         match           Bitmap of (1 << OFPXMT_*) that indicate the                  ["OFB_IN_PORT","OFB_METADATA"]
477                         fields the table can match on
478         wildcards       Bitmap of (1 << OFPXMT_*) wildcards that are                 ["OFB_IN_PORT","OFB_METADATA"]
479                         supported by the table
480         write_actions   Bitmap of OFPAT_* that are supported                         ["OUTPUT","SET_MPLS_TTL"]
481                         by the table with OFPIT_WRITE_ACTIONS
482         apply_actions   Bitmap of OFPAT_* that are supported                         ["OUTPUT","SET_MPLS_TTL"]
483                         by the table with OFPIT_APPLY_ACTIONS
484         write_setfields Bitmap of (1 << OFPXMT_*) header fields that                 ["OFB_IN_PORT","OFB_METADATA"]
485                         can be set with OFPIT_WRITE_ACTIONS
486         apply_setfields Bitmap of (1 << OFPXMT_*) header fields that                 ["OFB_IN_PORT","OFB_METADATA"]
487                         can be set with OFPIT_APPLY_ACTIONS
488         metadata_match  Bits of metadata table can match                             18446744073709552000
489         metadata_write  Bits of metadata table can write                             18446744073709552000
490         instructions    Bitmap of OFPIT_* values supported                           ["GOTO_TABLE","WRITE_METADATA"]
491         config          Bitmap of OFPTC_* values                                     []
492         max_entries     Max number of entries supported                              1e+06
493         active_count    Number of active entries                                     0
494         lookup_count    Number of packets looked up in table                         0
495         matched_count   Number of packets that hit table                             8
496         =============== ============================================================ ====================
497
498     Response message body(OpenFlow1.3):
499
500         ============== ============================================================= =========
501         Attribute      Description                                                   Example
502         ============== ============================================================= =========
503         dpid           Datapath ID                                                   "1"
504         table_id       Table ID                                                      0
505         active_count   Number of active entries                                      0
506         lookup_count   Number of packets looked up in table                          8
507         matched_count  Number of packets that hit table                              0
508         ============== ============================================================= =========
509
510
511     Example of use::
512
513         $ curl -X GET http://localhost:8080/stats/table/1
514
515     Response (OpenFlow1.0):
516
517     .. code-block:: javascript
518
519         {
520           "1": [
521             {
522               "table_id": 0,
523               "lookup_count": 8,
524               "max_entries": 1e+06,
525               "active_count": 0,
526               "name": "classifier",
527               "matched_count": 0,
528               "wildcards": [
529                "IN_PORT",
530                "DL_VLAN"
531               ]
532             },
533             ...
534             {
535               "table_id": 253,
536               "lookup_count": 0,
537               "max_entries": 1e+06,
538               "active_count": 0,
539               "name": "table253",
540               "matched_count": 0,
541               "wildcards": [
542                "IN_PORT",
543                "DL_VLAN"
544               ]
545             }
546           ]
547         }
548
549     Response (OpenFlow1.2):
550
551     .. code-block:: javascript
552
553         {
554           "1": [
555             {
556               "apply_setfields": [
557                "OFB_IN_PORT",
558                "OFB_METADATA"
559               ],
560               "match": [
561                "OFB_IN_PORT",
562                "OFB_METADATA"
563               ],
564               "metadata_write": 18446744073709552000,
565               "config": [],
566               "instructions":[
567                "GOTO_TABLE",
568                "WRITE_METADATA"
569               ],
570               "table_id": 0,
571               "metadata_match": 18446744073709552000,
572               "lookup_count": 8,
573               "wildcards": [
574                "OFB_IN_PORT",
575                "OFB_METADATA"
576               ],
577               "write_setfields": [
578                "OFB_IN_PORT",
579                "OFB_METADATA"
580               ],
581               "write_actions": [
582                "OUTPUT",
583                "SET_MPLS_TTL"
584               ],
585               "name": "classifier",
586               "matched_count": 0,
587               "apply_actions": [
588                "OUTPUT",
589                "SET_MPLS_TTL"
590               ],
591               "active_count": 0,
592               "max_entries": 1e+06
593             },
594             ...
595             {
596               "apply_setfields": [
597                "OFB_IN_PORT",
598                "OFB_METADATA"
599               ],
600               "match": [
601                "OFB_IN_PORT",
602                "OFB_METADATA"
603               ],
604               "metadata_write": 18446744073709552000,
605               "config": [],
606               "instructions": [
607                "GOTO_TABLE",
608                "WRITE_METADATA"
609               ],
610               "table_id": 253,
611               "metadata_match": 18446744073709552000,
612               "lookup_count": 0,
613               "wildcards": [
614                "OFB_IN_PORT",
615                "OFB_METADATA"
616               ],
617               "write_setfields": [
618                "OFB_IN_PORT",
619                "OFB_METADATA"
620               ],
621               "write_actions": [
622                "OUTPUT",
623                "SET_MPLS_TTL"
624               ],
625               "name": "table253",
626               "matched_count": 0,
627               "apply_actions": [
628                "OUTPUT",
629                "SET_MPLS_TTL"
630               ],
631               "active_count": 0,
632               "max_entries": 1e+06
633             }
634           ]
635         }
636
637     Response (OpenFlow1.3):
638
639     .. code-block:: javascript
640
641         {
642           "1": [
643             {
644               "active_count": 0,
645               "table_id": 0,
646               "lookup_count": 8,
647               "matched_count": 0
648             },
649             ...
650             {
651               "active_count": 0,
652               "table_id": 253,
653               "lookup_count": 0,
654               "matched_count": 0
655             }
656           ]
657         }
658
659
660 Get table features
661 ------------------
662
663     Get table features of the switch which specified with Datapath ID in URI.
664
665     Usage:
666
667         ======= ===========================
668         Method  GET
669         URI     /stats/tablefeatures/<dpid>
670         ======= ===========================
671
672     Response message body:
673
674         ============== ==================================== =======================================================
675         Attribute      Description                          Example
676         ============== ==================================== =======================================================
677         dpid           Datapath ID                          "1"
678         table_id       Table ID                             0
679         name           Name of Table                        "table_0"
680         metadata_match Bits of metadata table can match     18446744073709552000
681         metadata_write Bits of metadata table can write     18446744073709552000
682         config         Bitmap of OFPTC_* values             0
683         max_entries    Max number of entries supported      4096
684         properties     struct ofp_table_feature_prop_header [{"type": "INSTRUCTIONS","instruction_ids": [...]},...]
685         ============== ==================================== =======================================================
686
687     Example of use::
688
689         $ curl -X GET http://localhost:8080/stats/tablefeatures/1
690
691     .. code-block:: javascript
692
693         {
694           "1": [
695             {
696               "metadata_write": 18446744073709552000,
697               "config": 0,
698               "table_id": 0,
699               "metadata_match": 18446744073709552000,
700               "max_entries": 4096,
701               "properties": [
702                 {
703                   "type": "INSTRUCTIONS",
704                   "instruction_ids": [
705                    {
706                    "len": 4,
707                    "type": 1
708                    },
709                    ...
710                   ]
711                 },
712                 ...
713               ],
714               "name": "table_0"
715             },
716             {
717               "metadata_write": 18446744073709552000,
718               "config": 0,
719               "table_id": 1,
720               "metadata_match": 18446744073709552000,
721               "max_entries": 4096,
722               "properties": [
723                 {
724                   "type": "INSTRUCTIONS",
725                   "instruction_ids": [
726                    {
727                    "len": 4,
728                    "type": 1
729                    },
730                    ...
731                   ]
732                 },
733                 ...
734               ],
735               "name": "table_1"
736             },
737             ...
738           ]
739         }
740
741
742 Get ports stats
743 ---------------
744
745     Get ports stats of the switch which specified with Datapath ID in URI.
746
747     Usage:
748
749         ======= ===========================
750         Method  GET
751         URI     /stats/port/<dpid>[/<port>]
752         ======= ===========================
753
754         .. NOTE::
755
756            Specification of port number is optional.
757
758
759     Response message body(OpenFlow1.3 or earlier):
760
761         ============== ============================================================ =========
762         Attribute      Description                                                  Example
763         ============== ============================================================ =========
764         dpid           Datapath ID                                                  "1"
765         port_no        Port number                                                  1
766         rx_packets     Number of received packets                                   9
767         tx_packets     Number of transmitted packets                                6
768         rx_bytes       Number of received bytes                                     738
769         tx_bytes       Number of transmitted bytes                                  252
770         rx_dropped     Number of packets dropped by RX                              0
771         tx_dropped     Number of packets dropped by TX                              0
772         rx_errors      Number of receive errors                                     0
773         tx_errors      Number of transmit errors                                    0
774         rx_frame_err   Number of frame alignment errors                             0
775         rx_over_err    Number of packets with RX overrun                            0
776         rx_crc_err     Number of CRC errors                                         0
777         collisions     Number of collisions                                         0
778         duration_sec   Time port has been alive in seconds                          12
779         duration_nsec  Time port has been alive in nanoseconds beyond duration_sec  9.76e+08
780         ============== ============================================================ =========
781
782
783     Response message body(OpenFlow1.4 or later):
784
785         ============== ============================================================ =================================================================================
786         Attribute      Description                                                  Example
787         ============== ============================================================ =================================================================================
788         dpid           Datapath ID                                                  "1"
789         port_no        Port number                                                  1
790         rx_packets     Number of received packets                                   9
791         tx_packets     Number of transmitted packets                                6
792         rx_bytes       Number of received bytes                                     738
793         tx_bytes       Number of transmitted bytes                                  252
794         rx_dropped     Number of packets dropped by RX                              0
795         tx_dropped     Number of packets dropped by TX                              0
796         rx_errors      Number of receive errors                                     0
797         tx_errors      Number of transmit errors                                    0
798         duration_sec   Time port has been alive in seconds                          12
799         duration_nsec  Time port has been alive in nanoseconds beyond duration_sec  9.76e+08
800         properties     struct ofp_port_desc_prop_header                             [{"rx_frame_err": 0, "rx_over_err": 0, "rx_crc_err": 0, "collisions": 0,...},...]
801         ============== ============================================================ =================================================================================
802
803     Example of use::
804
805         $ curl -X GET http://localhost:8080/stats/port/1
806
807     Response (OpenFlow1.3 or earlier):
808
809     .. code-block:: javascript
810
811         {
812           "1": [
813             {
814               "port_no": 1,
815               "rx_packets": 9,
816               "tx_packets": 6,
817               "rx_bytes": 738,
818               "tx_bytes": 252,
819               "rx_dropped": 0,
820               "tx_dropped": 0,
821               "rx_errors": 0,
822               "tx_errors": 0,
823               "rx_frame_err": 0,
824               "rx_over_err": 0,
825               "rx_crc_err": 0,
826               "collisions": 0,
827               "duration_sec": 12,
828               "duration_nsec": 9.76e+08
829             },
830             {
831               :
832               :
833             }
834           ]
835         }
836
837     Response (OpenFlow1.4 or later):
838
839     .. code-block:: javascript
840
841         {
842            "1": [
843              {
844                "port_no": 1,
845                "rx_packets": 9,
846                "tx_packets": 6,
847                "rx_bytes": 738,
848                "tx_bytes": 252,
849                "rx_dropped": 0,
850                "tx_dropped": 0,
851                "rx_errors": 0,
852                "tx_errors": 0,
853                "duration_nsec": 12,
854                "duration_sec": 9.76e+08,
855                "properties": [
856                  {
857                    "rx_frame_err": 0,
858                    "rx_over_err": 0,
859                    "rx_crc_err": 0,
860                    "collisions": 0,
861                    "type": "ETHERNET"
862                  },
863                  {
864                    "bias_current": 300,
865                    "flags": 3,
866                    "rx_freq_lmda": 1500,
867                    "rx_grid_span": 500,
868                    "rx_offset": 700,
869                    "rx_pwr": 2000,
870                    "temperature": 273,
871                    "tx_freq_lmda": 1500,
872                    "tx_grid_span": 500,
873                    "tx_offset": 700,
874                    "tx_pwr": 2000,
875                    "type": "OPTICAL"
876                  },
877                  {
878                    "data": [],
879                    "exp_type": 0,
880                    "experimenter": 101,
881                    "type": "EXPERIMENTER"
882                  },
883                  {
884                    :
885
886                    :
887                  }
888                ]
889              }
890            ]
891          }
892
893
894 .. _get-ports-description:
895
896 Get ports description
897 ---------------------
898
899     Get ports description of the switch which specified with Datapath ID in URI.
900
901     Usage(OpenFlow1.4 or earlier):
902
903         ======= =======================
904         Method  GET
905         URI     /stats/portdesc/<dpid>
906         ======= =======================
907
908     Usage(OpenFlow1.5 or later):
909
910         ======= ==================================
911         Method  GET
912         URI     /stats/portdesc/<dpid>/[<port>]
913         ======= ==================================
914
915         .. NOTE::
916
917            Specification of port number is optional.
918
919
920     Response message body(OpenFlow1.3 or earlier):
921
922         ============== ====================================== ====================
923         Attribute      Description                            Example
924         ============== ====================================== ====================
925         dpid           Datapath ID                            "1"
926         port_no        Port number                            1
927         hw_addr        Ethernet hardware address              "0a:b6:d0:0c:e1:d7"
928         name           Name of port                           "s1-eth1"
929         config         Bitmap of OFPPC_* flags                0
930         state          Bitmap of OFPPS_* flags                0
931         curr           Current features                       2112
932         advertised     Features being advertised by the port  0
933         supported      Features supported by the port         0
934         peer           Features advertised by peer            0
935         curr_speed     Current port bitrate in kbps           1e+07
936         max_speed      Max port bitrate in kbps               0
937         ============== ====================================== ====================
938
939     Response message body(OpenFlow1.4 or later):
940
941         ============== ====================================== ======================================
942         Attribute      Description                            Example
943         ============== ====================================== ======================================
944         dpid           Datapath ID                            "1"
945         port_no        Port number                            1
946         hw_addr        Ethernet hardware address              "0a:b6:d0:0c:e1:d7"
947         name           Name of port                           "s1-eth1"
948         config         Bitmap of OFPPC_* flags                0
949         state          Bitmap of OFPPS_* flags                0
950         length         Length of this entry                   168
951         properties     struct ofp_port_desc_prop_header       [{"length": 32, "curr": 10248,...}...]
952         ============== ====================================== ======================================
953
954     Example of use::
955
956         $ curl -X GET http://localhost:8080/stats/portdesc/1
957
958     Response (OpenFlow1.3 or earlier):
959
960     .. code-block:: javascript
961
962         {
963           "1": [
964             {
965               "port_no": 1,
966               "hw_addr": "0a:b6:d0:0c:e1:d7",
967               "name": "s1-eth1",
968               "config": 0,
969               "state": 0,
970               "curr": 2112,
971               "advertised": 0,
972               "supported": 0,
973               "peer": 0,
974               "curr_speed": 1e+07,
975               "max_speed": 0
976             },
977             {
978               :
979               :
980             }
981           ]
982         }
983
984     Response (OpenFlow1.4 or later):
985
986     .. code-block:: javascript
987
988         {
989            "1": [
990              {
991                "port_no": 1,
992                "hw_addr": "0a:b6:d0:0c:e1:d7",
993                "name": "s1-eth1",
994                "config": 0,
995                "state": 0,
996                "length": 168,
997                "properties": [
998                  {
999                    "length": 32,
1000                    "curr": 10248,
1001                    "advertised": 10240,
1002                    "supported": 10248,
1003                    "peer": 10248,
1004                    "curr_speed": 5000,
1005                    "max_speed": 5000,
1006                    "type": "ETHERNET"
1007                  },
1008                  {
1009                    "length": 40,
1010                    "rx_grid_freq_lmda": 1500,
1011                    "tx_grid_freq_lmda": 1500,
1012                    "rx_max_freq_lmda": 2000,
1013                    "tx_max_freq_lmda": 2000,
1014                    "rx_min_freq_lmda": 1000,
1015                    "tx_min_freq_lmda": 1000,
1016                    "tx_pwr_max": 2000,
1017                    "tx_pwr_min": 1000,
1018                    "supported": 1,
1019                    "type": "OPTICAL"
1020                  },
1021                  {
1022                    "data": [],
1023                    "exp_type": 0,
1024                    "experimenter": 101,
1025                    "length": 12,
1026                    "type": "EXPERIMENTER"
1027                  },
1028                  {
1029                    :
1030
1031                    :
1032                  }
1033                ]
1034              }
1035            ]
1036         }
1037
1038
1039 Get queues stats
1040 ----------------
1041
1042     Get queues stats of the switch which specified with Datapath ID in URI.
1043
1044     Usage:
1045
1046         ======= =========================================
1047         Method  GET
1048         URI     /stats/queue/<dpid>[/<port>[/<queue_id>]]
1049         ======= =========================================
1050
1051         .. NOTE::
1052
1053            Specification of port number and queue id are optional.
1054
1055            If you want to omitting the port number and setting the queue id,
1056            please specify the keyword "ALL" to the port number.
1057
1058            e.g. GET http://localhost:8080/stats/queue/1/ALL/1
1059
1060
1061     Response message body(OpenFlow1.3 or earlier):
1062
1063         ============== ============================================================= ===========
1064         Attribute      Description                                                   Example
1065         ============== ============================================================= ===========
1066         dpid           Datapath ID                                                   "1"
1067         port_no        Port number                                                   1
1068         queue_id       Queue ID                                                      0
1069         tx_bytes       Number of transmitted bytes                                   0
1070         tx_packets     Number of transmitted packets                                 0
1071         tx_errors      Number of packets dropped due to overrun                      0
1072         duration_sec   Time queue has been alive in seconds                          4294963425
1073         duration_nsec  Time queue has been alive in nanoseconds beyond duration_sec  3912967296
1074         ============== ============================================================= ===========
1075
1076     Response message body(OpenFlow1.4 or later):
1077
1078         ============== ============================================================= ======================================
1079         Attribute      Description                                                   Example
1080         ============== ============================================================= ======================================
1081         dpid           Datapath ID                                                   "1"
1082         port_no        Port number                                                   1
1083         queue_id       Queue ID                                                      0
1084         tx_bytes       Number of transmitted bytes                                   0
1085         tx_packets     Number of transmitted packets                                 0
1086         tx_errors      Number of packets dropped due to overrun                      0
1087         duration_sec   Time queue has been alive in seconds                          4294963425
1088         duration_nsec  Time queue has been alive in nanoseconds beyond duration_sec  3912967296
1089         length         Length of this entry                                          104
1090         properties     struct ofp_queue_stats_prop_header                            [{"type": 65535,"length": 12,...},...]
1091         ============== ============================================================= ======================================
1092
1093     Example of use::
1094
1095         $ curl -X GET http://localhost:8080/stats/queue/1
1096
1097     Response (OpenFlow1.3 or earlier):
1098
1099     .. code-block:: javascript
1100
1101         {
1102           "1": [
1103             {
1104               "port_no": 1,
1105               "queue_id": 0,
1106               "tx_bytes": 0,
1107               "tx_packets": 0,
1108               "tx_errors": 0,
1109               "duration_sec": 4294963425,
1110               "duration_nsec": 3912967296
1111             },
1112             {
1113               "port_no": 1,
1114               "queue_id": 1,
1115               "tx_bytes": 0,
1116               "tx_packets": 0,
1117               "tx_errors": 0,
1118               "duration_sec": 4294963425,
1119               "duration_nsec": 3912967296
1120             }
1121           ]
1122         }
1123
1124     Response (OpenFlow1.4 or later):
1125
1126     .. code-block:: javascript
1127
1128         {
1129           "1": [
1130             {
1131               "port_no": 1,
1132               "queue_id": 0,
1133               "tx_bytes": 0,
1134               "tx_packets": 0,
1135               "tx_errors": 0,
1136               "duration_sec": 4294963425,
1137               "duration_nsec": 3912967296,
1138               "length": 104,
1139               "properties": [
1140                  {
1141                     "OFPQueueStatsPropExperimenter": {
1142                        "type": 65535,
1143                        "length": 16,
1144                        "data": [
1145                           1
1146                        ],
1147                        "exp_type": 1,
1148                        "experimenter": 101
1149                     }
1150                  },
1151                  {
1152                     :
1153
1154                     :
1155                  }
1156               ]
1157             },
1158             {
1159               "port_no": 2,
1160               "queue_id": 1,
1161               "tx_bytes": 0,
1162               "tx_packets": 0,
1163               "tx_errors": 0,
1164               "duration_sec": 4294963425,
1165               "duration_nsec": 3912967296,
1166               "length": 48,
1167               "properties": []
1168             }
1169           ]
1170         }
1171
1172 .. _get-queues-config:
1173
1174 Get queues config
1175 -----------------
1176
1177     Get queues config of the switch which specified with Datapath ID and Port in URI.
1178
1179     Usage:
1180
1181         ======= ==================================
1182         Method  GET
1183         URI     /stats/queueconfig/<dpid>/[<port>]
1184         ======= ==================================
1185
1186         .. NOTE::
1187
1188            Specification of port number is optional.
1189
1190
1191         .. CAUTION::
1192
1193            This message is deprecated in Openflow1.4.
1194            If OpenFlow 1.4 or later is in use, please refer to :ref:`get-queues-description` instead.
1195
1196     Response message body:
1197
1198         ================ ====================================================== ========================================
1199         Attribute        Description                                            Example
1200         ================ ====================================================== ========================================
1201         dpid             Datapath ID                                            "1"
1202         port             Port which was queried                                 1
1203         queues           struct ofp_packet_queue
1204         -- queue_id      ID for the specific queue                              2
1205         -- port          Port this queue is attached to                         0
1206         -- properties    struct ofp_queue_prop_header properties                [{"property": "MIN_RATE","rate": 80}]
1207         ================ ====================================================== ========================================
1208
1209     Example of use::
1210
1211         $ curl -X GET http://localhost:8080/stats/queueconfig/1/1
1212
1213     .. code-block:: javascript
1214
1215         {
1216           "1": [
1217             {
1218               "port": 1,
1219               "queues": [
1220                 {
1221                   "properties": [
1222                     {
1223                       "property": "MIN_RATE",
1224                       "rate": 80
1225                     }
1226                   ],
1227                   "port": 0,
1228                   "queue_id": 1
1229                 },
1230                 {
1231                   "properties": [
1232                     {
1233                       "property": "MAX_RATE",
1234                       "rate": 120
1235                     }
1236                   ],
1237                   "port": 2,
1238                   "queue_id": 2
1239                 },
1240                 {
1241                   "properties": [
1242                     {
1243                       "property": "EXPERIMENTER",
1244                       "data": [],
1245                       "experimenter": 999
1246                     }
1247                   ],
1248                   "port": 3,
1249                   "queue_id": 3
1250                 }
1251               ]
1252             }
1253           ]
1254         }
1255
1256 .. _get-queues-description:
1257
1258 Get queues description
1259 ----------------------
1260
1261     Get queues description of the switch which specified with Datapath ID, Port and Queue_id in URI.
1262
1263     Usage:
1264
1265         ======= =============================================
1266         Method  GET
1267         URI     /stats/queuedesc/<dpid>[/<port>/[<queue_id>]]
1268         ======= =============================================
1269
1270         .. NOTE::
1271
1272            Specification of port number and queue id are optional.
1273
1274            If you want to omitting the port number and setting the queue id,
1275            please specify the keyword "ALL" to the port number.
1276
1277            e.g. GET http://localhost:8080/stats/queuedesc/1/ALL/1
1278
1279
1280         .. CAUTION::
1281
1282            This message is available in OpenFlow1.4 or later.
1283            If Openflow1.3 or earlier is in use, please refer to :ref:`get-queues-config` instead.
1284
1285
1286     Response message body:
1287
1288         ================ ====================================================== ========================================
1289         Attribute        Description                                            Example
1290         ================ ====================================================== ========================================
1291         dpid             Datapath ID                                            "1"
1292         len              Length in bytes of this queue desc                     88
1293         port_no          Port which was queried                                 1
1294         queue_id         Queue ID                                               1
1295         properties       struct ofp_queue_desc_prop_header                      [{"length": 8, ...},...]
1296         ================ ====================================================== ========================================
1297
1298     Example of use::
1299
1300         $ curl -X GET http://localhost:8080/stats/queuedesc/1/1/1
1301
1302     .. code-block:: javascript
1303
1304
1305         {
1306          "1": [
1307              {
1308                "len": 88,
1309                "port_no": 1,
1310                "queue_id": 1,
1311                "properties": [
1312                  {
1313                    "length": 8,
1314                    "rate": 300,
1315                    "type": "MIN_RATE"
1316                  },
1317                  {
1318                    "length": 8,
1319                    "rate": 900,
1320                    "type": "MAX_RATE"
1321                  },
1322                  {
1323                    "length": 16,
1324                    "exp_type": 0,
1325                    "experimenter": 101,
1326                    "data": [1],
1327                    "type": "EXPERIMENTER"
1328                  },
1329                  {
1330                    :
1331
1332                    :
1333                  }
1334                ]
1335              }
1336            ]
1337          }
1338
1339
1340 Get groups stats
1341 ----------------
1342
1343     Get groups stats of the switch which specified with Datapath ID in URI.
1344
1345     Usage:
1346
1347         ======= ================================
1348         Method  GET
1349         URI     /stats/group/<dpid>[/<group_id>]
1350         ======= ================================
1351
1352         .. NOTE::
1353
1354            Specification of group id is optional.
1355
1356
1357     Response message body:
1358
1359         ================ ============================================================== =========
1360         Attribute        Description                                                    Example
1361         ================ ============================================================== =========
1362         dpid             Datapath ID                                                    "1"
1363         length           Length of this entry                                           56
1364         group_id         Group ID                                                       1
1365         ref_count        Number of flows or groups that directly forward to this group  1
1366         packet_count     Number of packets processed by group                           0
1367         byte_count       Number of bytes processed by group                             0
1368         duration_sec     Time group has been alive in seconds                           161
1369         duration_nsec    Time group has been alive in nanoseconds beyond duration_sec   3.03e+08
1370         bucket_stats     struct ofp_bucket_counter
1371         -- packet_count  Number of packets processed by bucket                          0
1372         -- byte_count    Number of bytes processed by bucket                            0
1373         ================ ============================================================== =========
1374
1375     Example of use::
1376
1377         $ curl -X GET http://localhost:8080/stats/group/1
1378
1379     .. code-block:: javascript
1380
1381         {
1382           "1": [
1383             {
1384               "length": 56,
1385               "group_id": 1,
1386               "ref_count": 1,
1387               "packet_count": 0,
1388               "byte_count": 0,
1389               "duration_sec": 161,
1390               "duration_nsec": 3.03e+08,
1391               "bucket_stats": [
1392                 {
1393                   "packet_count": 0,
1394                   "byte_count": 0
1395                 }
1396               ]
1397             }
1398           ]
1399         }
1400
1401
1402 .. _get-group-description-stats:
1403
1404 Get group description stats
1405 ---------------------------
1406
1407     Get group description stats of the switch which specified with Datapath ID in URI.
1408
1409     Usage(Openflow1.4 or earlier):
1410
1411         ======= ========================
1412         Method  GET
1413         URI     /stats/groupdesc/<dpid>
1414         ======= ========================
1415
1416     Usage(Openflow1.5 or later):
1417
1418         ======= ====================================
1419         Method  GET
1420         URI     /stats/groupdesc/<dpid>/[<group_id>]
1421         ======= ====================================
1422
1423         .. NOTE::
1424
1425            Specification of group id is optional.
1426
1427
1428     Response message body(Openflow1.3 or earlier):
1429
1430         =============== ======================================================= =============
1431         Attribute       Description                                             Example
1432         =============== ======================================================= =============
1433         dpid            Datapath ID                                             "1"
1434         type            One of OFPGT_*                                          "ALL"
1435         group_id        Group ID                                                1
1436         buckets         struct ofp_bucket
1437         -- weight       Relative weight of bucket                               0
1438                         (Only defined for select groups)
1439         -- watch_port   Port whose state affects whether this bucket is live    4294967295
1440                         (Only required for fast failover groups)
1441         -- watch_group  Group whose state affects whether this bucket is live   4294967295
1442                         (Only required for fast failover groups)
1443         -- actions      0 or more actions associated with the bucket            ["OUTPUT:1"]
1444         =============== ======================================================= =============
1445
1446     Response message body(Openflow1.4 or later):
1447
1448         =============== ======================================================= ====================================
1449         Attribute       Description                                             Example
1450         =============== ======================================================= ====================================
1451         dpid            Datapath ID                                             "1"
1452         type            One of OFPGT_*                                          "ALL"
1453         group_id        Group ID                                                1
1454         length          Length of this entry                                    40
1455         buckets         struct ofp_bucket
1456         -- weight       Relative weight of bucket                               0
1457                         (Only defined for select groups)
1458         -- watch_port   Port whose state affects whether this bucket is live    4294967295
1459                         (Only required for fast failover groups)
1460         -- watch_group  Group whose state affects whether this bucket is live   4294967295
1461                         (Only required for fast failover groups)
1462         -- len          Length the bucket in bytes, including this header and   32
1463                         any adding to make it 64-bit aligned.
1464         -- actions      0 or more actions associated with the bucket            [{"OUTPUT:1", "max_len": 65535,...}]
1465         =============== ======================================================= ====================================
1466
1467     Example of use::
1468
1469         $ curl -X GET http://localhost:8080/stats/groupdesc/1
1470
1471     Response (Openflow1.3 or earlier):
1472
1473     .. code-block:: javascript
1474
1475         {
1476           "1": [
1477             {
1478               "type": "ALL",
1479               "group_id": 1,
1480               "buckets": [
1481                 {
1482                   "weight": 0,
1483                   "watch_port": 4294967295,
1484                   "watch_group": 4294967295,
1485                   "actions": [
1486                     "OUTPUT:1"
1487                   ]
1488                 }
1489               ]
1490             }
1491           ]
1492         }
1493
1494     Response (Openflow1.4 or later):
1495
1496     .. code-block:: javascript
1497
1498         {
1499            "1": [
1500              {
1501                "type": "ALL",
1502                "group_id": 1,
1503                "length": 40,
1504                "buckets": [
1505                  {
1506                    "weight": 1,
1507                    "watch_port": 1,
1508                    "watch_group": 1,
1509                    "len": 32,
1510                    "actions": [
1511                      {
1512                          "type": "OUTPUT",
1513                          "max_len": 65535,
1514                          "port": 2
1515                      }
1516                    ]
1517                  }
1518                ]
1519              }
1520            ]
1521         }
1522
1523
1524 Get group features stats
1525 ------------------------
1526
1527     Get group features stats of the switch which specified with Datapath ID in URI.
1528
1529     Usage:
1530
1531         ======= ============================
1532         Method  GET
1533         URI     /stats/groupfeatures/<dpid>
1534         ======= ============================
1535
1536     Response message body:
1537
1538         ============== =========================================== ===============================================
1539         Attribute      Description                                 Example
1540         ============== =========================================== ===============================================
1541         dpid           Datapath ID                                 "1"
1542         types          Bitmap of (1 << OFPGT_*) values supported   []
1543         capabilities   Bitmap of OFPGFC_* capability supported     ["SELECT_WEIGHT","SELECT_LIVENESS","CHAINING"]
1544         max_groups     Maximum number of groups for each type      [{"ALL": 4294967040},...]
1545         actions        Bitmaps of (1 << OFPAT_*) values supported  [{"ALL": ["OUTPUT",...]},...]
1546         ============== =========================================== ===============================================
1547
1548     Example of use::
1549
1550         $ curl -X GET http://localhost:8080/stats/groupfeatures/1
1551
1552     .. code-block:: javascript
1553
1554         {
1555           "1": [
1556             {
1557               "types": [],
1558               "capabilities": [
1559                 "SELECT_WEIGHT",
1560                 "SELECT_LIVENESS",
1561                 "CHAINING"
1562               ],
1563               "max_groups": [
1564                 {
1565                   "ALL": 4294967040
1566                 },
1567                 {
1568                   "SELECT": 4294967040
1569                 },
1570                 {
1571                   "INDIRECT": 4294967040
1572                 },
1573                 {
1574                   "FF": 4294967040
1575                 }
1576               ],
1577               "actions": [
1578                 {
1579                   "ALL": [
1580                     "OUTPUT",
1581                     "COPY_TTL_OUT",
1582                     "COPY_TTL_IN",
1583                     "SET_MPLS_TTL",
1584                     "DEC_MPLS_TTL",
1585                     "PUSH_VLAN",
1586                     "POP_VLAN",
1587                     "PUSH_MPLS",
1588                     "POP_MPLS",
1589                     "SET_QUEUE",
1590                     "GROUP",
1591                     "SET_NW_TTL",
1592                     "DEC_NW_TTL",
1593                     "SET_FIELD"
1594                   ]
1595                 },
1596                 {
1597                   "SELECT": []
1598                 },
1599                 {
1600                   "INDIRECT": []
1601                 },
1602                 {
1603                   "FF": []
1604                 }
1605               ]
1606             }
1607           ]
1608         }
1609
1610
1611 Get meters stats
1612 ----------------
1613
1614     Get meters stats of the switch which specified with Datapath ID in URI.
1615
1616     Usage:
1617
1618         ======= ================================
1619         Method  GET
1620         URI     /stats/meter/<dpid>[/<meter_id>]
1621         ======= ================================
1622
1623         .. NOTE::
1624
1625            Specification of meter id is optional.
1626
1627
1628     Response message body:
1629
1630         ===================== ============================================================= ========
1631         Attribute             Description                                                   Example
1632         ===================== ============================================================= ========
1633         dpid                  Datapath ID                                                   "1"
1634         meter_id              Meter ID                                                      1
1635         len                   Length in bytes of this stats                                 56
1636         flow_count            Number of flows bound to meter                                0
1637         packet_in_count       Number of packets in input                                    0
1638         byte_in_count         Number of bytes in input                                      0
1639         duration_sec          Time meter has been alive in seconds                          37
1640         duration_nsec         Time meter has been alive in nanoseconds beyond duration_sec  988000
1641         band_stats            struct ofp_meter_band_stats
1642         -- packet_band_count  Number of packets in band                                     0
1643         -- byte_band_count    Number of bytes in band                                       0
1644         ===================== ============================================================= ========
1645
1646     Example of use::
1647
1648         $ curl -X GET http://localhost:8080/stats/meter/1
1649
1650     .. code-block:: javascript
1651
1652         {
1653           "1": [
1654             {
1655               "meter_id": 1,
1656               "len": 56,
1657               "flow_count": 0,
1658               "packet_in_count": 0,
1659               "byte_in_count": 0,
1660               "duration_sec": 37,
1661               "duration_nsec": 988000,
1662               "band_stats": [
1663                 {
1664                   "packet_band_count": 0,
1665                   "byte_band_count": 0
1666                 }
1667               ]
1668             }
1669           ]
1670         }
1671
1672
1673 .. _get-meter-config-stats:
1674
1675 Get meter config stats
1676 ----------------------
1677 Get meter description stats
1678 ---------------------------
1679
1680     Get meter config stats of the switch which specified with Datapath ID in URI.
1681
1682         .. CAUTION::
1683
1684            This message has been renamed in openflow 1.5.
1685            If Openflow 1.4 or earlier is in use, please used as Get meter description stats.
1686            If Openflow 1.5 or later is in use, please used as Get meter description stats.
1687
1688
1689     Usage(Openflow1.4 or earlier):
1690
1691         ======= ======================================
1692         Method  GET
1693         URI     /stats/meterconfig/<dpid>[/<meter_id>]
1694         ======= ======================================
1695
1696     Usage(Openflow1.5 or later):
1697
1698         ======= ======================================
1699         Method  GET
1700         URI     /stats/meterdesc/<dpid>[/<meter_id>]
1701         ======= ======================================
1702
1703         .. NOTE::
1704
1705            Specification of meter id is optional.
1706
1707
1708     Response message body:
1709
1710         ============== ============================================ =========
1711         Attribute      Description                                  Example
1712         ============== ============================================ =========
1713         dpid           Datapath ID                                  "1"
1714         flags          All OFPMC_* that apply                       "KBPS"
1715         meter_id       Meter ID                                     1
1716         bands          struct ofp_meter_band_header
1717         -- type        One of OFPMBT_*                              "DROP"
1718         -- rate        Rate for this band                           1000
1719         -- burst_size  Size of bursts                               0
1720         ============== ============================================ =========
1721
1722     Example of use::
1723
1724         $ curl -X GET http://localhost:8080/stats/meterconfig/1
1725
1726     .. code-block:: javascript
1727
1728         {
1729           "1": [
1730             {
1731               "flags": [
1732                 "KBPS"
1733               ],
1734               "meter_id": 1,
1735               "bands": [
1736                 {
1737                   "type": "DROP",
1738                   "rate": 1000,
1739                   "burst_size": 0
1740                 }
1741               ]
1742             }
1743           ]
1744         }
1745
1746
1747 Get meter features stats
1748 ------------------------
1749
1750     Get meter features stats of the switch which specified with Datapath ID in URI.
1751
1752     Usage:
1753
1754         ======= ============================
1755         Method  GET
1756         URI     /stats/meterfeatures/<dpid>
1757         ======= ============================
1758
1759     Response message body:
1760
1761         ============= ============================================ ===========================
1762         Attribute     Description                                  Example
1763         ============= ============================================ ===========================
1764         dpid          Datapath ID                                  "1"
1765         max_meter     Maximum number of meters                     256
1766         band_types    Bitmaps of (1 << OFPMBT_*) values supported  ["DROP"]
1767         capabilities  Bitmaps of "ofp_meter_flags"                 ["KBPS", "BURST", "STATS"]
1768         max_bands     Maximum bands per meters                     16
1769         max_color     Maximum color value                          8
1770         ============= ============================================ ===========================
1771
1772     Example of use::
1773
1774         $ curl -X GET http://localhost:8080/stats/meterfeatures/1
1775
1776     .. code-block:: javascript
1777
1778         {
1779           "1": [
1780             {
1781               "max_meter": 256,
1782               "band_types": [
1783                 "DROP"
1784               ],
1785               "capabilities": [
1786                 "KBPS",
1787                 "BURST",
1788                 "STATS"
1789               ],
1790               "max_bands": 16,
1791               "max_color": 8
1792             }
1793           ]
1794         }
1795
1796
1797 Get role
1798 --------
1799
1800     Get the current role of the controller from the switch.
1801
1802     Usage:
1803
1804         ======= =========================
1805         Method  GET
1806         URI     /stats/role/<dpid>
1807         ======= =========================
1808
1809     Response message body(Openflow1.4 or earlier):
1810
1811         ============= ============================= =========
1812         Attribute     Description                   Example
1813         ============= ============================= =========
1814         dpid          Datapath ID                   1
1815         role          One of OFPCR_ROLE_*           "EQUAL"
1816         generation_id Master Election Generation Id 0
1817         ============= ============================= =========
1818
1819     Response message body(Openflow1.5 or later):
1820
1821         ============= ============================= =========
1822         Attribute     Description                   Example
1823         ============= ============================= =========
1824         dpid          Datapath ID                   1
1825         role          One of OFPCR_ROLE_*           "EQUAL"
1826         short_id      ID number for the controller  0
1827         generation_id Master Election Generation Id 0
1828         ============= ============================= =========
1829
1830     Example of use::
1831
1832         $ curl -X GET http://localhost:8080/stats/role/1
1833
1834     Response (Openflow1.4 or earlier):
1835
1836     .. code-block:: javascript
1837
1838         {
1839             "1": [
1840                 {
1841                     "generation_id": 0,
1842                     "role": "EQUAL"
1843                 }
1844             ]
1845         }
1846
1847
1848     Response (Openflow1.5 or later):
1849
1850     .. code-block:: javascript
1851
1852         {
1853             "1": [
1854                 {
1855                     "generation_id": 0,
1856                     "role": "EQUAL",
1857                     "short_id": 0
1858                 }
1859             ]
1860         }
1861
1862
1863 Update the switch stats
1864 =======================
1865
1866 Add a flow entry
1867 ----------------
1868
1869     Add a flow entry to the switch.
1870
1871     Usage:
1872
1873         ======= =====================
1874         Method  POST
1875         URI     /stats/flowentry/add
1876         ======= =====================
1877
1878     Request message body(Openflow1.3 or earlier):
1879
1880         ============= ===================================================== ============================== ===============
1881         Attribute     Description                                           Example                        Default
1882         ============= ===================================================== ============================== ===============
1883         dpid          Datapath ID (int)                                     1                              (Mandatory)
1884         cookie        Opaque controller-issued identifier (int)             1                              0
1885         cookie_mask   Mask used to restrict the cookie bits (int)           1                              0
1886         table_id      Table ID to put the flow in (int)                     0                              0
1887         idle_timeout  Idle time before discarding (seconds) (int)           30                             0
1888         hard_timeout  Max time before discarding (seconds) (int)            30                             0
1889         priority      Priority level of flow entry (int)                    11111                          0
1890         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                              OFP_NO_BUFFER
1891         flags         Bitmap of OFPFF_* flags (int)                         1                              0
1892         match         Fields to match (dict)                                {"in_port":1}                  {} #wildcarded
1893         actions       Instruction set (list of dict)                        [{"type":"OUTPUT", "port":2}]  [] #DROP
1894         ============= ===================================================== ============================== ===============
1895
1896     Request message body(Openflow1.4 or later):
1897
1898         ============= ===================================================== ================================ ===============
1899         Attribute     Description                                           Example                          Default
1900         ============= ===================================================== ================================ ===============
1901         dpid          Datapath ID (int)                                     1                                (Mandatory)
1902         cookie        Opaque controller-issued identifier (int)             1                                0
1903         cookie_mask   Mask used to restrict the cookie bits (int)           1                                0
1904         table_id      Table ID to put the flow in (int)                     0                                0
1905         idle_timeout  Idle time before discarding (seconds) (int)           30                               0
1906         hard_timeout  Max time before discarding (seconds) (int)            30                               0
1907         priority      Priority level of flow entry (int)                    11111                            0
1908         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                                OFP_NO_BUFFER
1909         flags         Bitmap of OFPFF_* flags (int)                         1                                0
1910         match         Fields to match (dict)                                {"in_port":1}                    {} #wildcarded
1911         instructions  Instruction set (list of dict)                        [{"type":"METER", "meter_id":2}] [] #DROP
1912         ============= ===================================================== ================================ ===============
1913
1914     .. NOTE::
1915
1916         For description of match and actions, please see :ref:`description-of-match-and-actions`.
1917
1918     Example of use(Openflow1.3 or earlier):
1919
1920     ::
1921
1922         $ curl -X POST -d '{
1923             "dpid": 1,
1924             "cookie": 1,
1925             "cookie_mask": 1,
1926             "table_id": 0,
1927             "idle_timeout": 30,
1928             "hard_timeout": 30,
1929             "priority": 11111,
1930             "flags": 1,
1931             "match":{
1932                 "in_port":1
1933             },
1934             "actions":[
1935                 {
1936                     "type":"OUTPUT",
1937                     "port": 2
1938                 }
1939             ]
1940          }' http://localhost:8080/stats/flowentry/add
1941
1942     ::
1943
1944         $ curl -X POST -d '{
1945             "dpid": 1,
1946             "priority": 22222,
1947             "match":{
1948                 "in_port":1
1949             },
1950             "actions":[
1951                 {
1952                     "type":"GOTO_TABLE",
1953                     "table_id": 1
1954                 }
1955             ]
1956          }' http://localhost:8080/stats/flowentry/add
1957
1958     ::
1959
1960         $ curl -X POST -d '{
1961             "dpid": 1,
1962             "priority": 33333,
1963             "match":{
1964                 "in_port":1
1965             },
1966             "actions":[
1967                 {
1968                     "type":"WRITE_METADATA",
1969                     "metadata": 1,
1970                     "metadata_mask": 1
1971                 }
1972             ]
1973          }' http://localhost:8080/stats/flowentry/add
1974
1975     ::
1976
1977         $ curl -X POST -d '{
1978             "dpid": 1,
1979             "priority": 44444,
1980             "match":{
1981                 "in_port":1
1982             },
1983             "actions":[
1984                 {
1985                     "type":"METER",
1986                     "meter_id": 1
1987                 }
1988             ]
1989          }' http://localhost:8080/stats/flowentry/add
1990
1991     Example of use(Openflow1.4 or later):
1992
1993     ::
1994
1995         $ curl -X POST -d '{
1996             "dpid": 1,
1997             "cookie": 1,
1998             "cookie_mask": 1,
1999             "table_id": 0,
2000             "idle_timeout": 30,
2001             "hard_timeout": 30,
2002             "priority": 11111,
2003             "flags": 1,
2004             "match":{
2005                 "in_port":1
2006             },
2007             "instructions": [
2008                 {
2009                     "type": "APPLY_ACTIONS",
2010                     "actions": [
2011                         {
2012                             "max_len": 65535,
2013                             "port": 2,
2014                             "type": "OUTPUT"
2015                         }
2016                     ]
2017                 }
2018             ]
2019          }' http://localhost:8080/stats/flowentry/add
2020
2021     ::
2022
2023         $ curl -X POST -d '{
2024             "dpid": 1,
2025             "priority": 22222,
2026             "match":{
2027                 "in_port":1
2028             },
2029             "instructions": [
2030                 {
2031                     "type":"GOTO_TABLE",
2032                     "table_id": 1
2033                 }
2034             ]
2035          }' http://localhost:8080/stats/flowentry/add
2036
2037     ::
2038
2039         $ curl -X POST -d '{
2040             "dpid": 1,
2041             "priority": 33333,
2042             "match":{
2043                 "in_port":1
2044             },
2045             "instructions": [
2046                 {
2047                     "type":"WRITE_METADATA",
2048                     "metadata": 1,
2049                     "metadata_mask": 1
2050                 }
2051             ]
2052          }' http://localhost:8080/stats/flowentry/add
2053
2054     ::
2055
2056         $ curl -X POST -d '{
2057             "dpid": 1,
2058             "priority": 44444,
2059             "match":{
2060                 "in_port":1
2061             },
2062             "instructions": [
2063                 {
2064                     "type":"METER",
2065                     "meter_id": 1
2066                 }
2067             ]
2068          }' http://localhost:8080/stats/flowentry/add
2069
2070     .. NOTE::
2071
2072         To confirm flow entry registration, please see :ref:`get-all-flows-stats` or :ref:`get-flows-stats-filtered`.
2073
2074
2075 Modify all matching flow entries
2076 --------------------------------
2077
2078     Modify all matching flow entries of the switch.
2079
2080     Usage:
2081
2082         ======= ========================
2083         Method  POST
2084         URI     /stats/flowentry/modify
2085         ======= ========================
2086
2087     Request message body:
2088
2089         ============= ===================================================== ============================== ===============
2090         Attribute     Description                                           Example                        Default
2091         ============= ===================================================== ============================== ===============
2092         dpid          Datapath ID (int)                                     1                              (Mandatory)
2093         cookie        Opaque controller-issued identifier (int)             1                              0
2094         cookie_mask   Mask used to restrict the cookie bits (int)           1                              0
2095         table_id      Table ID to put the flow in (int)                     0                              0
2096         idle_timeout  Idle time before discarding (seconds) (int)           30                             0
2097         hard_timeout  Max time before discarding (seconds) (int)            30                             0
2098         priority      Priority level of flow entry (int)                    11111                          0
2099         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                              OFP_NO_BUFFER
2100         flags         Bitmap of OFPFF_* flags (int)                         1                              0
2101         match         Fields to match (dict)                                {"in_port":1}                  {} #wildcarded
2102         actions       Instruction set (list of dict)                        [{"type":"OUTPUT", "port":2}]  [] #DROP
2103         ============= ===================================================== ============================== ===============
2104
2105     Example of use::
2106
2107         $ curl -X POST -d '{
2108             "dpid": 1,
2109             "cookie": 1,
2110             "cookie_mask": 1,
2111             "table_id": 0,
2112             "idle_timeout": 30,
2113             "hard_timeout": 30,
2114             "priority": 11111,
2115             "flags": 1,
2116             "match":{
2117                 "in_port":1
2118             },
2119             "actions":[
2120                 {
2121                     "type":"OUTPUT",
2122                     "port": 2
2123                 }
2124             ]
2125          }' http://localhost:8080/stats/flowentry/modify
2126
2127
2128 Modify flow entry strictly
2129 --------------------------
2130
2131     Modify flow entry strictly matching wildcards and priority
2132
2133     Usage:
2134
2135         ======= ===============================
2136         Method  POST
2137         URI     /stats/flowentry/modify_strict
2138         ======= ===============================
2139
2140     Request message body:
2141
2142         ============= ===================================================== ============================== ===============
2143         Attribute     Description                                           Example                        Default
2144         ============= ===================================================== ============================== ===============
2145         dpid          Datapath ID (int)                                     1                              (Mandatory)
2146         cookie        Opaque controller-issued identifier (int)             1                              0
2147         cookie_mask   Mask used to restrict the cookie bits (int)           1                              0
2148         table_id      Table ID to put the flow in (int)                     0                              0
2149         idle_timeout  Idle time before discarding (seconds) (int)           30                             0
2150         hard_timeout  Max time before discarding (seconds) (int)            30                             0
2151         priority      Priority level of flow entry (int)                    11111                          0
2152         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                              OFP_NO_BUFFER
2153         flags         Bitmap of OFPFF_* flags (int)                         1                              0
2154         match         Fields to match (dict)                                {"in_port":1}                  {} #wildcarded
2155         actions       Instruction set (list of dict)                        [{"type":"OUTPUT", "port":2}]  [] #DROP
2156         ============= ===================================================== ============================== ===============
2157
2158     Example of use::
2159
2160         $ curl -X POST -d '{
2161             "dpid": 1,
2162             "cookie": 1,
2163             "cookie_mask": 1,
2164             "table_id": 0,
2165             "idle_timeout": 30,
2166             "hard_timeout": 30,
2167             "priority": 11111,
2168             "flags": 1,
2169             "match":{
2170                 "in_port":1
2171             },
2172             "actions":[
2173                 {
2174                     "type":"OUTPUT",
2175                     "port": 2
2176                 }
2177             ]
2178          }' http://localhost:8080/stats/flowentry/modify_strict
2179
2180
2181 Delete all matching flow entries
2182 --------------------------------
2183
2184     Delete all matching flow entries of the switch.
2185
2186     Usage:
2187
2188         ======= ========================
2189         Method  POST
2190         URI     /stats/flowentry/delete
2191         ======= ========================
2192
2193     Request message body:
2194
2195         ============= ===================================================== ============================== ===============
2196         Attribute     Description                                           Example                        Default
2197         ============= ===================================================== ============================== ===============
2198         dpid          Datapath ID (int)                                     1                              (Mandatory)
2199         cookie        Opaque controller-issued identifier (int)             1                              0
2200         cookie_mask   Mask used to restrict the cookie bits (int)           1                              0
2201         table_id      Table ID to put the flow in (int)                     0                              0
2202         idle_timeout  Idle time before discarding (seconds) (int)           30                             0
2203         hard_timeout  Max time before discarding (seconds) (int)            30                             0
2204         priority      Priority level of flow entry (int)                    11111                          0
2205         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                              OFP_NO_BUFFER
2206         out_port      Output port (int)                                     1                              OFPP_ANY
2207         out_group     Output group (int)                                    1                              OFPG_ANY
2208         flags         Bitmap of OFPFF_* flags (int)                         1                              0
2209         match         Fields to match (dict)                                {"in_port":1}                  {} #wildcarded
2210         actions       Instruction set (list of dict)                        [{"type":"OUTPUT", "port":2}]  [] #DROP
2211         ============= ===================================================== ============================== ===============
2212
2213     Example of use::
2214
2215         $ curl -X POST -d '{
2216             "dpid": 1,
2217             "cookie": 1,
2218             "cookie_mask": 1,
2219             "table_id": 0,
2220             "idle_timeout": 30,
2221             "hard_timeout": 30,
2222             "priority": 11111,
2223             "flags": 1,
2224             "match":{
2225                 "in_port":1
2226             },
2227             "actions":[
2228                 {
2229                     "type":"OUTPUT",
2230                     "port": 2
2231                 }
2232             ]
2233          }' http://localhost:8080/stats/flowentry/delete
2234
2235
2236 Delete flow entry strictly
2237 --------------------------
2238
2239     Delete flow entry strictly matching wildcards and priority.
2240
2241     Usage:
2242
2243         ======= ===============================
2244         Method  POST
2245         URI     /stats/flowentry/delete_strict
2246         ======= ===============================
2247
2248     Request message body:
2249
2250         ============= ===================================================== ============================== ===============
2251         Attribute     Description                                           Example                        Default
2252         ============= ===================================================== ============================== ===============
2253         dpid          Datapath ID (int)                                     1                              (Mandatory)
2254         cookie        Opaque controller-issued identifier (int)             1                              0
2255         cookie_mask   Mask used to restrict the cookie bits (int)           1                              0
2256         table_id      Table ID to put the flow in (int)                     0                              0
2257         idle_timeout  Idle time before discarding (seconds) (int)           30                             0
2258         hard_timeout  Max time before discarding (seconds) (int)            30                             0
2259         priority      Priority level of flow entry (int)                    11111                          0
2260         buffer_id     Buffered packet to apply to, or OFP_NO_BUFFER (int)   1                              OFP_NO_BUFFER
2261         out_port      Output port (int)                                     1                              OFPP_ANY
2262         out_group     Output group (int)                                    1                              OFPG_ANY
2263         flags         Bitmap of OFPFF_* flags (int)                         1                              0
2264         match         Fields to match (dict)                                {"in_port":1}                  {} #wildcarded
2265         actions       Instruction set (list of dict)                        [{"type":"OUTPUT", "port":2}]  [] #DROP
2266         ============= ===================================================== ============================== ===============
2267
2268     Example of use::
2269
2270         $ curl -X POST -d '{
2271             "dpid": 1,
2272             "cookie": 1,
2273             "cookie_mask": 1,
2274             "table_id": 0,
2275             "idle_timeout": 30,
2276             "hard_timeout": 30,
2277             "priority": 11111,
2278             "flags": 1,
2279             "match":{
2280                 "in_port":1
2281             },
2282             "actions":[
2283                 {
2284                     "type":"OUTPUT",
2285                     "port": 2
2286                 }
2287             ]
2288          }' http://localhost:8080/stats/flowentry/delete_strict
2289
2290
2291 Delete all flow entries
2292 -----------------------
2293
2294     Delete all flow entries of the switch which specified with Datapath ID in URI.
2295
2296     Usage:
2297
2298         ======= ==============================
2299         Method  DELETE
2300         URI     /stats/flowentry/clear/<dpid>
2301         ======= ==============================
2302
2303     Example of use::
2304
2305         $ curl -X DELETE http://localhost:8080/stats/flowentry/clear/1
2306
2307
2308 Add a group entry
2309 -----------------
2310
2311     Add a group entry to the switch.
2312
2313     Usage:
2314
2315         ======= ======================
2316         Method  POST
2317         URI     /stats/groupentry/add
2318         ======= ======================
2319
2320     Request message body:
2321
2322         =============== ============================================================ ================================ ============
2323         Attribute       Description                                                  Example                          Default
2324         =============== ============================================================ ================================ ============
2325         dpid            Datapath ID (int)                                            1                                (Mandatory)
2326         type            One of OFPGT_* (string)                                      "ALL"                            "ALL"
2327         group_id        Group ID (int)                                               1                                0
2328         buckets         struct ofp_bucket
2329         -- weight       Relative weight of bucket                                    0                                0
2330                         (Only defined for select groups)
2331         -- watch_port   Port whose state affects whether this bucket is live         4294967295                       OFPP_ANY
2332                         (Only required for fast failover groups)
2333         -- watch_group  Group whose state affects whether this bucket is live        4294967295                       OFPG_ANY
2334                         (Only required for fast failover groups)
2335         -- actions      0 or more actions associated with the bucket (list of dict)  [{"type": "OUTPUT", "port": 1}]  [] #DROP
2336         =============== ============================================================ ================================ ============
2337
2338     Example of use::
2339
2340         $ curl -X POST -d '{
2341             "dpid": 1,
2342             "type": "ALL",
2343             "group_id": 1,
2344             "buckets": [
2345                 {
2346                     "actions": [
2347                         {
2348                             "type": "OUTPUT",
2349                             "port": 1
2350                         }
2351                     ]
2352                 }
2353             ]
2354          }' http://localhost:8080/stats/groupentry/add
2355
2356     .. NOTE::
2357
2358         To confirm group entry registration, please see :ref:`get-group-description-stats`.
2359
2360
2361 Modify a group entry
2362 --------------------
2363
2364     Modify a group entry to the switch.
2365
2366     Usage:
2367
2368         ======= =========================
2369         Method  POST
2370         URI     /stats/groupentry/modify
2371         ======= =========================
2372
2373     Request message body:
2374
2375         =============== ============================================================ ================================ ============
2376         Attribute       Description                                                  Example                          Default
2377         =============== ============================================================ ================================ ============
2378         dpid            Datapath ID (int)                                            1                                (Mandatory)
2379         type            One of OFPGT_* (string)                                      "ALL"                            "ALL"
2380         group_id        Group ID (int)                                               1                                0
2381         buckets         struct ofp_bucket
2382         -- weight       Relative weight of bucket                                    0                                0
2383                         (Only defined for select groups)
2384         -- watch_port   Port whose state affects whether this bucket is live         4294967295                       OFPP_ANY
2385                         (Only required for fast failover groups)
2386         -- watch_group  Group whose state affects whether this bucket is live        4294967295                       OFPG_ANY
2387                         (Only required for fast failover groups)
2388         -- actions      0 or more actions associated with the bucket (list of dict)  [{"type": "OUTPUT", "port": 1}]  [] #DROP
2389         =============== ============================================================ ================================ ============
2390
2391     Example of use::
2392
2393         $ curl -X POST -d '{
2394             "dpid": 1,
2395             "type": "ALL",
2396             "group_id": 1,
2397             "buckets": [
2398                 {
2399                     "actions": [
2400                         {
2401                             "type": "OUTPUT",
2402                             "port": 1
2403                         }
2404                     ]
2405                 }
2406             ]
2407          }' http://localhost:8080/stats/groupentry/modify
2408
2409
2410 Delete a group entry
2411 --------------------
2412
2413     Delete a group entry to the switch.
2414
2415     Usage:
2416
2417         ======= =========================
2418         Method  POST
2419         URI     /stats/groupentry/delete
2420         ======= =========================
2421
2422     Request message body:
2423
2424         =========== ======================== ======== ============
2425         Attribute   Description              Example  Default
2426         =========== ======================== ======== ============
2427         dpid        Datapath ID (int)        1        (Mandatory)
2428         group_id    Group ID (int)           1        0
2429         =========== ======================== ======== ============
2430
2431     Example of use::
2432
2433         $ curl -X POST -d '{
2434             "dpid": 1,
2435             "group_id": 1
2436          }' http://localhost:8080/stats/groupentry/delete
2437
2438
2439 Modify the behavior of the port
2440 -------------------------------
2441
2442     Modify the behavior of the physical port.
2443
2444     Usage:
2445
2446         ======= =======================
2447         Method  POST
2448         URI     /stats/portdesc/modify
2449         ======= =======================
2450
2451     Request message body:
2452
2453         =========== ============================================ ======== ============
2454         Attribute   Description                                  Example  Default
2455         =========== ============================================ ======== ============
2456         dpid        Datapath ID (int)                            1        (Mandatory)
2457         port_no     Port number (int)                            1        0
2458         config      Bitmap of OFPPC_* flags (int)                1        0
2459         mask        Bitmap of OFPPC_* flags to be changed (int)  1        0
2460         =========== ============================================ ======== ============
2461
2462     Example of use::
2463
2464         $ curl -X POST -d '{
2465             "dpid": 1,
2466             "port_no": 1,
2467             "config": 1,
2468             "mask": 1
2469             }' http://localhost:8080/stats/portdesc/modify
2470
2471     .. NOTE::
2472
2473         To confirm port description, please see :ref:`get-ports-description`.
2474
2475
2476 Add a meter entry
2477 -----------------
2478
2479     Add a meter entry to the switch.
2480
2481     Usage:
2482
2483         ======= ======================
2484         Method  POST
2485         URI     /stats/meterentry/add
2486         ======= ======================
2487
2488     Request message body:
2489
2490         ============== =============================== ========= ============
2491         Attribute      Description                     Example   Default
2492         ============== =============================== ========= ============
2493         dpid           Datapath ID (int)               1         (Mandatory)
2494         flags          Bitmap of OFPMF_* flags (list)  ["KBPS"]  [] #Empty
2495         meter_id       Meter ID (int)                  1         0
2496         bands          struct ofp_meter_band_header
2497         -- type        One of OFPMBT_* (string)        "DROP"    None
2498         -- rate        Rate for this band (int)        1000      None
2499         -- burst_size  Size of bursts (int)            100       None
2500         ============== =============================== ========= ============
2501
2502     Example of use::
2503
2504         $ curl -X POST -d '{
2505             "dpid": 1,
2506             "flags": "KBPS",
2507             "meter_id": 1,
2508             "bands": [
2509                 {
2510                     "type": "DROP",
2511                     "rate": 1000
2512                 }
2513             ]
2514          }' http://localhost:8080/stats/meterentry/add
2515
2516     .. NOTE::
2517
2518         To confirm meter entry registration, please see :ref:`get-meter-config-stats`.
2519
2520
2521 Modify a meter entry
2522 --------------------
2523
2524     Modify a meter entry to the switch.
2525
2526     Usage:
2527
2528         ======= =========================
2529         Method  POST
2530         URI     /stats/meterentry/modify
2531         ======= =========================
2532
2533     Request message body:
2534
2535         ============== =============================== ========= ============
2536         Attribute      Description                     Example   Default
2537         ============== =============================== ========= ============
2538         dpid           Datapath ID (int)               1         (Mandatory)
2539         flags          Bitmap of OFPMF_* flags (list)  ["KBPS"]  [] #Empty
2540         meter_id       Meter ID (int)                  1         0
2541         bands          struct ofp_meter_band_header
2542         -- type        One of OFPMBT_* (string)        "DROP"    None
2543         -- rate        Rate for this band (int)        1000      None
2544         -- burst_size  Size of bursts (int)            100       None
2545         ============== =============================== ========= ============
2546
2547     Example of use::
2548
2549         $ curl -X POST -d '{
2550             "dpid": 1,
2551             "meter_id": 1,
2552             "flags": "KBPS",
2553             "bands": [
2554                 {
2555                     "type": "DROP",
2556                     "rate": 1000
2557                 }
2558             ]
2559          }' http://localhost:8080/stats/meterentry/modify
2560
2561
2562 Delete a meter entry
2563 --------------------
2564
2565     Delete a meter entry to the switch.
2566
2567     Usage:
2568
2569         ======= =========================
2570         Method  POST
2571         URI     /stats/meterentry/delete
2572         ======= =========================
2573
2574     Request message body:
2575
2576         =========== ================== ========= ============
2577         Attribute   Description        Example   Default
2578         =========== ================== ========= ============
2579         dpid        Datapath ID (int)  1         (Mandatory)
2580         meter_id    Meter ID (int)     1         0
2581         =========== ================== ========= ============
2582
2583     Example of use::
2584
2585         $ curl -X POST -d '{
2586             "dpid": 1,
2587             "meter_id": 1
2588          }' http://localhost:8080/stats/meterentry/delete
2589
2590 Modify role
2591 --------------------
2592
2593     modify the role of the switch.
2594
2595     Usage:
2596
2597         ======= =========================
2598         Method  POST
2599         URI     /stats/role
2600         ======= =========================
2601
2602     Request message body:
2603
2604         =========== ============================ ========= =================
2605         Attribute   Description                  Example   Default
2606         =========== ============================ ========= =================
2607         dpid        Datapath ID (int)            1         (Mandatory)
2608         role        One of OFPCR_ROLE_*(string)  "MASTER"  OFPCR_ROLE_EQUAL
2609         =========== ============================ ========= =================
2610
2611     Example of use::
2612
2613         $ curl -X POST -d '{
2614             "dpid": 1,
2615             "role": "MASTER"
2616          }' http://localhost:8080/stats/role
2617
2618 Support for experimenter multipart
2619 ==================================
2620
2621 Send a experimenter message
2622 ---------------------------
2623
2624     Send a experimenter message to the switch which specified with Datapath ID in URI.
2625
2626
2627     Usage:
2628
2629         ======= ===========================
2630         Method  POST
2631         URI     /stats/experimenter/<dpid>
2632         ======= ===========================
2633
2634     Request message body:
2635
2636         ============= ============================================ ======== ============
2637         Attribute     Description                                  Example  Default
2638         ============= ============================================ ======== ============
2639         dpid          Datapath ID (int)                            1        (Mandatory)
2640         experimenter  Experimenter ID (int)                        1        0
2641         exp_type      Experimenter defined (int)                   1        0
2642         data_type     Data format type ("ascii" or "base64")       "ascii"  "ascii"
2643         data          Data to send (string)                        "data"   "" #Empty
2644         ============= ============================================ ======== ============
2645
2646     Example of use::
2647
2648         $ curl -X POST -d '{
2649             "dpid": 1,
2650             "experimenter": 1,
2651             "exp_type": 1,
2652             "data_type": "ascii",
2653             "data": "data"
2654             }' http://localhost:8080/stats/experimenter/1
2655
2656
2657 .. _description-of-match-and-actions:
2658
2659 Reference: Description of Match and Actions
2660 ===========================================
2661
2662 Description of Match on request messages
2663 ----------------------------------------
2664
2665     List of Match fields (OpenFlow1.0):
2666
2667         =============== ================================================ ==============================================
2668         Match field     Description                                      Example
2669         =============== ================================================ ==============================================
2670         in_port         Input switch port (int)                          {"in_port": 7}
2671         dl_src          Ethernet source address (string)                 {"dl_src": "aa:bb:cc:11:22:33"}
2672         dl_dst          Ethernet destination address (string)            {"dl_dst": "aa:bb:cc:11:22:33"}
2673         dl_vlan         Input VLAN id (int)                              {"dl_vlan": 5}
2674         dl_vlan_pcp     Input VLAN priority (int)                        {"dl_vlan_pcp": 3, "dl_vlan": 3}
2675         dl_type         Ethernet frame type (int)                        {"dl_type": 123}
2676         nw_tos          IP ToS (int)                                     {"nw_tos": 16, "dl_type": 2048}
2677         nw_proto        IP protocol or lower 8 bits of ARP opcode (int)  {"nw_proto": 5, "dl_type": 2048}
2678         nw_src          IPv4 source address (string)                     {"nw_src": "192.168.0.1", "dl_type": 2048}
2679         nw_dst          IPv4 destination address (string)                {"nw_dst": "192.168.0.1/24", "dl_type": 2048}
2680         tp_src          TCP/UDP source port (int)                        {"tp_src": 1, "nw_proto": 6, "dl_type": 2048}
2681         tp_dst          TCP/UDP destination port (int)                   {"tp_dst": 2, "nw_proto": 6, "dl_type": 2048}
2682         =============== ================================================ ==============================================
2683
2684     .. NOTE::
2685
2686         IPv4 address field can be described as IP Prefix like as follows.
2687
2688         IPv4 address::
2689
2690             "192.168.0.1"
2691             "192.168.0.2/24"
2692
2693     List of Match fields (OpenFlow1.2 or later):
2694
2695         =============== ================================================== =======================================================================================================
2696         Match field     Description                                        Example
2697         =============== ================================================== =======================================================================================================
2698         in_port         Switch input port (int)                            {"in_port": 7}
2699         in_phy_port     Switch physical input port (int)                   {"in_phy_port": 5, "in_port": 3}
2700         metadata        Metadata passed between tables (int or string)     {"metadata": 12345} or {"metadata": "0x1212/0xffff"}
2701         eth_dst         Ethernet destination address (string)              {"eth_dst": "aa:bb:cc:11:22:33/00:00:00:00:ff:ff"}
2702         eth_src         Ethernet source address (string)                   {"eth_src": "aa:bb:cc:11:22:33"}
2703         eth_type        Ethernet frame type (int)                          {"eth_type": 2048}
2704         vlan_vid        VLAN id (int or string)                            See :ref:`example-of-vlan-id-match-field`
2705         vlan_pcp        VLAN priority (int)                                {"vlan_pcp": 3, "vlan_vid": 3}
2706         ip_dscp         IP DSCP (6 bits in ToS field) (int)                {"ip_dscp": 3, "eth_type": 2048}
2707         ip_ecn          IP ECN (2 bits in ToS field) (int)                 {"ip_ecn": 0, "eth_type": 34525}
2708         ip_proto        IP protocol (int)                                  {"ip_proto": 5, "eth_type": 34525}
2709         ipv4_src        IPv4 source address (string)                       {"ipv4_src": "192.168.0.1", "eth_type": 2048}
2710         ipv4_dst        IPv4 destination address (string)                  {"ipv4_dst": "192.168.10.10/255.255.255.0", "eth_type": 2048}
2711         tcp_src         TCP source port (int)                              {"tcp_src": 3, "ip_proto": 6, "eth_type": 2048}
2712         tcp_dst         TCP destination port (int)                         {"tcp_dst": 5, "ip_proto": 6, "eth_type": 2048}
2713         udp_src         UDP source port (int)                              {"udp_src": 2, "ip_proto": 17, "eth_type": 2048}
2714         udp_dst         UDP destination port (int)                         {"udp_dst": 6, "ip_proto": 17, "eth_type": 2048}
2715         sctp_src        SCTP source port (int)                             {"sctp_src": 99, "ip_proto": 132, "eth_type": 2048}
2716         sctp_dst        SCTP destination port (int)                        {"sctp_dst": 99, "ip_proto": 132, "eth_type": 2048}
2717         icmpv4_type     ICMP type (int)                                    {"icmpv4_type": 5, "ip_proto": 1, "eth_type": 2048}
2718         icmpv4_code     ICMP code (int)                                    {"icmpv4_code": 6, "ip_proto": 1, "eth_type": 2048}
2719         arp_op          ARP opcode (int)                                   {"arp_op": 3, "eth_type": 2054}
2720         arp_spa         ARP source IPv4 address (string)                   {"arp_spa": "192.168.0.11", "eth_type": 2054}
2721         arp_tpa         ARP target IPv4 address (string)                   {"arp_tpa": "192.168.0.44/24", "eth_type": 2054}
2722         arp_sha         ARP source hardware address (string)               {"arp_sha": "aa:bb:cc:11:22:33", "eth_type": 2054}
2723         arp_tha         ARP target hardware address (string)               {"arp_tha": "aa:bb:cc:11:22:33/00:00:00:00:ff:ff", "eth_type": 2054}
2724         ipv6_src        IPv6 source address (string)                       {"ipv6_src": "2001::aaaa:bbbb:cccc:1111", "eth_type": 34525}
2725         ipv6_dst        IPv6 destination address (string)                  {"ipv6_dst": "2001::ffff:cccc:bbbb:1111/64", "eth_type": 34525}
2726         ipv6_flabel     IPv6 Flow Label (int)                              {"ipv6_flabel": 2, "eth_type": 34525}
2727         icmpv6_type     ICMPv6 type (int)                                  {"icmpv6_type": 3, "ip_proto": 58, "eth_type": 34525}
2728         icmpv6_code     ICMPv6 code (int)                                  {"icmpv6_code": 4, "ip_proto": 58, "eth_type": 34525}
2729         ipv6_nd_target  Target address for Neighbor Discovery (string)     {"ipv6_nd_target": "2001::ffff:cccc:bbbb:1111", "icmpv6_type": 135, "ip_proto": 58, "eth_type": 34525}
2730         ipv6_nd_sll     Source link-layer for Neighbor Discovery (string)  {"ipv6_nd_sll": "aa:bb:cc:11:22:33", "icmpv6_type": 135, "ip_proto": 58, "eth_type": 34525}
2731         ipv6_nd_tll     Target link-layer for Neighbor Discovery (string)  {"ipv6_nd_tll": "aa:bb:cc:11:22:33", "icmpv6_type": 136, "ip_proto": 58, "eth_type": 34525}
2732         mpls_label      MPLS label (int)                                   {"mpls_label": 3, "eth_type": 34888}
2733         mpls_tc         MPLS Traffic Class (int)                           {"mpls_tc": 2, "eth_type": 34888}
2734         mpls_bos        MPLS BoS bit (int)                                 {"mpls_bos": 1, "eth_type": 34888}
2735                         (Openflow1.3+)
2736         pbb_isid        PBB I-SID (int or string)                          {"pbb_isid": 5, "eth_type": 35047} or{"pbb_isid": "0x05/0xff", "eth_type": 35047}
2737                         (Openflow1.3+)
2738         tunnel_id       Logical Port Metadata (int or string)              {"tunnel_id": 7} or {"tunnel_id": "0x07/0xff"}
2739                         (Openflow1.3+)
2740         ipv6_exthdr     IPv6 Extension Header pseudo-field (int or string) {"ipv6_exthdr": 3, "eth_type": 34525} or {"ipv6_exthdr": "0x40/0x1F0", "eth_type": 34525}
2741                         (Openflow1.3+)
2742         pbb_uca         PBB UCA hander field(int)                          {"pbb_uca": 1, "eth_type": 35047}
2743                         (Openflow1.4+)
2744         tcp_flags       TCP flags(int)                                     {"tcp_flags": 2, "ip_proto": 6, "eth_type": 2048}
2745                         (Openflow1.5+)
2746         actset_output   Output port from action set metadata(int)          {"actset_output": 3}
2747                         (Openflow1.5+)
2748         packet_type     Packet type value(int)                             {"packet_type": [1, 2048]}
2749                         (Openflow1.5+)
2750         =============== ================================================== =======================================================================================================
2751
2752     .. NOTE::
2753
2754         Some field can be described with mask like as follows.
2755
2756         Ethernet address::
2757
2758             "aa:bb:cc:11:22:33"
2759             "aa:bb:cc:11:22:33/00:00:00:00:ff:ff"
2760
2761         IPv4 address::
2762
2763             "192.168.0.11"
2764             "192.168.0.44/24"
2765             "192.168.10.10/255.255.255.0"
2766
2767         IPv6 address::
2768
2769             "2001::ffff:cccc:bbbb:1111"
2770             "2001::ffff:cccc:bbbb:2222/64"
2771             "2001::ffff:cccc:bbbb:2222/ffff:ffff:ffff:ffff::0"
2772
2773         Metadata::
2774
2775             "0x1212121212121212"
2776             "0x3434343434343434/0x01010101010101010"
2777
2778
2779 .. _example-of-vlan-id-match-field:
2780
2781 Example of VLAN ID match field
2782 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2783
2784     The following is available in OpenFlow1.0 or later.
2785
2786     - To match only packets with VLAN tag and VLAN ID equal value 5::
2787
2788         $ curl -X POST -d '{
2789             "dpid": 1,
2790             "match":{
2791                 "dl_vlan": 5
2792             },
2793             "actions":[
2794                 {
2795                     "type":"OUTPUT",
2796                     "port": 1
2797                 }
2798             ]
2799          }' http://localhost:8080/stats/flowentry/add
2800
2801     .. NOTE::
2802         When "dl_vlan" field is described as decimal int value, OFPVID_PRESENT(0x1000) bit is automatically applied.
2803
2804     The following is available in OpenFlow1.2 or later.
2805
2806     - To match only packets without a VLAN tag::
2807
2808         $ curl -X POST -d '{
2809             "dpid": 1,
2810             "match":{
2811                 "dl_vlan": "0x0000"   # Describe OFPVID_NONE(0x0000)
2812             },
2813             "actions":[
2814                 {
2815                     "type":"OUTPUT",
2816                     "port": 1
2817                 }
2818             ]
2819          }' http://localhost:8080/stats/flowentry/add
2820
2821     - To match only packets with a VLAN tag regardless of its value::
2822
2823         $ curl -X POST -d '{
2824             "dpid": 1,
2825             "match":{
2826                 "dl_vlan": "0x1000/0x1000"   # Describe OFPVID_PRESENT(0x1000/0x1000)
2827             },
2828             "actions":[
2829                 {
2830                     "type":"OUTPUT",
2831                     "port": 1
2832                 }
2833             ]
2834          }' http://localhost:8080/stats/flowentry/add
2835
2836     - To match only packets with VLAN tag and VLAN ID equal value 5::
2837
2838         $ curl -X POST -d '{
2839             "dpid": 1,
2840             "match":{
2841                 "dl_vlan": "0x1005"   # Describe sum of VLAN-ID(e.g. 5) | OFPVID_PRESENT(0x1000)
2842             },
2843             "actions":[
2844                 {
2845                     "type":"OUTPUT",
2846                     "port": 1
2847                 }
2848             ]
2849          }' http://localhost:8080/stats/flowentry/add
2850
2851     .. NOTE::
2852         When using the descriptions for OpenFlow1.2 or later, please describe "dl_vlan" field as hexadecimal string value,
2853         and OFPVID_PRESENT(0x1000) bit is NOT automatically applied.
2854
2855
2856
2857 Description of Actions on request messages
2858 ------------------------------------------
2859
2860     List of Actions (OpenFlow1.0):
2861
2862         =============== ============================================================================ ======================================================
2863         Actions         Description                                                                  Example
2864         =============== ============================================================================ ======================================================
2865         OUTPUT          Output packet from "port"                                                    {"type": "OUTPUT", "port": 3}
2866         SET_VLAN_VID    Set the 802.1Q VLAN ID using "vlan_vid"                                      {"type": "SET_VLAN_VID", "vlan_vid": 5}
2867         SET_VLAN_PCP    Set the 802.1Q priority using "vlan_pcp"                                     {"type": "SET_VLAN_PCP", "vlan_pcp": 3}
2868         STRIP_VLAN      Strip the 802.1Q header                                                      {"type": "STRIP_VLAN"}
2869         SET_DL_SRC      Set ethernet source address using "dl_src"                                   {"type": "SET_DL_SRC", "dl_src": "aa:bb:cc:11:22:33"}
2870         SET_DL_DST      Set ethernet destination address using "dl_dst"                              {"type": "SET_DL_DST", "dl_dst": "aa:bb:cc:11:22:33"}
2871         SET_NW_SRC      IP source address using "nw_src"                                             {"type": "SET_NW_SRC", "nw_src": "10.0.0.1"}
2872         SET_NW_DST      IP destination address using "nw_dst"                                        {"type": "SET_NW_DST", "nw_dst": "10.0.0.1"}
2873         SET_NW_TOS      Set IP ToS (DSCP field, 6 bits) using "nw_tos"                               {"type": "SET_NW_TOS", "nw_tos": 184}
2874         SET_TP_SRC      Set TCP/UDP source port using "tp_src"                                       {"type": "SET_TP_SRC", "tp_src": 8080}
2875         SET_TP_DST      Set TCP/UDP destination port using "tp_dst"                                  {"type": "SET_TP_DST", "tp_dst": 8080}
2876         ENQUEUE         Output to queue with "queue_id" attached to "port"                           {"type": "ENQUEUE", "queue_id": 3, "port": 1}
2877         =============== ============================================================================ ======================================================
2878
2879     List of Actions (OpenFlow1.2 or later):
2880
2881         =============== ============================================================================ ========================================================================================================================
2882         Actions         Description                                                                  Example
2883         =============== ============================================================================ ========================================================================================================================
2884         OUTPUT          Output packet from "port"                                                    {"type": "OUTPUT", "port": 3}
2885         COPY_TTL_OUT    Copy TTL outwards                                                            {"type": "COPY_TTL_OUT"}
2886         COPY_TTL_IN     Copy TTL inwards                                                             {"type": "COPY_TTL_IN"}
2887         SET_MPLS_TTL    Set MPLS TTL using "mpls_ttl"                                                {"type": "SET_MPLS_TTL", "mpls_ttl": 64}
2888         DEC_MPLS_TTL    Decrement MPLS TTL                                                           {"type": "DEC_MPLS_TTL"}
2889         PUSH_VLAN       Push a new VLAN tag with "ethertype"                                         {"type": "PUSH_VLAN", "ethertype": 33024}
2890         POP_VLAN        Pop the outer VLAN tag                                                       {"type": "POP_VLAN"}
2891         PUSH_MPLS       Push a new MPLS tag with "ethertype"                                         {"type": "PUSH_MPLS", "ethertype": 34887}
2892         POP_MPLS        Pop the outer MPLS tag with "ethertype"                                      {"type": "POP_MPLS", "ethertype": 2054}
2893         SET_QUEUE       Set queue id using "queue_id" when outputting to a port                      {"type": "SET_QUEUE", "queue_id": 7}
2894         GROUP           Apply group identified by "group_id"                                         {"type": "GROUP", "group_id": 5}
2895         SET_NW_TTL      Set IP TTL using "nw_ttl"                                                    {"type": "SET_NW_TTL", "nw_ttl": 64}
2896         DEC_NW_TTL      Decrement IP TTL                                                             {"type": "DEC_NW_TTL"}
2897         SET_FIELD       Set a "field" using "value"                                                  See :ref:`example-of-set-field-action`
2898                         (The set of keywords available for "field" is the same as match field)
2899         PUSH_PBB        Push a new PBB service tag with "ethertype"                                  {"type": "PUSH_PBB", "ethertype": 35047}
2900                         (Openflow1.3+)
2901         POP_PBB         Pop the outer PBB service tag                                                {"type": "POP_PBB"}
2902                         (Openflow1.3+)
2903         COPY_FIELD      Copy value between header and register                                       {"type": "COPY_FIELD", "n_bits": 32, "src_offset": 1, "dst_offset": 2, "src_oxm_id": "eth_src", "dst_oxm_id": "eth_dst"}
2904                         (Openflow1.5+)
2905         METER           Apply meter identified by "meter_id"                                         {"type": "METER", "meter_id": 3}
2906                         (Openflow1.5+)
2907         EXPERIMENTER    Extensible action for the experimenter                                       {"type": "EXPERIMENTER", "experimenter": 101, "data": "AAECAwQFBgc=", "data_type": "base64"}
2908                         (Set "base64" or "ascii" to "data_type" field)
2909         GOTO_TABLE      (Instruction) Setup the next table identified by "table_id"                  {"type": "GOTO_TABLE", "table_id": 8}
2910         WRITE_METADATA  (Instruction) Setup the metadata field using "metadata" and "metadata_mask"  {"type": "WRITE_METADATA", "metadata": 0x3, "metadata_mask": 0x3}
2911         METER           (Instruction) Apply meter identified by "meter_id"                           {"type": "METER", "meter_id": 3}
2912                         (deprecated in Openflow1.5)
2913         WRITE_ACTIONS   (Instruction) Write the action(s) onto the datapath action set               {"type": "WRITE_ACTIONS", actions":[{"type":"POP_VLAN",},{ "type":"OUTPUT", "port": 2}]}
2914         CLEAR_ACTIONS   (Instruction) Clears all actions from the datapath action set                {"type": "CLEAR_ACTIONS"}
2915         =============== ============================================================================ ========================================================================================================================
2916
2917
2918
2919 .. _example-of-set-field-action:
2920
2921 Example of set-field action
2922 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2923
2924     To set VLAN ID to non-VLAN-tagged frame::
2925
2926         $ curl -X POST -d '{
2927             "dpid": 1,
2928             "match":{
2929                 "dl_type": "0x8000"
2930             },
2931             "actions":[
2932                 {
2933                     "type": "PUSH_VLAN",     # Push a new VLAN tag if a input frame is non-VLAN-tagged
2934                     "ethertype": 33024       # Ethertype 0x8100(=33024): IEEE 802.1Q VLAN-tagged frame
2935                 },
2936                 {
2937                     "type": "SET_FIELD",
2938                     "field": "vlan_vid",     # Set VLAN ID
2939                     "value": 4102            # Describe sum of vlan_id(e.g. 6) | OFPVID_PRESENT(0x1000=4096)
2940                 },
2941                 {
2942                     "type": "OUTPUT",
2943                     "port": 2
2944                 }
2945             ]
2946          }' http://localhost:8080/stats/flowentry/add
2947