Exemplo n.º 1
0
 def test_ethernet_write(self):
     """This test writes a fake ethernet packet to a dump file."""
     from pcs.pcap import DLT_EN10MB
     file = PcapDumpConnector("etherdump.out", DLT_EN10MB)
     # create one packet, copy its bytes, then compare their fields
     ether = ethernet()
     assert (ethernet != None)
     ether.src = "\x00\x00\x00\x00\x00\x00"
     ether.dst = "\xff\xff\xff\xff\xff\xff"
     ether.type = 2048
     file.write(ether.bytes)
Exemplo n.º 2
0
 def test_ethernet_write(self):
     """This test writes a fake ethernet packet to a dump file."""
     from pcs.pcap import DLT_EN10MB
     file = PcapDumpConnector("etherdump.out", DLT_EN10MB)
     # create one packet, copy its bytes, then compare their fields
     ether = ethernet()
     assert (ethernet != None)
     ether.src = "\x00\x00\x00\x00\x00\x00"
     ether.dst = "\xff\xff\xff\xff\xff\xff"
     ether.type = 2048
     file.write(ether.bytes)
Exemplo n.º 3
0
    def test_ethernet_dump(self):
        """This test dumps a fake ethernet packet, with timetamp, to a
        dump file."""
        from pcs.pcap import DLT_EN10MB
        file = PcapDumpConnector("pcapdump2.out", DLT_EN10MB)
        # create one packet, copy its bytes, then compare their fields
        ether = ethernet()
        assert (ethernet != None)
        ether.src = "\x00\x00\x00\x00\x00\x00"
        ether.dst = "\xff\xff\xff\xff\xff\xff"
        ether.type = 2048

        class header:
            sec = 0
            usec = 0
            caplen = 0

        header.sec = 69
        header.usec = 69
        header.caplen = len(ether.bytes)
        file.sendto(ether.bytes, header)
        file.close()
        # Re read what we just wrote.
        file = PcapConnector("pcapdump2.out", DLT_EN10MB)
        ether = file.readpkt()
        assert (ether.timestamp == 69.000069)
Exemplo n.º 4
0
 def test_ethernet_dump(self):
     """This test dumps a fake ethernet packet, with timetamp, to a
     dump file."""
     from pcs.pcap import DLT_EN10MB
     file = PcapDumpConnector("pcapdump2.out", DLT_EN10MB)
     # create one packet, copy its bytes, then compare their fields
     ether = ethernet()
     assert (ethernet != None)
     ether.src = "\x00\x00\x00\x00\x00\x00"
     ether.dst = "\xff\xff\xff\xff\xff\xff"
     ether.type = 2048
     class header:
         sec = 0
         usec = 0
         caplen = 0
     
     header.sec = 69
     header.usec = 69
     header.caplen = len(ether.bytes)
     file.sendto(ether.bytes, header)
     file.close()
     # Re read what we just wrote.
     file = PcapConnector("pcapdump2.out", DLT_EN10MB)        
     ether = file.readpkt()
     assert(ether.timestamp == 69.000069)