packet_count = split_appdata(int(size)) self.canvas.message.show_message("传输层拆包成功!数量:{}".format(packet_count)) for i in range(1, packet_count + 1): trans_data = TransData( obj_id=self.ObjID, id_key=app_data.id_key, trans_pack_id=str(i), trans_seq=i, trans_tag=label, app_pack_id=app_data.app_pack_id, sent_port=int(self.interface[0]["conn_port"].split(".")[0]), rcpt_port=80, source_app_addr=self.interface[0]['ip'], target_app_addr=ip, trans_packed_string=app_data.pack(), timestamp=int(time.time()) ) self.canvas.message.show_message("传输层数据包{}:{}".format(i, trans_data.pack())) ip_data = IPData( obj_id=self.ObjID, id_key="1001", ip_pack_id="1001", trans_pack_id=str(i), source_ip=self.interface[0]["ip"], target_ip=ip, source_app_addr=self.interface[0]["ip"], target_app_addr=ip, ip_packed_string=trans_data.pack() ) self.canvas.message.show_message("网络层数据包:{}".format(trans_data.pack())) mac_data = MACData( obj_id=self.ObjID, id_key=app_data.id_key, mac_pack_id="1001", ip_pack_id=str(i), sent_mac=self.interface[0]["mac"], rcpt_mac=mac, source_ip=self.interface[0]["ip"], target_ip=ip, source_app_addr=self.interface[0]["ip"], target_app_addr=ip, mac_packed_string=ip_data.pack() ) self.canvas.message.show_message("链路层数据包:{}".format(mac_data.pack())) self.canvas.show_top_message(self, message=message.format(self.ObjLabel, self.interface[0]["ip"], self.interface[0]["mac"], size, i, packet_count)) packet = SimPacket(self.interface[0]["ip"], self.interface[0]["mac"], ip, mac, mac_data.pack()) thread = threading.Timer(i, function=self.send, args=(packet,)) thread.start() tk.Button(toplevel, text='开启模拟', font=('黑体', 16), height=1, command=split_packet).grid(row=5, column=0, sticky='e', pady=10) tk.Button(toplevel, text='取消', font=('黑体', 16), height=1, command=toplevel.destroy).grid(row=5, column=1, sticky='e', pady=10)