Skip to content

Commit d36bcd8

Browse files
committed
Log: add pcap info
1 parent 96753a1 commit d36bcd8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

back/src/emulator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import subprocess
44
import time
55

6+
import dpkt
7+
68
from ipmininet.ipnet import IPNet
79
from jobs import Jobs
810
from network_schema import Job, Network
@@ -180,6 +182,22 @@ def create_animation(
180182
if not os.path.exists(pcap_out_file2):
181183
raise ValueError("No capture for interface: " + link2)
182184

185+
# Log pcap sizes and packet counts before parsing
186+
for fname, iface, node_name in [
187+
(pcap_out_file1, link1, edge_source),
188+
(pcap_out_file2, link2, edge_target),
189+
]:
190+
fsize = os.path.getsize(fname)
191+
try:
192+
with open(fname, "rb") as _f:
193+
_count = sum(1 for _ in dpkt.pcapng.Reader(_f))
194+
except Exception as _e:
195+
_count = -1
196+
info(
197+
"[create_animation] pcap: node=%s iface=%s file=%s size=%d pkt_count=%d\n"
198+
% (node_name, iface, fname, fsize, _count)
199+
)
200+
183201
with open(pcap_file1, "rb") as file1, open(pcap_file2, "rb") as file2:
184202
pcap_list.append((file1.read(), link1))
185203
pcap_list.append((file2.read(), link2))

0 commit comments

Comments
 (0)