示例#1
0
文件: pic.py 项目: sangyf/picdfi
 def _initsummary_(self):
     # the result summary { ftype: [nflows, nbytes, npackets] }
     self.dsum = {}
     self.dsum['nflows'] = 0
     self.dsum['npackets'] = 0
     self.dsum['nbytes'] = 0
     self.dsum['ident_pkts'] = 0
     self.dsum['ident_bytes'] = 0
     for typ in TYPE.keys():
         if isinstance(typ, int):
             self.dsum[typ] = [0, 0, 0]
示例#2
0
文件: pic.py 项目: 72Zn/picdfi
 def _initsummary_(self):
     # the result summary { ftype: [nflows, nbytes, npackets] }
     self.dsum = {}
     self.dsum["nflows"] = 0
     self.dsum["npackets"] = 0
     self.dsum["nbytes"] = 0
     self.dsum["ident_pkts"] = 0
     self.dsum["ident_bytes"] = 0
     for typ in TYPE.keys():
         if isinstance(typ, int):
             self.dsum[typ] = [0, 0, 0]
示例#3
0
文件: pic.py 项目: 72Zn/picdfi
 def summary(self):
     self.flush()
     s = "FLOW TABLE SUMMARY\n"
     s += "created: %s\t\tlastaccess: %s\t\tduration: %s\n" % (self.created, self.lastaccess, self.duration)
     s += "nflows: %s\t\tnbytes: %s\t\tnpackets: %s\n" % (self.nflows, self.nbytes, self.npackets)
     fident_bytes = self.ident_bytes / float(self.nbytes) * 100
     fident_pkts = self.ident_pkts / float(self.npackets) * 100
     s += "\t\t%c ident_bytes: %s\t\t%c ident_packtes: %s\n" % ("%", fident_bytes, "%", fident_pkts)
     s += "type\t\t\tnflows\t\t%c flows\t\t%c bytes\t\t%c packets\n" % ("%", "%", "%")
     for typ in TYPE.keys():
         if isinstance(typ, int):
             t = TYPE[typ]
             v = self.dsum[typ]
             fflows = v[0] / float(self.nflows) * 100
             fbytes = v[1] / float(self.nbytes) * 100
             fpackets = v[2] / float(self.npackets) * 100
             s += "%13s:\t\t%s\t\t%.3f\t\t%.3f\t\t%.3f\n" % (t, v[0], fflows, fbytes, fpackets)
     return s[:-1]
示例#4
0
文件: pic.py 项目: sangyf/picdfi
 def summary(self):
     self.flush()
     s = "FLOW TABLE SUMMARY\n"
     s += "created: %s\t\tlastaccess: %s\t\tduration: %s\n" % \
         (self.created,self.lastaccess,self.duration)
     s += "nflows: %s\t\tnbytes: %s\t\tnpackets: %s\n" % \
          (self.nflows, self.nbytes, self.npackets)
     fident_bytes = self.ident_bytes / float(self.nbytes) * 100
     fident_pkts = self.ident_pkts / float(self.npackets) * 100
     s += "\t\t%c ident_bytes: %s\t\t%c ident_packtes: %s\n" % (
         '%', fident_bytes, '%', fident_pkts)
     s += "type\t\t\tnflows\t\t%c flows\t\t%c bytes\t\t%c packets\n" % (
         '%', '%', '%')
     for typ in TYPE.keys():
         if isinstance(typ, int):
             t = TYPE[typ]
             v = self.dsum[typ]
             fflows = v[0] / float(self.nflows) * 100
             fbytes = v[1] / float(self.nbytes) * 100
             fpackets = v[2] / float(self.npackets) * 100
             s += "%13s:\t\t%s\t\t%.3f\t\t%.3f\t\t%.3f\n" % \
                 (t,v[0],fflows,fbytes,fpackets)
     return s[:-1]