On Tue, 08 May 2018 00:29:54 +0900, Jade Manapee wrote: > > Hi everyone, > > I wrote some code for monitoring traffic. I created a link which has > 10 Mbps I tried to send traffic 5 Mbps with iperf and i expect it will > give me something like 600000 bytes/sec. it did actually but sometimes > it gives me 1000000 bytes/sec. > > Here's my code > > def _port_stats_reply_handler(self, ev): > body = ev.msg.body > > for stat in sorted(body, key=attrgetter('port_no')): > if stat.port_no != ofproto_v1_3.OFPP_LOCAL: > key = (ev.msg.datapath.id, stat.port_no) > value = (stat.tx_bytes, stat.rx_bytes, stat.rx_errors, > stat.duration_sec, stat.duration_nsec) > self._save_stats(self.port_stats, key, value, 5) > > load = stat.tx_bytes > self._save_stats(self.AllLoad, key, load, 1) > if len(self.AllLoad[key]) == 1: > cur_load = load - 0 > else: > cur_load = load -self.AllLoad[key][-2] > self._save_stats(self.CurLoad, key, cur_load, 1) > #print ("load-", load ,"allload-",self.AllLoad[key][-2]) > #print "Request time:", time.time() - self.request_start > print self.port2curload > if ev.msg.datapath.id==0x1 and stat.port_no==0x2: > load = stat.tx_bytes > self.port2curload.append(load-self.port2allload[-1]) > self.port2allload.append(load) > > the output I want is port2curload. your help would be highly appreciated. > Thanks
Code indents are broken and it is difficult to judge from this small fraction of code, but: 1. have you taken header bytes in account ? 2. how was tx_packets? 3. didn't you record duration_sec, duration_nsec? -- IWAMOTO Toshihiro ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel