def UDPBWCompareProber(ctr_udp=1):
  mts = MyTestSuite()
  print "Connected to all hosts"

  remoteserver = mts.S
  remoterouter = mts.R
  for remoteclient in [mts.A, mts.B]: #, mts.C]:
    if remoteserver != remoteclient:
      for k in range(ctr_udp):
        print "ROUND ", k
        print ('UPLINK '+ remoteclient.name + ' to ' + remoteserver.name)
        bwlim = remoteclient.UDPProbeTest(remoterouter)
        bwlim = remoteclient.UDPProbeTest(remoteserver)
        bwlim = remoterouter.UDPProbeTest(remoteserver)
        print ('DOWNLINK '+ remoteserver.name + ' to ' + remoteclient.name)
        bwlim = remoterouter.UDPProbeTest(remoteclient)
        bwlim = remoteserver.UDPProbeTest(remoteclient)
        bwlim = remoteserver.UDPProbeTest(remoterouter)
      # transfer logs
      mts.transferLogs('udpprobe_'+remoteclient.name+remoteserver.name)
  return mts
def UDPBWGraphs(ctr_udp=1):
  mts = MyTestSuite()
  print "Connected to all hosts"
  mts.startAllPings()
  print "start pings"
  time_sleep = 10.0

  for k in range(ctr_udp):
    print "ROUND ", k
    for remoteclient in [mts.A, mts.B, mts.C, mts.R, mts.S]:
      for remoteserver in [mts.A, mts.B, mts.C, mts.R, mts.S]:
        if remoteserver != remoteclient:
          print (remoteclient.name + ' to ' + remoteserver.name)
          #mts.R.tcpDump('R_'+remoteclient.name+remoteserver.name+'.pcap')
          print 'start udpprobe test'
          bwlim = remoteclient.UDPProbeTest(remoteserver)
          print 'done udpprobe test; start iperf udp with bw '+bwlim
          #remoteclient.UDPIperfTest(remoteserver, bwlim)
          #print 'done iperf udp test'
          #mts.R.remoteCommand('killall tcpdump')
          # transfer logs
          #mts.transferLogs('traffic_'+remoteclient.name+remoteserver.name)
  mts.stopAllPings()
  #mts.transferLogs('udpbwtest')

  return mts
def UDPBWTests(ctr_udp):
  mts = MyTestSuite()
  mts.startAllPings()
  for remoteclient in [mts.A, mts.B, mts.C, mts.R, mts.S]:
    for remotesrcdirteserver in [mts.A, mts.B, mts.C, mts.R, mts.S]:
      if remoteserver != remoteclient:
        print (remoteclient.name + ' to ' + remoteserver.name)
        for k in range(ctr_udp):
          remoteclient.UDPProbeTest(remoteserver)
          time.sleep(time_sleep)
          # take a tcpdump at router between round 2 and 4
          mts.routerSmallTCPDump(remoteclient, remoteserver, k, 2, 4)

  mts.stopAllPings()
  return mts
def UDPBWCompareIperfTCP(ctr_tcp=1):
  mts = MyTestSuite()
  print "Connected to all hosts"
  print "start all tcp servers on all hosts"
  for x in [mts.A, mts.B, mts.C, mts.R, mts.S]:
    x.startIperfServer()
  remoteserver = mts.S
  remoterouter = mts.R
  for remoteclient in [mts.A, mts.B]: #, mts.C]:
    if remoteserver != remoteclient:
      for k in range(ctr_tcp):
        print "ROUND ", k
        print ('UPLINK '+ remoteclient.name + ' to ' + remoteserver.name)
        bwlim = remoteclient.startIperfClient(remoterouter)
        bwlim = remoteclient.startIperfClient(remoteserver)
        bwlim = remoterouter.startIperfClient(remoteserver)
        print ('DOWNLINK '+ remoteserver.name + ' to ' + remoteclient.name)
        bwlim = remoterouter.startIperfClient(remoteclient)
        bwlim = remoteserver.startIperfClient(remoteclient)
        bwlim = remoteserver.startIperfClient(remoterouter)
      # transfer logs
      mts.transferLogs('iperftcp_'+remoteclient.name+remoteserver.name)
  return mts
def runTrafficLatTest(rate):
  mts = MyTestSuite()

  if rate != 0:
    mts.S.remoteCommand('echo "gtnoise" | sudo -S sh ratelimit.sh '+rate+'mbit '+rate+'mbit')
    mts.R.remoteCommand('sh ratelimit2.sh '+rate+'mbit '+rate+'mbit')
  else:
    mts.S.remoteCommand('echo "gtnoise" | sudo -S tc qdisc del dev eth1 root')
    mts.R.remoteCommand('tc qdisc del dev eth1 root')

  mts2 = TrafficLatencyTests(mts.A, mts.S, mts)
  mts2 = TrafficLatencyTests(mts.B, mts.S, mts)
  mts2 = TrafficLatencyTests(mts.C, mts.S, mts)

  return
def bandwidthTest(ctr_tcp, ctr_udp):
  mts = MyTestSuite()
  print "Connected to all hosts"
  mts.startAllPings()
  print "start pings"
  TCPTest(mts, ctr_tcp)
  print "iperf TCP x "+str(ctr_tcp)
  UDPTest(mts, ctr_udp)
  print "iperf UDP x "+str(ctr_udp)
  mts.stopAllPings()
  print "stop pings"
  print  time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), " DONE"
  return mts
def UDPProbeTests(ctr_udp=1):
  mts = MyTestSuite()
  time_sleep = 10.0
  for k in range(ctr_udp):
    print "ROUND ", k
    for remoteclient in [mts.A, mts.B, mts.C, mts.R, mts.S]:
      for remoteserver in [mts.A, mts.B, mts.C, mts.R, mts.S]:
        if remoteserver != remoteclient:
          print (remoteclient.name + ' to ' + remoteserver.name)
          mts.R.tcpDump('R_'+remoteclient.name+remoteserver.name+'.pcap')
          mts.startAllPings()
          print 'start test'
          remoteclient.UDPProbeTest(remoteserver)
          print 'done test'
          print 'no traffic for 10 secs'
          time.sleep(time_sleep)
          print 'done: stop all process and transfer logs'
          mts.stopAllPings()
          mts.R.remoteCommand('killall tcpdump')
          # transfer logs
          mts.transferLogs('traffic_'+remoteclient.name+remoteserver.name)
  return mts
def runTCPLatTest(rate):
  mts = MyTestSuite()
  #buffersize = str(buffersize) #in kb

  if rate != 0:
    rate = str(rate)
    mts.Q.remoteCommand('sh ratelimit3.sh eth0 '+rate)
    mts.Q.remoteCommand('sh ratelimit3.sh eth1 '+rate)
    #mts.Q.remoteCommand('sh ratelimit2.sh eth0 '+rate+' '+rate+' '+buffersize)
    #mts.Q.remoteCommand('sh ratelimit2.sh eth1 '+rate+' '+rate+' '+buffersize)
    #mts.R.remoteCommand('sh ratelimit2.sh eth1 '+rate+'mbit '+rate+'mbit')
  else:
    mts.Q.remoteCommand('tc qdisc del dev eth0 root')
    mts.Q.remoteCommand('tc qdisc del dev eth1 root')
    #mts.R.remoteCommand('tc qdisc del dev eth1 root')

  mts2 = TCPLatencyTest(mts, rate)
  mts2.stop_n_clear()
  mts2.closeAllHosts()

  return