This project simulates packet transfer over a network using a custom Multipacket Transfer Protocol (MTTP) model.
It combines Python for network generation, visualization, and k-shortest path calculations, with C++ for path analysis, TCP/UDP timing calculations, and probability of failure analysis.
- Languages / Tools: C++, Python 3.x, NetworkX, Matplotlib
- Key Concepts:
- Graph-based network modeling
- K-shortest path calculation
- Packet transfer timing (UDP & TCP)
- Path failure probability analysis
- Skills Demonstrated:
- Systems-level programming in C++
- Python scripting for graph generation and visualization
- Integration of Python and C++ workflows
- Data parsing, file I/O, and algorithmic computation
-
Python Network Generation (
driver.py)- Generates a random network graph with a specified number of nodes using NetworkX.
- Assigns random weights to edges (simulating transfer times in ms).
- Computes k-shortest paths from a start node to an end node.
- Saves the network edges and path data to
output.txt.
-
C++ Path Analysis (
driver.cpp)- Reads
output.txtfor network edges and k-shortest paths. - For each path:
- Calculates UDP transmission time as the sum of edge weights.
- Calculates TCP transmission time as UDP + 3 ms per node.
- Tracks probability of failure for each path.
- Computes combined failure probabilities for all path combinations.
- Outputs results to
pathAnalysis.txt.
- Reads
-
Output Visualization
- Python generates a network plot showing nodes and edge weights (requires
matplotlib). - C++ outputs a text-based analysis including:
- Path sequences
- UDP/TCP times
- Failure probabilities
- Combined failure probabilities for path sets
- Python generates a network plot showing nodes and edge weights (requires
Follow these steps to generate a network, compute paths, and analyze them:
-
Clone the repository and navigate to the project folder.
-
Run the Python script
driver.pyto generate a random network:- This will create a network graph with labeled nodes and random edge weights.
- The script will compute k-shortest paths from the start node to the end node.
- Results are saved automatically to
output.txt.
-
Compile the C++ program
driver.cpp:- This will create an executable (e.g.,
pathAnalysis) that readsoutput.txt.
- This will create an executable (e.g.,
-
Run the C++ executable:
- The program calculates UDP and TCP times for each path.
- It also computes failure probabilities for each path and all path combinations.
- Results are saved to
pathAnalysis.txt.
-
View the results in
pathAnalysis.txt:- Each path with nodes is listed along with UDP/TCP times.
- Individual and combined path failure probabilities are included.
-
Optional edits:
- Modify
driver.pyto change the number of nodes, probability of edges, or random seed. - Modify
driver.cppto adjust TCP/UDP calculation parameters or failure probability logic.
- Modify
- Demonstrates integration of Python and C++ workflows for simulation and analysis.
- Simulates network behavior, packet transfer times, and path reliability.
- Implements algorithmic combination logic to calculate multi-path failure probabilities.
- Useful for learning graph algorithms, network modeling, and system simulations.
- Change the number of nodes or probability of edges in Python (
generate_network) to simulate different networks. - Adjust edge weight ranges to model different latency distributions.
- Extend
driver.cppto simulate additional protocols or more complex failure models. - Enhance Python visualization with color-coded edges for high-latency links or failing paths.
MTTPNetworkSim/
│
├─ driver.cpp # C++ simulation and path analysis
├─ driver.py # Python network generation and visualization
├─ output.txt # Network edges and k-shortest paths (generated by Python)
├─ pathAnalysis.txt # Analysis output (generated by C++)
├─ README.md