How to Easily Find and Plot the Correct Simulation Results in OMNeT++? #1521
Replies: 3 comments 3 replies
|
Hi @emystayastronaut! You don’t need to open every result separately. I’d start with an analysis file (.anf), which saves your input files, filters and charts.
|
|
Thanks for sharing the screenshot! That helps a lot 🙂 You're actually in the right place. I can see you're looking at the Scalars tab, which currently contains 2,022 results from your The good news is that you don't need to check all of them individually. Here's what I'd try next:
One important thing I noticed in your screenshot: Values like For example, For your 4G vs 5G comparison, you'll also want to make sure the corresponding result files from both simulations are included in your analysis. I'd start with just one metric: latency. Try searching for If you can share a screenshot of those filtered results showing the Module, Name, and Value columns, it'll be easier to identify which measurements are relevant. Also, if no delay or jitter statistics appear, they might not have been recorded by your current simulation configuration. Hope this makes the results a little easier to navigate! |
|
Hi Welcome to OMNeT++! What you are experiencing is completely normal. The built-in OMNeT++ Analysis Tool (the To answer your questions directly:
Here is the exact step-by-step guide to automating your results: Step 1: Know Your Metric NamesIn OMNeT++, you don't need to look at every file. You only need these specific scalar metrics:
Step 2: Export Data to CSV (The Fast Way)Instead of opening the slow
(This instantly creates Step 3: The Python Automation ScriptNow, we use a Python script to read that CSV, find the exact metrics automatically, and draw the graphs.
import pandas as pd
import matplotlib.pyplot as plt
import os
# 1. Read the OMNeT++ CSV data
csv_file = "raw_simulation_data.csv"
if not os.path.exists(csv_file):
print(f"Error: {csv_file} not found. Run opp_scavetool first!")
exit()
print("Analyzing simulation data...")
df_raw = pd.read_csv(csv_file, low_memory=False)
df_scalars = df_raw[df_raw['type'] == 'scalar']
results = []
runs = df_scalars['run'].dropna().unique()
# 2. Extract Metrics for 4G and 5G Automatically
for run_id in runs:
run_data = df_scalars[df_scalars['run'] == run_id]
if "LTE" in run_id or "4G" in run_id:
network_type = "4G LTE"
elif "NR" in run_id or "5G" in run_id:
network_type = "5G NR"
else:
continue
# Throughput (Convert Bytes over 3 seconds to Mbps)
bytes_data = run_data[run_data['name'].str.contains('rcvdPk:sum.packetBytes', regex=False, na=False)]
total_bytes = bytes_data['value'].astype(float).sum()
throughput_mbps = (total_bytes * 8) / (3.0 * 1000000)
# Latency (Convert seconds to ms)
delay_data = run_data[run_data['name'].str.contains('rcvdPk:mean.delay', regex=False, na=False)]
latency_ms = delay_data['value'].astype(float).mean() * 1000
# Jitter (Convert seconds to ms)
jitter_data = run_data[run_data['name'].str.contains('rcvdPk:mean.jitter', regex=False, na=False)]
jitter_ms = jitter_data['value'].astype(float).mean() * 1000
# Packet Loss (%)
sent_data = run_data[run_data['name'].str.contains('sentPk:count', regex=False, na=False)]
rcvd_data = run_data[run_data['name'].str.contains('rcvdPk:count', regex=False, na=False)]
total_sent = sent_data['value'].astype(float).sum()
total_rcvd = rcvd_data['value'].astype(float).sum()
loss_pct = max(0, ((total_sent - total_rcvd) / total_sent) * 100) if total_sent > 0 else 0.0
results.append({
"Network": network_type,
"Throughput (Mbps)": round(throughput_mbps, 2),
"Latency (ms)": round(latency_ms, 2),
"Packet Loss (%)": round(loss_pct, 2),
"Jitter (ms)": round(jitter_ms, 2)
})
# 3. Print the Final Table
df_results = pd.DataFrame(results).sort_values(by="Network")
print("\n" + "="*60)
print(" AUTOMATED RESULTS TABLE")
print("="*60)
print(df_results.to_string(index=False))
print("="*60 + "\n")
# 4. Automatically Plot the Graphs
fig, axes = plt.subplots(2, 2, figsize=(10, 8))
networks = df_results["Network"].tolist()
colors = ["#e74c3c", "#27ae60"] # Red for 4G, Green for 5G
metrics = [
("Throughput (Mbps)", axes[0,0], "Higher is Better"),
("Latency (ms)", axes[0,1], "Lower is Better"),
("Packet Loss (%)", axes[1,0], "Lower is Better"),
("Jitter (ms)", axes[1,1], "Lower is Better")
]
for metric, ax, title_suffix in metrics:
values = df_results[metric].tolist()
ax.bar(networks, values, color=colors, width=0.5)
ax.set_title(f"{metric}\n({title_suffix})", fontweight="bold")
ax.set_ylabel(metric)
ax.grid(axis='y', linestyle='--', alpha=0.7)
for i, v in enumerate(values):
ax.text(i, v + (max(values)*0.02), str(v), ha='center', fontweight='bold')
plt.suptitle("4G LTE vs 5G NR Performance Comparison", fontsize=14, fontweight="bold")
plt.tight_layout()
plt.savefig("Automated_Comparison_Graphs.png", dpi=300)
print("Success! Graphs automatically saved as 'Automated_Comparison_Graphs.png'.")
plt.show()Step 4: Run the ScriptNow, every time you finish your simulation in OMNeT++, you just run these two commands in your terminal: opp_scavetool x results/*.sca -o raw_simulation_data.csv
python auto_plotter.pyThe script will automatically read your raw data, print a clean table into the terminal, and pop up the graphs on your screen, saving them as an image for your report! I hope this helps speed up your workflow! |





Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I’m new to OMNeT++ and currently working on my Final Year Project titled “Comparative Performance Analysis of 4G LTE and 5G Networks Using OMNeT++ Simulation.”
My current setup is:
I have successfully run my simulation, and it can run until the green screen appears. After that, I can expand the run and access the result files, such as
.sca,.vci, and.vec. However, there is a large amount of data, which makes it confusing for me to identify the correct results and graphs for my project.When I select a result or try to plot a graph, it also takes quite a long time to load. Since I need to analyse several QoS metrics, such as throughput, latency, packet loss, and jitter, checking the results one by one is quite time-consuming.
My questions are:-
I would really appreciate any guidance or suggestions. Since I’m still a beginner, a simple explanation or step-by-step instructions would be very helpful.
Thank you for your time and help!
All reactions