Search code examples
sdnmininetopenflow

How to add flow table on each two switches? (mininet)


I set topology as can seen in the image below. I want to add different flow-tables to each switch. But if I type

dpctl add-flow in_port=1,nw_dst=10.0.0.2,actions=output:3

the flow table is added to both s1 and s2!

How can I add a different flow-table to each switch?

screen capture


Solution

  • You can't do this with dpctl command, you have to use "sh ovs-ofctl" command.

    Also mininet answered a question related with dpctl in this link

    Here is what i did:

    yavuz@ubuntu:~$ sudo mn --topo linear,2,1  --switch ovsk --controller=remote
    *** Creating network
    *** Adding controller
    Connecting to remote controller at 127.0.0.1:6653
    *** Adding hosts:
    h1 h2
    *** Adding switches:
    s1 s2
    *** Adding links:
    (h1, s1) (h2, s2) (s2, s1)
    *** Configuring hosts
    h1 h2
    *** Starting controller
    c0
    *** Starting 2 switches
    s1 s2 ...
    *** Starting CLI:
    

    Lets dump flows:

    mininet> dpctl dump-flows
    *** s1 ------------------------------------------------------------------------
    NXST_FLOW reply (xid=0x4):
     cookie=0x0, duration=10.979s, table=0, n_packets=21, n_bytes=1674, idle_age=1, priority=0 actions=CONTROLLER:65535
    *** s2 ------------------------------------------------------------------------
    NXST_FLOW reply (xid=0x4):
     cookie=0x0, duration=10.974s, table=0, n_packets=21, n_bytes=1674, idle_age=1, priority=0 actions=CONTROLLER:65535
    

    Add a flow to s1:

    mininet> sh ovs-ofctl add-flow s1 in_port=5,nw_dst=10.0.0.5,actions=output:5
    2017-08-03T16:06:41Z|00001|ofp_util|INFO|normalization changed ofp_match, details:
    2017-08-03T16:06:41Z|00002|ofp_util|INFO| pre: in_port=5,nw_dst=10.0.0.5
    2017-08-03T16:06:41Z|00003|ofp_util|INFO|post: in_port=5
    

    Now, as seen in flow dump, flows for each switch are different:

    mininet> dpctl dump-flows
    *** s1 ------------------------------------------------------------------------
    NXST_FLOW reply (xid=0x4):
     cookie=0x0, duration=2.644s, table=0, n_packets=0, n_bytes=0, idle_age=2, in_port=5 actions=output:5
     cookie=0x0, duration=20.971s, table=0, n_packets=21, n_bytes=1674, idle_age=11, priority=0 actions=CONTROLLER:65535
    *** s2 ------------------------------------------------------------------------
    NXST_FLOW reply (xid=0x4):
     cookie=0x0, duration=20.965s, table=0, n_packets=21, n_bytes=1674, idle_age=11, priority=0 actions=CONTROLLER:65535
    mininet>