Revision 97381a53 src/peerstreamer.py

View differences:

src/peerstreamer.py
37 37
        params = {}
38 38
        params['-i'] = source.defaultIntf().ip
39 39
        params['-I'] = host.defaultIntf().name
40
        params['-p'] = self.source_opt_params['-P'] 
40
        params['-p'] = self.source_opt_params['-P']
41 41
        params['-P'] = str(randint(4000,8000))
42 42
        return self.launchPS(host,params,'/dev/null',logfile)
43 43

  
......
67 67
            self.source_opt_params['-P'] = str(7000)
68 68
        if "push_strategy" in conf_args:
69 69
            if conf_args["push_strategy"] != "0":
70
                self.peer_opt_params['--push_strategy'] = "" 
70
                self.peer_opt_params['--push_strategy'] = ""
71 71

  
72 72

  
73 73
        if "chunks_per_second" in conf_args:
......
82 82
            self.peer_opt_params['-b'] = conf_args["chunk_buffer_size"]
83 83
        if "log_chunks" in conf_args:
84 84
            if conf_args["log_chunks"] != "0":
85
                self.peer_opt_params['--chunk_log'] = "" 
85
                self.peer_opt_params['--chunk_log'] = ""
86 86
        if "log_neighbourhood" in conf_args:
87 87
            if conf_args["log_neighbourhood"] != "0":
88
                self.peer_opt_params['--neighbourhood_log'] = "" 
88
                self.peer_opt_params['--neighbourhood_log'] = ""
89 89
        if "log_signals" in conf_args:
90 90
            if conf_args["log_signals"] != "0":
91
                self.peer_opt_params['--signal_log'] = "" 
91
                self.peer_opt_params['--signal_log'] = ""
92 92
        if "distoptimization" in conf_args:
93 93
            if conf_args["distoptimization"] != "0":
94
                self.peer_opt_params['--distoptimization'] = "" 
94
                self.peer_opt_params['--distoptimization'] = ""
95 95
        if "xloptimization" in conf_args:
96 96
            if conf_args["xloptimization"] != "0":
97
                self.peer_opt_params['--xloptimization'] =  conf_args["xloptimization"] 
97
                self.peer_opt_params['--xloptimization'] =  conf_args["xloptimization"]
98 98

  
99 99

  
100 100
    def runTest(self):
......
106 106
        for h in self.hosts:
107 107
            self.launchPeer(h,self.source)
108 108
        info("\nWaiting completion...\n")
109
        sleep(self.duration)
109
        self.wait(self.duration, log_resources={'cpu': 'cpu_usage',
110
                                                'mem': 'mem_usage',
111
                                                'net': 'net_usage'})
110 112

  
111 113
        self.killAll()
112 114

  
......
129 131
            self.source = self.hosts.pop()
130 132
        self.setPrefix(name)
131 133

  
134

  
135
class PSRandomNTest(PSRandomTest):
136
    def __init__(self, mininet, name, args):
137
        args["num_peers"] = "0"
138
        super(PSRandomNTest,self).__init__(mininet,name,args)
139
        self.min_nodes = int(args["min_nodes_num"])
140
        self.max_nodes = int(args["max_nodes_num"])
141
        self.nodes_inc = int(args["nodes_num_inc"])
142

  
143
    def setTestLabel(self,s):
144
        self.test_label = s + "-"+str(len(self.hosts)+1)+"peers"
145

  
146
    def runTest(self):
147
        for n in range(self.min_nodes,self.max_nodes + 1,self.nodes_inc):
148
            self.hosts = self.getHostSample(n)
149
            self.source = self.hosts.pop()
150
            self.setTestLabel("normal")
151
            super(PSRandomTest,self).runTest()
152

  
153

  
132 154
class PSXLOptimizationTest(PSRandomTest):
133 155
    def __init__(self, mininet, name, args):
134 156
        super(PSXLOptimizationTest,self).__init__(mininet,name,args)
......
166 188
                    else:
167 189
                        sp.write("\n")
168 190
        sp.close()
169
        
191

  
170 192
    def resetNetStatistics(self):
171 193
        self.sent_packets, self.sent_bytes = self.net.sentPackets() # base value
172 194
        self.links = {}
......
180 202
            return (sum(values)**2)/den
181 203
        else:
182 204
            return 0
183
        
205

  
184 206
    def get_stats(self):
185 207
        links = self.bytes_per_link()
186 208

  
......
202 224
        return linkos
203 225

  
204 226
    def sentPackets(self):
205
        sp,sb = self.net.sentPackets() 
227
        sp,sb = self.net.sentPackets()
206 228
        return sp - self.sent_packets
207 229

  
208 230
    def runTest(self):
......
249 271
#        fp.write("SCALED," + str(self.scaled_res[0]) + "," + str(self.scaled_res[1]))
250 272
#        fp.write("\n")
251 273
        fp.close()
252
        
274

  
253 275

  
254 276
class PSXLOptimizationNTest(PSXLOptimizationTest):
255 277
    def __init__(self, mininet, name, args):

Also available in: Unified diff