Saturday, May 21, 2016

Mininet dashboard

Mininet Dashboard has been released on GitHub, https://github.com/sflow-rt/mininet-dashboard. Follow the steps in Mininet flow analytics to install sFlow-RT and configure sFlow instrumentation in Mininet.

The following steps install the dashboard and start sFlow-RT:
cd sflow-rt
./get-app.sh sflow-rt mininet-dashboard
./start.sh
The dashboard web interface shown in the screen shot should now be accessible. Run a test to see data in the dashboard. The following test created the results shown:
sudo mn --custom extras/sflow.py --link tc,bw=10 --topo tree,depth=2,fanout=2 --test iperf
The dashboard has three time series charts that update every second and show five minutes worth of data. From top to bottom, the charts are:
  1. Top Flows - Click on a peak in the chart to see the flows that were active at that time.
  2. Top Ports - Click on a peak in the chart to see the ingress ports that were active at that time.
  3. Topology Diameter - The diameter of the topology.
The dashboard application is easily modified to add additional metrics, generate events, or implement controls. For example, adding the following code to the end of the sflow-rt/app/mininet-dashboard/scripts/metrics.js file implements equivalent functionality to the large flow detection Python script described in Mininet flow analytics:
setFlow('pair',
  {'keys':'link:inputifindex,ipsource,ipdestination','value':'bytes'});

setThreshold('elephant',
  {'metric':'pair','value':1000000/8,'byFlow':true,'timeout':1});

setEventHandler(function(evt) {
  logInfo(evt.flowKey);
},['elephant']);
Restart sFlow-RT and repeat the iperf test and the following events should be logged:
$ ./start.sh 
2016-05-21T18:00:03-0700 INFO: Listening, sFlow port 6343
2016-05-21T18:00:03-0700 INFO: Starting the Jetty [HTTP/1.1] server on port 8008
2016-05-21T18:00:03-0700 INFO: Starting com.sflow.rt.rest.SFlowApplication application
2016-05-21T18:00:03-0700 INFO: Listening, http://localhost:8008
2016-05-21T18:00:03-0700 INFO: app/mininet-dashboard/scripts/metrics.js started
2016-05-21T18:00:12-0700 INFO: s1-s2,10.0.0.1,10.0.0.4
2016-05-21T18:00:12-0700 INFO: s1-s3,10.0.0.1,10.0.0.4
See Writing Application for more information.

11 comments:

  1. cd sflow-rt
    ./get-app<.sh> sflow-rt mininet-dashboard
    ./start.sh

    Thank you for the article!

    ReplyDelete
    Replies
    1. Thank you for the correction. I have updated the instructions in the article.

      Delete
  2. what if i have my own topology, in example customtopo.py and i want to run in sflow.py ??

    Thank you

    ReplyDelete
    Replies
    1. I believe that the latest versions of Mininet allow multiple comma separated entries in the --custom argument, i.e. --custom extras/sflow.py,customtopo.py

      You might also be interested in the Mininet dashboard application for sFlow-RT.

      Delete
    2. Thanks Peter.
      I have same question with it.
      Now it works :)

      Delete
  3. Replies
    1. In this example sFlow-RT is running on the command line, so just type CNTRL+C to stop it and then run ./start.sh again.

      If you are installed sFlow-RT as a package then type:
      sudo systemctl restart sflow-rt.service

      Delete
  4. Hello Peter, I have problem with detecting elephant flow in running mininet-dashboard app. I must edited topology command, because I am working with ryu rest QoS. Problem is after iperf test between h1 and h2, I do not get events about detected elephant flow.

    edited topology: sudo mn --custom extras/sflow.py --topo tree,depth=1,fanout=2 --controller remote --switch ovsk,protocols=OpenFlow13

    link to screens from mininet screen: https://imgur.com/a/bGhvGQS
    link to my metrics.js file: https://pastebin.com/x5XNWzrk

    ReplyDelete
    Replies
    1. Your topology doesn't have any inter-switch links and so the link:inputifindex expression in your flow definition won't return a value and so the flow will not be tracked.

      I created the following elephant.js file (it's cleaner to keep your changes in a separate file, rather than edit the mininet-dashboard application files):

      setFlow('pair',
       {'keys':'inputifindex,ipsource,ipdestination','value':'bytes'});

      setThreshold('elephant',
       {'metric':'pair','value':1000000/8,'byFlow':true,'timeout':1});

      setEventHandler(function(evt) {
       var [inputifindex,ipsource,ipdestination] = evt.flowKey.split(',');
       var {node,port} = topologyInterfaceToPort(evt.agent,inputifindex);
       logInfo(port + " " + ipsource + " " + ipdestination);
      },['elephant']);

      And started sFlow-RT with the following command:
      env RTPROP="-Dscript.file=elephant.js" ./start.sh

      When you get an elephant flow it will print the switch port along with the flow:
      s1-eth1 10.0.0.1 10.0.0.2

      Delete
    2. Thanks for your reply Peter. I have one more problem with flowHandler. Here is link to stackoverflow: https://stackoverflow.com/questions/49965853/handle-flow-records-in-mininet-dashboard/49968342

      Delete
    3. I ran the script (with the setFlowHandler function you added) from stackoverflow. The script works. You may need to run a second iperf test since sFlow-RT is data driven and requires a stream of packet samples to flush flow records.

      Delete