(self, packet, sec=None, usec=None, caplen=None, wirelen=None)
writes a single packet to the pcap file
writes a single packet to the pcap file
writes a single packet to the pcap file
def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None):
        """writes a single packet to the pcap file
        """
        if caplen is None:
            caplen = len(packet)
        if wirelen is None:
            wirelen = caplen
        if sec is None or usec is None:
            t=time.time()
            it = int(t)
            if sec is None:
                sec = it
            if usec is None:
                usec = int(round((t-it)*1000000))
        self.f.write(struct.pack(self.endian+"IIII", sec, usec, caplen, wirelen))
        self.f.write(packet)
        if self.gz and self.sync:
            self.f.flush()
def _write_packet ( self , packet , sec = None , usec = None , caplen = None , wirelen = None ) : if caplen is None : caplen = len ( packet ) if wirelen is None : wirelen = caplen if sec is None or usec is None : t = time . time ( ) it = int ( t ) if sec is None : sec = it if usec is None : usec = int ( round ( ( t - it ) * 1000000 ) ) self . f . write ( struct . pack ( self . endian + "IIII" , sec , usec , caplen , wirelen ) ) self . f . write ( packet ) if self . gz and self . sync : self . f . flush ( )