while selfp.arp.table.response.stb != 1:
selfp.arp.table.response.ack = 1
yield
- print("Model's MAC : 0x%12x" %selfp.arp.table.response.mac_address)
+ print("Received MAC : 0x{:12x}".format(selfp.arp.table.response.mac_address))
if __name__ == "__main__":
selfp.ip_port.source.ack = 1
if selfp.ip_port.source.stb == 1 and selfp.ip_port.source.sop == 1:
- print("IP Packet / from ip_address %08x" %selfp.ip_port.sink.ip_address)
+ print("packet from from IP 0x{:08x}".format(selfp.ip_port.sink.ip_address))
yield
def __repr__(self):
r = "--------\n"
for k in sorted(arp_header.keys()):
- r += k + " : 0x%x" %getattr(self,k) + "\n"
+ r += k + " : 0x{:0x}\n".format(getattr(self,k))
r += "payload: "
for d in self:
- r += "%02x" %d
+ r += "{:02x}".format(d)
return r
class ARP(Module):
def __repr__(self):
r = "--------\n"
for k in sorted(icmp_header.keys()):
- r += k + " : 0x%x" %getattr(self,k) + "\n"
+ r += k + " : 0x{:0x}\n".format(getattr(self,k))
r += "payload: "
for d in self:
- r += "%02x" %d
+ r += "{:02x}".format(d)
return r
class ICMP(Module):
def __repr__(self):
r = "--------\n"
for k in sorted(ipv4_header.keys()):
- r += k + " : 0x%x" %getattr(self,k) + "\n"
+ r += k + " : 0x{:0x}\n".format(getattr(self,k))
r += "payload: "
for d in self:
- r += "%02x" %d
+ r += "{:02x}".format(d)
return r
class IP(Module):
received = packet.get_checksum()
packet.insert_checksum()
expected = packet.get_checksum()
- raise ValueError("Checksum error received %04x / expected %04x" %(received, expected))
+ raise ValueError("Checksum error received {:04x} / expected {:04x}".format(received, expected))
packet.decode()
if self.debug:
print_ip("<<<<<<<<")
def __repr__(self):
r = "--------\n"
for k in sorted(mac_header.keys()):
- r += k + " : 0x%x" %getattr(self,k) + "\n"
+ r += k + " : 0x{:0x}\n".format(getattr(self,k))
r += "payload: "
for d in self:
- r += "%02x" %d
+ r += "{:02x}".format(d)
return r
class MAC(Module):
r = ">>>>>>>>\n"
r += "length " + str(len(datas)) + "\n"
for d in datas:
- r += "%02x" %d
+ r += "{:02x}".format(d)
print_phy(r)
self.phy_source.send(packet)
r = "<<<<<<<<\n"
r += "length " + str(len(self.phy_sink.packet)) + "\n"
for d in self.phy_sink.packet:
- r += "%02x" %d
+ r += "{:02x}".format(d)
print_phy(r)
self.packet = self.phy_sink.packet
def __repr__(self):
r = "--------\n"
for k in sorted(udp_header.keys()):
- r += k + " : 0x%x" %getattr(self,k) + "\n"
+ r += k + " : 0x{:0x}\n".format(getattr(self,k))
r += "payload: "
for d in self:
- r += "%02x" %d
+ r += "{:02x}".format(d)
return r
class UDP(Module):