Statistics
| Branch: | Revision:

wcn_emulator / wcn_simulator.py @ c09f8d98

History | View | Annotate | Download (1.44 KB)

1
#!/usr/bin/env python
2
import sys
3

    
4
sys.path.append('test_code')
5

    
6
from network_builder import *
7
from test_code import *
8

    
9
from os import path
10
from time import time
11

    
12

    
13
from parameters_parser import parameters
14

    
15

    
16
class conf(parameters):
17
    def checkCorrectness(self):
18
        self.checkNeededParams()
19
        return True
20

    
21
if __name__ == '__main__':
22
    setLogLevel('info')
23
    need = [
24
            ("-f", ["graphDefinition", True, "", "path of the graph definition", str]),
25
            ("-t", ["testName", True, "", "base name for test output", str])
26
           ]
27
    opt = [
28
            ("-d", ["drawGraph", False, False, 
29
                "draw the graph before you run the test", int])
30
          ]
31

    
32
    P = conf(path.basename(__file__),need, opt)
33
    P.parseArgs()
34
    drawGraph = P.getParam("drawGraph")
35
    if P.checkCorrectness() == False:
36
        P.printUsage()
37
        sys.exit(1)
38
    net = GraphNet(P.getParam("graphDefinition"), draw = drawGraph)
39
    net.start()
40
    net.enableForwarding()
41
    net.setShortestRoutes()
42
#    CLI(net)
43
    test_name = P.getParam("testName")+"_"+str(int(time()))
44
    for i in range(1):
45
        info("+++++++ Round: "+str(i+1) + '\n')
46
        #test = PSRandomTest(net,duration=6,name=test_name,num_peers=2)
47
        test = peerstreamer.PSHostsTest(net, 'h0_0', ['h1_1','h1_1','h2_2'],
48
                duration = 600, name = test_name)
49
        test.runTest()
50
      #  sleep(60)
51
    net.stop()
52
    info("*** Done with experiment: "+test_name+"\n")