Beispiel #1
0
 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]
Beispiel #2
0
 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]
Beispiel #3
0
 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]
Beispiel #4
0
 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]