add cbench application

This simple application does _only_ what cbench expects. As usual, you
can use this application in the following way:

$ ryu-manager --app_lists ryu.app.cbench.Cbench

Currently, this supports only the latency mode.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori
2012-02-08 22:51:42 +09:00
parent f4063f2f06
commit 70e8d096d5

26
ryu/app/cbench.py Normal file
View File

@@ -0,0 +1,26 @@
# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2012 Isaku Yamahata <yamahata at valinux co jp>
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
class Cbench(object):
def __init__(self, *_args, **kwargs):
pass
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
match = datapath.ofproto_parser.OFPMatch(ofproto.OFPFW_ALL,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0)
datapath.send_flow_mod(
match=match, cookie=0, command=ofproto.OFPFC_ADD,
idle_timeout=0, hard_timeout=0, priority=32768,
flags=0, actions=None)