Revision 8f01e99f

View differences:

wcn_simulator.py
98 98
            self.insertLink(self.get(e[0]),self.get(e[1]),quality_params)
99 99

  
100 100
        if draw:
101
            ion()
102 101
            showGraph(self.gg)
103 102

  
104
    def pickHostAddrPort(self,node):
103
    def pickHostAddrPort(self, node):
105 104
        port = self.hosts_port[node.name]
106 105
        addr = "10.0."+node.name.split('_')[-1]+"."+str(port)+"/8"
107 106
        self.hosts_port[node.name] += 1
108 107
        return addr,port
109 108

  
110
    def insertLink(self,n1,n2,quality_params={}):
109
    def insertLink(self, n1, n2, quality_params={}):
111 110
        addr1, port1 = self.pickHostAddrPort(n1)
112 111
        addr2, port2 = self.pickHostAddrPort(n2)
113 112

  
114
        self.addLink(n1,n2,  \
113
        self.addLink(n1, n2,  \
115 114
                port1 = port1, \
116 115
                port2 = port2, \
117 116
                params1=dict([('ip',addr1)] + quality_params.items()), \
......
269 268

  
270 269
if __name__ == '__main__':
271 270
    setLogLevel('info')
272
    opt = [("-o", ["optional", True, 10, "optional parameter", int])]
273
    need = [("-n", ["needed", True, 100, "needed parameter", int])]
271
    need = [
272
            ("-f", ["graphDefinition", True, "", "path of the graph definition", str]),
273
            ("-t", ["testName", True, "", "base name for test output", str])
274
           ]
275
    opt = [
276
            ("-d", ["drawGraph", False, False, 
277
                "draw the graph before you run the test", int])
278
          ]
279

  
274 280
    P = conf(path.basename(__file__),need, opt)
275 281
    P.parseArgs()
282
    drawGraph = P.getParam("drawGraph")
276 283
    if P.checkCorrectness() == False:
277 284
        P.printUsage()
278 285
        sys.exit(1)
279
    net = GraphNet("square.edges",draw=True)
286
    net = GraphNet(P.getParam("graphDefinition"), draw = drawGraph)
280 287
    net.start()
281 288
    net.enableForwarding()
282 289
    net.setShortestRoutes()
283 290
#    CLI(net)
284
    test_name = "FFGRAZ0_parameterless_"+str(int(time()))
291
    test_name = P.getParam("testName")+str(int(time()))
285 292
    for i in range(1):
286
        info( "+++++++ Round: "+str(i+1) + '\n')
293
        info("+++++++ Round: "+str(i+1) + '\n')
287 294
        #test = PSRandomTest(net,duration=6,name=test_name,num_peers=2)
288
        test = PSHostsTest(net,'h0_0',['h1_1','h1_1','h2_2'],duration=600,name=test_name)
295
        test = PSHostsTest(net, 'h0_0', ['h1_1','h1_1','h2_2'],
296
                duration = 600, name = test_name)
289 297
        test.runTest()
290 298
      #  sleep(60)
291 299
    net.stop()

Also available in: Unified diff