#!/usr/bin/python

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
import time

class SingleSwitchTopo(Topo):
   "Single switch connected to n hosts."
   def build(self, n=2):
       switch = self.addSwitch('s1')
       for h in range(n):
           host = self.addHost('h%s' % (h + 1))
           # 10 Mbps, 5ms delay, 10% loss, 1000 packet queue
           self.addLink(host, switch,
              bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True)

def test():
    topo = SingleSwitchTopo(n=2)
    net = Mininet( topo=topo, link=TCLink )
    net.start()

    h1, h2 = net.get('h1', 'h2')
    print h1.cmd( 'ping -c10', h2.IP() )
    h1.cmd( '../tcp-clock-station/tcp-clock-station -l -address ' + h1.IP() + ':8080 &' )
    h2.cmd( '../tcp-clock-station/tcp-clock-station -address ' + h2.IP() + ':8080 > output &' )
    time.sleep(2)
    h1.cmd('kill %tcp-clock-station')
    h2.cmd('kill %tcp-clock-station')

    net.stop()

if __name__ == '__main__':
   setLogLevel('info')
   test()

@@ -330,19 +330,27 @@
 d(self, 
-n=2
+delay, loss
 ):%0A     
@@ -403,17 +403,17 @@
 n range(
-n
+2
 ):%0A     
@@ -585,10 +585,22 @@
 lay=
+str(delay) + 
 '
-5
 ms',
@@ -605,18 +605,20 @@
 ', loss=
-10
+loss
 , max_qu
@@ -655,15 +655,468 @@
 def 
-test():
+runTests():%0A    tcpTest = 'tcp-clock-station'%0A    udpTest = 'udp-clock-station'%0A    rrtcpTest = 'rrtcp-clock-station'%0A%0A    # latency: 0ms..100ms%0A    # loss: 0%25..10%25%0A    for delay in xrange(0, 100, 100):%0A        for loss in xrange(0, 10, 10):%0A            runTest(tcpTest, delay, loss, 'tcp')%0A            runTest(udpTest, delay, loss, 'udp')%0A            runTest(rrtcpTest, delay, loss, 'rrtcp')%0A%0A%0Adef runTest(test, delay, loss, name):%0A    timeToRun = 5 # seconds
 %0A   
@@ -1144,11 +1144,19 @@
 opo(
-n=2
+delay, loss
 )%0A  
@@ -1255,186 +1255,236 @@
     
-print h1.cmd( 'ping -c10', h2.IP() )%0A    h1.cmd( '../tcp-clock-station/tcp-clock-station -l -address ' + h1.IP() + ':8080 &' )%0A    h2.cmd( '../tcp-clock-station/tcp-clock-station
+outputName = name + '_' + str(delay) + '_' + str(loss)%0A%0A    h1.cmd( '../' + test + '/' + test + ' -l -d ' + str(timeToRun) + '-address ' + h1.IP() + ':8080 &' )%0A    h2.cmd( '../' + test + '/' + test + ' -d ' + str(timeToRun) + '
  -ad
@@ -1494,17 +1494,17 @@
 ss ' + h
-2
+1
 .IP() + 
@@ -1511,23 +1511,35 @@
 ':8080 %3E
+ ' +
  output
+Name + '
  &' )%0A  
@@ -1555,85 +1555,21 @@
 eep(
-2)%0A    h1.cmd('kill %25tcp-clock-station')%0A    h2.cmd('kill %25tcp-clock-station'
+timeToRun + 1
 )%0A%0A 
@@ -1636,15 +1636,19 @@
 fo')%0A   
-t
+runT
 est
+s
 ()%0A

update emulation script to run a variety of latencies and losses