Skip to content

Commit

Permalink
✨ generated graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefEZ committed Apr 8, 2024
1 parent d555c96 commit 5bb3e9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions pcap_analysis/process_pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,23 @@ def plot_flow_comp_time(results, case, mode, senders):
def plot_packet_loss(results, case, mode, senders):
plt.figure(figsize=(12, 6)) # Adjust figure size as needed

unit = "Mbps" if "bandwidth" in mode else "ms"
for queue_size in queue_sizes:
# Get results for the current queue size
packet_loss_data = get_scaling_results(results, case, queue_size, senders)

# Sort variables for consistent plotting
variables_sorted = sorted(packet_loss_data.keys())
variables_sorted = sorted(packet_loss_data.keys(), key=extract_integer)
packet_losses = [packet_loss_data[var] for var in variables_sorted]
variables_sorted = list(map(extract_integer, variables_sorted))


# Plotting
plt.plot(variables_sorted, packet_losses, label=f"Senders: {senders}, Queue Size: {queue_size}",
marker='o') # Adjust marker style as desired

plt.title(f"Packet Loss - ({case} scenario)")
plt.xlabel(mode)
plt.xlabel(f"{mode.replace('_', ' ')} ({unit})")
plt.ylabel("Total Packet Loss")
plt.legend()
plt.grid(True)
Expand Down Expand Up @@ -246,6 +249,7 @@ def get_avg_packets_dropped(source_directory, senders=1):

for seed in seeds:
# Calculate paths for UDP and TCP senders based on number of senders
print(f"reading for {source_directory}/{seed}/{senders}")
udp_sender_path = os.path.join(source_directory, seed, f"{senders}", "-CongestionSender-1.pcap")
if os.path.exists(udp_sender_path):
total_packet_loss_udp += count_packets_by_port(read_pcap(udp_sender_path), 49153, 50001)
Expand All @@ -271,7 +275,7 @@ def get_avg_packets_dropped(source_directory, senders=1):

avg_udp_loss = total_packet_loss_udp / len(seeds) if seeds else 0
avg_tcp_loss = total_packet_loss_tcp / (len(seeds) * senders) if seeds else 0

print(f"UDP LOSS: {avg_udp_loss}, TCP LOSS: {avg_tcp_loss}")
return avg_udp_loss + avg_tcp_loss

def record_packet_loss(source_directory, result_directory, mode):
Expand All @@ -290,7 +294,7 @@ def record_packet_loss(source_directory, result_directory, mode):
else:
results[senders][case][variable][queue_size] = get_avg_packets_dropped(f"{source_directory}{variable}/{queue_size}/frr-{case}", senders)
results[senders][case][variable]['base'] = get_avg_packets_dropped(f"{source_directory}{variable}/20/baseline-{case}", senders)

return results


if __name__ == '__main__':
Expand Down

0 comments on commit 5bb3e9d

Please sign in to comment.