<commit_before>#!/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, delay, loss):
       switch = self.addSwitch('s1')
       for h in range(2):
           host = self.addHost('h%s' % (h + 1))
           # 10 Mbps, 5ms delay, 10% loss, 1000 packet queue
           self.addLink(host, switch,
              bw=10, delay=str(delay) + 'ms', loss=loss, max_queue_size=1000, use_htb=True)

def runTests():
    tcpTest = 'tcp-clock-station'
    udpTest = 'udp-clock-station'
    rrtcpTest = 'rrtcp-clock-station'

    for delay in [0, 40, 80, 160]:
        for loss in [0, 5, 10]:
            runTest(tcpTest, delay, loss, 'tcp')
            runTest(udpTest, delay, loss, 'udp')
            runTest(rrtcpTest, delay, loss, 'rrtcp')


def runTest(test, delay, loss, name):
    timeToRun = 5 # seconds
    topo = SingleSwitchTopo(delay, loss)
    net = Mininet( topo=topo, link=TCLink )
    net.start()

    h1, h2 = net.get('h1', 'h2')
    outputName = name + '_' + str(delay) + '_' + str(loss)+'.out'

    h1.cmd( '../' + test + '/' + test + ' -l -d ' + str(timeToRun) + 's -address ' + h1.IP() + ':8080 2>'+outputName+'.listener.err &' )
    h2.cmd( '../' + test + '/' + test + ' -d ' + str(timeToRun) + 's -address ' + h1.IP() + ':8080 > ' + outputName + ' 2>'+outputName+'.dialer.err &' )
    time.sleep(timeToRun + 1)

    net.stop()

if __name__ == '__main__':
   setLogLevel('info')
   runTests()
<commit_msg>fix delay in emulation<commit_after>#!/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, delay, loss):
       switch = self.addSwitch('s1')
       for h in range(2):
           host = self.addHost('h%s' % (h + 1))
           # 10 Mbps, 5ms delay, 10% loss, 1000 packet queue
           self.addLink(host, switch,
              bw=10, delay=str(delay/2) + 'ms', loss=loss, max_queue_size=1000, use_htb=True)

def runTests():
    tcpTest = 'tcp-clock-station'
    udpTest = 'udp-clock-station'
    rrtcpTest = 'rrtcp-clock-station'

    for delay in [0, 40, 80, 160]:
        for loss in [0, 5, 10]:
            runTest(tcpTest, delay, loss, 'tcp')
            runTest(udpTest, delay, loss, 'udp')
            runTest(rrtcpTest, delay, loss, 'rrtcp')


def runTest(test, delay, loss, name):
    timeToRun = 5 # seconds
    topo = SingleSwitchTopo(delay, loss)
    net = Mininet( topo=topo, link=TCLink )
    net.start()

    h1, h2 = net.get('h1', 'h2')
    outputName = name + '_' + str(delay) + '_' + str(loss)+'.out'

    h1.cmd( '../' + test + '/' + test + ' -l -d ' + str(timeToRun) + 's -address ' + h1.IP() + ':8080 2>'+outputName+'.listener.err &' )
    h2.cmd( '../' + test + '/' + test + ' -d ' + str(timeToRun) + 's -address ' + h1.IP() + ':8080 > ' + outputName + ' 2>'+outputName+'.dialer.err &' )
    time.sleep(timeToRun + .1)

    net.stop()

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

{'fraction_non_alphanumeric': 0.1612713360800471, 'fraction_numerical': 0.02972336668628605, 'mean_word_length': 2.8363431151241536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7275637', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1235, 'n_words': 309}