Skip to content
Snippets Groups Projects
Commit fd21c46f authored by Bob Lantz's avatar Bob Lantz
Browse files

Restored udpbwtest.py

parent c80e18cd
No related branches found
No related tags found
No related merge requests found
...@@ -8,8 +8,42 @@ ...@@ -8,8 +8,42 @@
We should also make a tcp version. :D We should also make a tcp version. :D
""" """
import select, sys, time, re import os
from mininet import init, TreeNet, Cli, flush, quietRun import re
import select
import sys
import time
flush = sys.stdout.flush
from mininet.log import lg
from mininet.net import init, Mininet
from mininet.node import Host, KernelSwitch
from mininet.topo import Topo, Node
from mininet.util import quietRun
class TreeTopo( Topo ):
"Topology for a tree network with a given depth and fanout."
def __init__( self, depth=1, fanout=2 ):
super( TreeTopo, self ).__init__()
# Build topology
self.treeNet( 1, depth, fanout )
# Consider all switches and hosts 'on'
self.enable_all()
def treeNet( self, id, depth, fanout ):
"""Add a subtree with a given id.
returns: last id added"""
me = id
isSwitch = (depth > 0 )
self._add_node( me, Node( is_switch=isSwitch ) )
if isSwitch:
for i in range( 0, fanout ):
child = id + 1
self._add_edge( me, child )
id = self.treeNet( child, depth-1, fanout )
return id
# Some useful stuff: buffered readline and host monitoring # Some useful stuff: buffered readline and host monitoring
...@@ -61,8 +95,9 @@ def printTotal( time=None, result=None ): ...@@ -61,8 +95,9 @@ def printTotal( time=None, result=None ):
print '%d\t%d\t%.2f/%.2f\t\t%.2f/%.2f' % ( time, count, intotal, outtotal, print '%d\t%d\t%.2f/%.2f\t\t%.2f/%.2f' % ( time, count, intotal, outtotal,
inavg, outavg ) inavg, outavg )
def udpbwtest( controllers, switches, hosts, seconds ): def udpbwtest( net, seconds ):
"Start up and monitor udpbwtest on each of our hosts." "Start up and monitor udpbwtest on each of our hosts."
hosts, switches = net.hosts, net.switches
hostCount = len( hosts ) hostCount = len( hosts )
print "*** Starting udpbwtest on hosts" print "*** Starting udpbwtest on hosts"
for host in hosts: for host in hosts:
...@@ -94,8 +129,11 @@ def udpbwtest( controllers, switches, hosts, seconds ): ...@@ -94,8 +129,11 @@ def udpbwtest( controllers, switches, hosts, seconds ):
print print
if __name__ == '__main__': if __name__ == '__main__':
init() lg.setLogLevel( 'info' )
network = TreeNet( depth=2, fanout=8, kernel=True ) if not os.path.exists( './udpbwtest' ):
def test( c, s, h ): return udpbwtest( c, s, h, seconds=10 ) raise Exception( 'Could not find udpbwtest in current directory.' )
network.run( test ) init()
network = Mininet( TreeTopo( depth=2, fanout=2 ), switch=KernelSwitch )
\ No newline at end of file network.start()
udpbwtest( network, seconds=10 )
network.stop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment