2 * Copyright (c) 2008, 2009, 2010 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
29 #include "command-line.h"
35 #include "ofp-parse.h"
36 #include "ofp-print.h"
39 #include "openflow/nicira-ext.h"
40 #include "openflow/openflow.h"
42 #include "stream-ssl.h"
49 VLOG_DEFINE_THIS_MODULE(ofctl)
52 #define MOD_PORT_CMD_UP "up"
53 #define MOD_PORT_CMD_DOWN "down"
54 #define MOD_PORT_CMD_FLOOD "flood"
55 #define MOD_PORT_CMD_NOFLOOD "noflood"
57 /* Use strict matching for flow mod commands? */
60 static const struct command all_commands[];
62 static void usage(void) NO_RETURN;
63 static void parse_options(int argc, char *argv[]);
66 main(int argc, char *argv[])
68 set_program_name(argv[0]);
69 parse_options(argc, argv);
70 signal(SIGPIPE, SIG_IGN);
71 run_command(argc - optind, argv + optind, all_commands);
76 parse_options(int argc, char *argv[])
79 OPT_STRICT = UCHAR_MAX + 1,
82 static struct option long_options[] = {
83 {"timeout", required_argument, 0, 't'},
84 {"strict", no_argument, 0, OPT_STRICT},
85 {"help", no_argument, 0, 'h'},
86 {"version", no_argument, 0, 'V'},
88 STREAM_SSL_LONG_OPTIONS
91 char *short_options = long_options_to_short_options(long_options);
94 unsigned long int timeout;
97 c = getopt_long(argc, argv, short_options, long_options, NULL);
104 timeout = strtoul(optarg, NULL, 10);
106 ovs_fatal(0, "value %s on -t or --timeout is not at least 1",
117 OVS_PRINT_VERSION(OFP_VERSION, OFP_VERSION);
125 STREAM_SSL_OPTION_HANDLERS
140 printf("%s: OpenFlow switch management utility\n"
141 "usage: %s [OPTIONS] COMMAND [ARG...]\n"
142 "\nFor OpenFlow switches:\n"
143 " show SWITCH show OpenFlow information\n"
144 " status SWITCH [KEY] report statistics (about KEY)\n"
145 " dump-desc SWITCH print switch description\n"
146 " dump-tables SWITCH print table stats\n"
147 " mod-port SWITCH IFACE ACT modify port behavior\n"
148 " dump-ports SWITCH [PORT] print port statistics\n"
149 " dump-flows SWITCH print all flow entries\n"
150 " dump-flows SWITCH FLOW print matching FLOWs\n"
151 " dump-aggregate SWITCH print aggregate flow statistics\n"
152 " dump-aggregate SWITCH FLOW print aggregate stats for FLOWs\n"
153 " add-flow SWITCH FLOW add flow described by FLOW\n"
154 " add-flows SWITCH FILE add flows from FILE\n"
155 " mod-flows SWITCH FLOW modify actions of matching FLOWs\n"
156 " del-flows SWITCH [FLOW] delete matching FLOWs\n"
157 " monitor SWITCH [MISSLEN] print packets received from SWITCH\n"
158 "\nFor OpenFlow switches and controllers:\n"
159 " probe VCONN probe whether VCONN is up\n"
160 " ping VCONN [N] latency of N-byte echos\n"
161 " benchmark VCONN N COUNT bandwidth of COUNT N-byte echos\n"
162 "where each SWITCH is an active OpenFlow connection method.\n",
163 program_name, program_name);
164 vconn_usage(true, false, false);
166 printf("\nOther options:\n"
167 " --strict use strict match for flow commands\n"
168 " -t, --timeout=SECS give up after SECS seconds\n"
169 " -h, --help display this help message\n"
170 " -V, --version display version information\n");
174 static void run(int retval, const char *message, ...)
177 static void run(int retval, const char *message, ...)
182 fprintf(stderr, "%s: ", program_name);
183 va_start(args, message);
184 vfprintf(stderr, message, args);
187 fputs(": unexpected end of file\n", stderr);
189 fprintf(stderr, ": %s\n", strerror(retval));
196 /* Generic commands. */
199 open_vconn_socket(const char *name, struct vconn **vconnp)
201 char *vconn_name = xasprintf("unix:%s", name);
202 VLOG_INFO("connecting to %s", vconn_name);
203 run(vconn_open_block(vconn_name, OFP_VERSION, vconnp),
204 "connecting to %s", vconn_name);
209 open_vconn__(const char *name, const char *default_suffix,
210 struct vconn **vconnp)
214 char *bridge_path, *datapath_name, *datapath_type;
216 bridge_path = xasprintf("%s/%s.%s", ovs_rundir, name, default_suffix);
217 dp_parse_name(name, &datapath_name, &datapath_type);
219 if (strstr(name, ":")) {
220 run(vconn_open_block(name, OFP_VERSION, vconnp),
221 "connecting to %s", name);
222 } else if (!stat(name, &s) && S_ISSOCK(s.st_mode)) {
223 open_vconn_socket(name, vconnp);
224 } else if (!stat(bridge_path, &s) && S_ISSOCK(s.st_mode)) {
225 open_vconn_socket(bridge_path, vconnp);
226 } else if (!dpif_open(datapath_name, datapath_type, &dpif)) {
227 char dpif_name[IF_NAMESIZE + 1];
230 run(dpif_port_get_name(dpif, ODPP_LOCAL, dpif_name, sizeof dpif_name),
231 "obtaining name of %s", dpif_name);
233 if (strcmp(dpif_name, name)) {
234 VLOG_INFO("datapath %s is named %s", name, dpif_name);
237 socket_name = xasprintf("%s/%s.%s",
238 ovs_rundir, dpif_name, default_suffix);
239 if (stat(socket_name, &s)) {
240 ovs_fatal(errno, "cannot connect to %s: stat failed on %s",
242 } else if (!S_ISSOCK(s.st_mode)) {
243 ovs_fatal(0, "cannot connect to %s: %s is not a socket",
247 open_vconn_socket(socket_name, vconnp);
250 ovs_fatal(0, "%s is not a valid connection method", name);
259 open_vconn(const char *name, struct vconn **vconnp)
261 return open_vconn__(name, "mgmt", vconnp);
265 alloc_stats_request(size_t body_len, uint16_t type, struct ofpbuf **bufferp)
267 struct ofp_stats_request *rq;
268 rq = make_openflow((offsetof(struct ofp_stats_request, body)
269 + body_len), OFPT_STATS_REQUEST, bufferp);
270 rq->type = htons(type);
271 rq->flags = htons(0);
276 send_openflow_buffer(struct vconn *vconn, struct ofpbuf *buffer)
278 update_openflow_length(buffer);
279 run(vconn_send_block(vconn, buffer), "failed to send packet to switch");
283 dump_transaction(const char *vconn_name, struct ofpbuf *request)
286 struct ofpbuf *reply;
288 update_openflow_length(request);
289 open_vconn(vconn_name, &vconn);
290 run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
291 ofp_print(stdout, reply->data, reply->size, 1);
296 dump_trivial_transaction(const char *vconn_name, uint8_t request_type)
298 struct ofpbuf *request;
299 make_openflow(sizeof(struct ofp_header), request_type, &request);
300 dump_transaction(vconn_name, request);
304 dump_stats_transaction(const char *vconn_name, struct ofpbuf *request)
306 uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
310 open_vconn(vconn_name, &vconn);
311 send_openflow_buffer(vconn, request);
314 struct ofpbuf *reply;
316 run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
317 recv_xid = ((struct ofp_header *) reply->data)->xid;
318 if (send_xid == recv_xid) {
319 struct ofp_stats_reply *osr;
321 ofp_print(stdout, reply->data, reply->size, 1);
323 osr = ofpbuf_at(reply, 0, sizeof *osr);
324 done = !osr || !(ntohs(osr->flags) & OFPSF_REPLY_MORE);
326 VLOG_DBG("received reply with xid %08"PRIx32" "
327 "!= expected %08"PRIx32, recv_xid, send_xid);
329 ofpbuf_delete(reply);
335 dump_trivial_stats_transaction(const char *vconn_name, uint8_t stats_type)
337 struct ofpbuf *request;
338 alloc_stats_request(0, stats_type, &request);
339 dump_stats_transaction(vconn_name, request);
343 do_show(int argc OVS_UNUSED, char *argv[])
345 dump_trivial_transaction(argv[1], OFPT_FEATURES_REQUEST);
346 dump_trivial_transaction(argv[1], OFPT_GET_CONFIG_REQUEST);
350 do_status(int argc, char *argv[])
352 struct nicira_header *request, *reply;
356 request = make_openflow(sizeof *request, OFPT_VENDOR, &b);
357 request->vendor = htonl(NX_VENDOR_ID);
358 request->subtype = htonl(NXT_STATUS_REQUEST);
360 ofpbuf_put(b, argv[2], strlen(argv[2]));
361 update_openflow_length(b);
363 open_vconn(argv[1], &vconn);
364 run(vconn_transact(vconn, b, &b), "talking to %s", argv[1]);
367 if (b->size < sizeof *reply) {
368 ovs_fatal(0, "short reply (%zu bytes)", b->size);
371 if (reply->header.type != OFPT_VENDOR
372 || reply->vendor != ntohl(NX_VENDOR_ID)
373 || reply->subtype != ntohl(NXT_STATUS_REPLY)) {
374 ofp_print(stderr, b->data, b->size, 2);
375 ovs_fatal(0, "bad reply");
378 fwrite(reply + 1, b->size - sizeof *reply, 1, stdout);
382 do_dump_desc(int argc OVS_UNUSED, char *argv[])
384 dump_trivial_stats_transaction(argv[1], OFPST_DESC);
388 do_dump_tables(int argc OVS_UNUSED, char *argv[])
390 dump_trivial_stats_transaction(argv[1], OFPST_TABLE);
394 str_to_port_no(const char *vconn_name, const char *str)
396 struct ofpbuf *request, *reply;
397 struct ofp_switch_features *osf;
401 unsigned int port_no;
404 /* Check if the argument is a port index. Otherwise, treat it as
406 if (str_to_uint(str, 10, &port_no)) {
410 /* Send a "Features Request" to resolve the name into a number. */
411 make_openflow(sizeof(struct ofp_header), OFPT_FEATURES_REQUEST, &request);
412 open_vconn(vconn_name, &vconn);
413 run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
416 n_ports = (reply->size - sizeof *osf) / sizeof *osf->ports;
418 for (port_idx = 0; port_idx < n_ports; port_idx++) {
419 /* Check argument as an interface name */
420 if (!strncmp((char *)osf->ports[port_idx].name, str,
421 sizeof osf->ports[0].name)) {
425 if (port_idx == n_ports) {
426 ovs_fatal(0, "couldn't find monitored port: %s", str);
429 ofpbuf_delete(reply);
436 do_dump_flows(int argc, char *argv[])
438 struct ofp_flow_stats_request *req;
440 struct ofpbuf *request;
442 req = alloc_stats_request(sizeof *req, OFPST_FLOW, &request);
443 parse_ofp_str(argc > 2 ? argv[2] : "", &req->match, NULL,
444 &req->table_id, &out_port, NULL, NULL, NULL, NULL);
445 memset(&req->pad, 0, sizeof req->pad);
446 req->out_port = htons(out_port);
448 dump_stats_transaction(argv[1], request);
452 do_dump_aggregate(int argc, char *argv[])
454 struct ofp_aggregate_stats_request *req;
455 struct ofpbuf *request;
458 req = alloc_stats_request(sizeof *req, OFPST_AGGREGATE, &request);
459 parse_ofp_str(argc > 2 ? argv[2] : "", &req->match, NULL,
460 &req->table_id, &out_port, NULL, NULL, NULL, NULL);
461 memset(&req->pad, 0, sizeof req->pad);
462 req->out_port = htons(out_port);
464 dump_stats_transaction(argv[1], request);
468 do_add_flow(int argc OVS_UNUSED, char *argv[])
471 struct ofpbuf *buffer;
472 struct ofp_flow_mod *ofm;
473 uint16_t priority, idle_timeout, hard_timeout;
475 struct ofp_match match;
477 /* Parse and send. parse_ofp_str() will expand and reallocate the
478 * data in 'buffer', so we can't keep pointers to across the
479 * parse_ofp_str() call. */
480 make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
481 parse_ofp_str(argv[2], &match, buffer,
482 NULL, NULL, &priority, &idle_timeout, &hard_timeout,
486 ofm->command = htons(OFPFC_ADD);
487 ofm->cookie = htonll(cookie);
488 ofm->idle_timeout = htons(idle_timeout);
489 ofm->hard_timeout = htons(hard_timeout);
490 ofm->buffer_id = htonl(UINT32_MAX);
491 ofm->priority = htons(priority);
493 open_vconn(argv[1], &vconn);
494 send_openflow_buffer(vconn, buffer);
499 do_add_flows(int argc OVS_UNUSED, char *argv[])
505 file = fopen(argv[2], "r");
507 ovs_fatal(errno, "%s: open", argv[2]);
510 open_vconn(argv[1], &vconn);
511 while (fgets(line, sizeof line, file)) {
512 struct ofpbuf *buffer;
513 struct ofp_flow_mod *ofm;
514 uint16_t priority, idle_timeout, hard_timeout;
516 struct ofp_match match;
520 /* Delete comments. */
521 comment = strchr(line, '#');
526 /* Drop empty lines. */
527 if (line[strspn(line, " \t\n")] == '\0') {
531 /* Parse and send. parse_ofp_str() will expand and reallocate
532 * the data in 'buffer', so we can't keep pointers to across the
533 * parse_ofp_str() call. */
534 make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
535 parse_ofp_str(line, &match, buffer,
536 NULL, NULL, &priority, &idle_timeout, &hard_timeout,
540 ofm->command = htons(OFPFC_ADD);
541 ofm->cookie = htonll(cookie);
542 ofm->idle_timeout = htons(idle_timeout);
543 ofm->hard_timeout = htons(hard_timeout);
544 ofm->buffer_id = htonl(UINT32_MAX);
545 ofm->priority = htons(priority);
547 send_openflow_buffer(vconn, buffer);
554 do_mod_flows(int argc OVS_UNUSED, char *argv[])
556 uint16_t priority, idle_timeout, hard_timeout;
559 struct ofpbuf *buffer;
560 struct ofp_flow_mod *ofm;
561 struct ofp_match match;
563 /* Parse and send. parse_ofp_str() will expand and reallocate the
564 * data in 'buffer', so we can't keep pointers to across the
565 * parse_ofp_str() call. */
566 make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
567 parse_ofp_str(argv[2], &match, buffer,
568 NULL, NULL, &priority, &idle_timeout, &hard_timeout,
573 ofm->command = htons(OFPFC_MODIFY_STRICT);
575 ofm->command = htons(OFPFC_MODIFY);
577 ofm->idle_timeout = htons(idle_timeout);
578 ofm->hard_timeout = htons(hard_timeout);
579 ofm->cookie = htonll(cookie);
580 ofm->buffer_id = htonl(UINT32_MAX);
581 ofm->priority = htons(priority);
583 open_vconn(argv[1], &vconn);
584 send_openflow_buffer(vconn, buffer);
588 static void do_del_flows(int argc, char *argv[])
593 struct ofpbuf *buffer;
594 struct ofp_flow_mod *ofm;
596 /* Parse and send. */
597 ofm = make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer);
598 parse_ofp_str(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL,
599 &out_port, &priority, NULL, NULL, NULL);
601 ofm->command = htons(OFPFC_DELETE_STRICT);
603 ofm->command = htons(OFPFC_DELETE);
605 ofm->idle_timeout = htons(0);
606 ofm->hard_timeout = htons(0);
607 ofm->buffer_id = htonl(UINT32_MAX);
608 ofm->out_port = htons(out_port);
609 ofm->priority = htons(priority);
611 open_vconn(argv[1], &vconn);
612 send_openflow_buffer(vconn, buffer);
617 do_tun_cookie(int argc OVS_UNUSED, char *argv[])
619 struct nxt_tun_id_cookie *tun_id_cookie;
620 struct ofpbuf *buffer;
623 tun_id_cookie = make_openflow(sizeof *tun_id_cookie, OFPT_VENDOR, &buffer);
625 tun_id_cookie->vendor = htonl(NX_VENDOR_ID);
626 tun_id_cookie->subtype = htonl(NXT_TUN_ID_FROM_COOKIE);
627 tun_id_cookie->set = !strcmp(argv[2], "true");
629 open_vconn(argv[1], &vconn);
630 send_openflow_buffer(vconn, buffer);
635 monitor_vconn(struct vconn *vconn)
639 run(vconn_recv_block(vconn, &b), "vconn_recv");
640 ofp_print(stderr, b->data, b->size, 2);
646 do_monitor(int argc, char *argv[])
650 open_vconn(argv[1], &vconn);
652 int miss_send_len = atoi(argv[2]);
653 struct ofp_switch_config *osc;
656 osc = make_openflow(sizeof *osc, OFPT_SET_CONFIG, &buf);
657 osc->miss_send_len = htons(miss_send_len);
658 send_openflow_buffer(vconn, buf);
660 monitor_vconn(vconn);
664 do_snoop(int argc OVS_UNUSED, char *argv[])
668 open_vconn__(argv[1], "snoop", &vconn);
669 monitor_vconn(vconn);
673 do_dump_ports(int argc, char *argv[])
675 struct ofp_port_stats_request *req;
676 struct ofpbuf *request;
679 req = alloc_stats_request(sizeof *req, OFPST_PORT, &request);
680 port = argc > 2 ? str_to_port_no(argv[1], argv[2]) : OFPP_NONE;
681 req->port_no = htons(port);
682 dump_stats_transaction(argv[1], request);
686 do_probe(int argc OVS_UNUSED, char *argv[])
688 struct ofpbuf *request;
690 struct ofpbuf *reply;
692 make_openflow(sizeof(struct ofp_header), OFPT_ECHO_REQUEST, &request);
693 open_vconn(argv[1], &vconn);
694 run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
695 if (reply->size != sizeof(struct ofp_header)) {
696 ovs_fatal(0, "reply does not match request");
698 ofpbuf_delete(reply);
703 do_mod_port(int argc OVS_UNUSED, char *argv[])
705 struct ofpbuf *request, *reply;
706 struct ofp_switch_features *osf;
707 struct ofp_port_mod *opm;
715 /* Check if the argument is a port index. Otherwise, treat it as
717 port_no = strtol(argv[2], &endptr, 10);
718 if (port_no == 0 && endptr == argv[2]) {
722 /* Send a "Features Request" to get the information we need in order
723 * to modify the port. */
724 make_openflow(sizeof(struct ofp_header), OFPT_FEATURES_REQUEST, &request);
725 open_vconn(argv[1], &vconn);
726 run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
729 n_ports = (reply->size - sizeof *osf) / sizeof *osf->ports;
731 for (port_idx = 0; port_idx < n_ports; port_idx++) {
733 /* Check argument as a port index */
734 if (osf->ports[port_idx].port_no == htons(port_no)) {
738 /* Check argument as an interface name */
739 if (!strncmp((char *)osf->ports[port_idx].name, argv[2],
740 sizeof osf->ports[0].name)) {
746 if (port_idx == n_ports) {
747 ovs_fatal(0, "couldn't find monitored port: %s", argv[2]);
750 opm = make_openflow(sizeof(struct ofp_port_mod), OFPT_PORT_MOD, &request);
751 opm->port_no = osf->ports[port_idx].port_no;
752 memcpy(opm->hw_addr, osf->ports[port_idx].hw_addr, sizeof opm->hw_addr);
753 opm->config = htonl(0);
754 opm->mask = htonl(0);
755 opm->advertise = htonl(0);
757 printf("modifying port: %s\n", osf->ports[port_idx].name);
759 if (!strncasecmp(argv[3], MOD_PORT_CMD_UP, sizeof MOD_PORT_CMD_UP)) {
760 opm->mask |= htonl(OFPPC_PORT_DOWN);
761 } else if (!strncasecmp(argv[3], MOD_PORT_CMD_DOWN,
762 sizeof MOD_PORT_CMD_DOWN)) {
763 opm->mask |= htonl(OFPPC_PORT_DOWN);
764 opm->config |= htonl(OFPPC_PORT_DOWN);
765 } else if (!strncasecmp(argv[3], MOD_PORT_CMD_FLOOD,
766 sizeof MOD_PORT_CMD_FLOOD)) {
767 opm->mask |= htonl(OFPPC_NO_FLOOD);
768 } else if (!strncasecmp(argv[3], MOD_PORT_CMD_NOFLOOD,
769 sizeof MOD_PORT_CMD_NOFLOOD)) {
770 opm->mask |= htonl(OFPPC_NO_FLOOD);
771 opm->config |= htonl(OFPPC_NO_FLOOD);
773 ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
776 send_openflow_buffer(vconn, request);
778 ofpbuf_delete(reply);
783 do_ping(int argc, char *argv[])
785 size_t max_payload = 65535 - sizeof(struct ofp_header);
786 unsigned int payload;
790 payload = argc > 2 ? atoi(argv[2]) : 64;
791 if (payload > max_payload) {
792 ovs_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
795 open_vconn(argv[1], &vconn);
796 for (i = 0; i < 10; i++) {
797 struct timeval start, end;
798 struct ofpbuf *request, *reply;
799 struct ofp_header *rq_hdr, *rpy_hdr;
801 rq_hdr = make_openflow(sizeof(struct ofp_header) + payload,
802 OFPT_ECHO_REQUEST, &request);
803 random_bytes(rq_hdr + 1, payload);
805 gettimeofday(&start, NULL);
806 run(vconn_transact(vconn, ofpbuf_clone(request), &reply), "transact");
807 gettimeofday(&end, NULL);
809 rpy_hdr = reply->data;
810 if (reply->size != request->size
811 || memcmp(rpy_hdr + 1, rq_hdr + 1, payload)
812 || rpy_hdr->xid != rq_hdr->xid
813 || rpy_hdr->type != OFPT_ECHO_REPLY) {
814 printf("Reply does not match request. Request:\n");
815 ofp_print(stdout, request, request->size, 2);
817 ofp_print(stdout, reply, reply->size, 2);
819 printf("%zu bytes from %s: xid=%08"PRIx32" time=%.1f ms\n",
820 reply->size - sizeof *rpy_hdr, argv[1], rpy_hdr->xid,
821 (1000*(double)(end.tv_sec - start.tv_sec))
822 + (.001*(end.tv_usec - start.tv_usec)));
823 ofpbuf_delete(request);
824 ofpbuf_delete(reply);
830 do_benchmark(int argc OVS_UNUSED, char *argv[])
832 size_t max_payload = 65535 - sizeof(struct ofp_header);
833 struct timeval start, end;
834 unsigned int payload_size, message_size;
840 payload_size = atoi(argv[2]);
841 if (payload_size > max_payload) {
842 ovs_fatal(0, "payload must be between 0 and %zu bytes", max_payload);
844 message_size = sizeof(struct ofp_header) + payload_size;
846 count = atoi(argv[3]);
848 printf("Sending %d packets * %u bytes (with header) = %u bytes total\n",
849 count, message_size, count * message_size);
851 open_vconn(argv[1], &vconn);
852 gettimeofday(&start, NULL);
853 for (i = 0; i < count; i++) {
854 struct ofpbuf *request, *reply;
855 struct ofp_header *rq_hdr;
857 rq_hdr = make_openflow(message_size, OFPT_ECHO_REQUEST, &request);
858 memset(rq_hdr + 1, 0, payload_size);
859 run(vconn_transact(vconn, request, &reply), "transact");
860 ofpbuf_delete(reply);
862 gettimeofday(&end, NULL);
865 duration = ((1000*(double)(end.tv_sec - start.tv_sec))
866 + (.001*(end.tv_usec - start.tv_usec)));
867 printf("Finished in %.1f ms (%.0f packets/s) (%.0f bytes/s)\n",
868 duration, count / (duration / 1000.0),
869 count * message_size / (duration / 1000.0));
873 do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
878 static const struct command all_commands[] = {
879 { "show", 1, 1, do_show },
880 { "status", 1, 2, do_status },
881 { "monitor", 1, 2, do_monitor },
882 { "snoop", 1, 1, do_snoop },
883 { "dump-desc", 1, 1, do_dump_desc },
884 { "dump-tables", 1, 1, do_dump_tables },
885 { "dump-flows", 1, 2, do_dump_flows },
886 { "dump-aggregate", 1, 2, do_dump_aggregate },
887 { "add-flow", 2, 2, do_add_flow },
888 { "add-flows", 2, 2, do_add_flows },
889 { "mod-flows", 2, 2, do_mod_flows },
890 { "del-flows", 1, 2, do_del_flows },
891 { "tun-cookie", 2, 2, do_tun_cookie },
892 { "dump-ports", 1, 2, do_dump_ports },
893 { "mod-port", 3, 3, do_mod_port },
894 { "probe", 1, 1, do_probe },
895 { "ping", 1, 2, do_ping },
896 { "benchmark", 3, 3, do_benchmark },
897 { "help", 0, INT_MAX, do_help },
898 { NULL, 0, 0, NULL },