3.24 GB
21,117 files
Updated 30 days ago
Name
Size
.git
02_Assignments
03_Past_Courses
04_Resources
6.829_OCW
Books
CAs_last_term
Exams
HomeWorks
LatexTemplate
Reports
Slides
University_Assignments
tutorials
.DS_Store28.7 kB
xet
.gitignore28 Bytes
xet
README.md18.9 kB
xet
README.md

CN — Computer Networks (repository root)

GitHub Repo License NS-2

This repository is a comprehensive archive of Computer Networks course materials, including assignments, experiments, simulations, and reports. It emphasizes reproducible research with tools like NS-2, P4, Mininet, and LaTeX for Persian/English documentation.

🎯 Goal: Provide students and researchers with hands-on networking projects, from TCP congestion control to SDN implementations.


📋 Table of Contents


Quick start (3 steps)

  1. Clone the repository
git clone <repo-url> CN
cd CN
  1. Install minimal prerequisites (Ubuntu example)
sudo apt update
sudo apt install -y python3 python3-pip git build-essential texlive-latex-recommended texlive-xetex latexmk
pip3 install --user matplotlib numpy

macOS (Homebrew):

brew install python git basictex
pip3 install --user matplotlib numpy
  1. Reproduce the CA_phase1 TCP experiment (smoke)
cd 02_Assignments/CA_phase1
./run_all.sh          # convenience wrapper: smoke run + build report
# or run full pipeline manually:
cd codes
python3 run_experiments.py --runs 10 --simtime 1000
# build the report (from report/)
cd ../report && latexmk -pdf report.tex

Notes:

  • If ns (ns-2) is not on your PATH, pass --ns-path /path/to/ns to run_experiments.py.
  • run_all.sh is a convenience wrapper that runs a smoke pipeline and attempts to build the report; inspect logs under results/.

Prerequisites and installation pointers

Minimum software

  • Python 3.8+ (matplotlib, numpy)
  • LaTeX toolchain: xelatex (for Persian) or latexmk/pdflatex for English variants
  • ns-2 (for CA_phase1, CA_phase2) — tested with ns-2.35 or ns-2.36
  • (Optional) Mininet / P4 / BMv2 for CA1 examples and CA_PHASE2_mininet

Installing ns-2 (high level guidance)

  • Use ns-allinone-2.35 or ns-allinone-2.36 and follow its README — building requires: gcc/g++, make, tcl/tk dev packages, perl, zlib, libx11-dev, and more.
  • Prefer Ubuntu 18.04/20.04 for known compatibility.

Python dependencies

  • If a requirements.txt exists, run pip3 install -r requirements.txt
  • Otherwise: pip3 install matplotlib numpy pandas (pandas optional for CSV output)

LaTeX dependencies

  • Install TeX Live or BasicTeX; for Persian support install xepersian and appropriate fonts.

📁 Detailed repository layout

Top-level folders overview:

Folder Description Key Contents
02_Assignments/ Current coursework assignments CA phases, simulations
03_Past_Courses/ Archived coursework Sample solutions
04_Resources/ Course notes CN Source
6.829_OCW/ MIT OCW materials (Empty)
Books/ Reference books LogBook
CAs_last_term/ Last term assignments Qt game
Exams/ Exams and quizzes WireShark Quiz
HomeWorks/ Homework sets HW1-HW6
LatexTemplate/ Report templates Persian support
Reports/ Additional reports LaTeX files
Slides/ Lecture slides CH1-CH6, tutorials
tutorials/ P4 exercises Mininet setups
University_Assignments/ External uni assignments DNS, routing

Per-assignment READMEs

  • Each assignment folder contains its own README with specific reproduction steps — read it first.

02_Assignments

This folder contains the main assignments for the current term.

CA_phase0

  • Location: 02_Assignments/CA_phase0
  • Contents: Basic setup, description, and initial report.
  • README: CA_phase0/README.md
  • Usage: Follow the description for initial setup.

CA_phase1 — TCP Tahoe / Reno / Vegas Comparison

Location: 02_Assignments/CA_phase1

Goal: Compare TCP variants on a dumbbell topology using NS-2, parse traces and produce a LaTeX report with plots and aggregated tables.

Topology Diagram:

graph LR
    N0[TCP Src] --> R1[Router1]
    N1[UDP Src] --> R1
    R1 --> R2[Router2]  // Bottleneck
    R2 --> N3[TCP Sink]
    R2 --> N4[UDP Sink]

Important scripts and purpose:

  • codes/tcp_dumbbell.tcl — OTcl topology and tracing (flags: -proto, -run, -seed, -simtime, -trace, -summary, -varMin, -varMax).
  • codes/run_experiments.py — driver: iterates protocols and runs, spawns ns with tcp_dumbbell.tcl, calls analyzer, aggregates metrics and produces plots.
  • codes/analyze_trace.py — trace parser that reads .tr files and .txt summaries to produce per-run JSON metrics (throughput_bps, recv_bytes, recv_packets, sent_packets, drops, loss_rate, srtt_seconds).
  • report/ — LaTeX sources that include generated PNG plots and results/summary_table.tex.
  • run_all.sh — top-level convenience wrapper: runs smoke pipeline and builds the report (see file header for behavior).

Full reproduction (recommended):

  1. Ensure prerequisites are installed (see "Prerequisites and installation").
  2. From 02_Assignments/CA_phase1 run the full experiments:
cd 02_Assignments/CA_phase1/codes
python3 run_experiments.py --runs 10 --simtime 1000 --out ../results_full
  1. After runs finish, inspect ../results_full and regenerate the report:
cd ../report && latexmk -pdf report.tex

Common optional flags (run_experiments.py):

  • --ns-path PATH — point to custom ns-2 binary
  • --runs N — number of independent runs per protocol (default 10)
  • --simtime SECONDS — simulation length (default 1000)
  • --out PATH — output directory
  • --skip-sim — skip simulation stage; parse existing traces and re-generate plots
  • --bin-size FLOAT — throughput aggregation bin size (seconds)
  • --queue-sample FLOAT — queue sampling interval (seconds)

Outputs and file formats

  • results/<Protocol>/runX.tr — raw ns-2 trace (event-based)
  • results/<Protocol>/runX.txt — human-readable summary written by OTcl script
  • results/<Protocol>/runX_metrics.json — parsed metrics (per-run JSON)
  • results/aggregate.json — aggregated means across runs
  • results/plots/*.png — plots used by report (throughput, RTT, loss, CDFs, queue occupancy)
  • results/summary_table.tex — LaTeX table inserted into the report

Example JSON schema (per-run metrics):

{
  "trace": "results/Tahoe/run1.tr",
  "duration_seconds": 1000,
  "flows": {
    "1": {
      "throughput_bps": 117000,
      "recv_bytes": 14625000,
      "recv_packets": 14625,
      "sent_packets": 14700,
      "drops": 625,
      "loss_rate": 0.0426,
      "srtt_seconds": 0.450
    },
    "2": { ... }
  }
}

Tips for successful runs

  • Prefer Linux for NS-2 simulations (ns-allinone builds easier).
  • Use --skip-sim to debug parsing/plotting after you have traces.
  • Keep results/ per-experiment and do not commit large results_full/ into git; package outputs separately for submission.

CA_phase2 — TCP-Friendly UDP (TFRC-like) Project

Location: 02_Assignments/CA_phase2

Goal: Implement a TCP-friendly rate control mechanism for UDP flows in NS-2 and evaluate it in a dumbbell topology.

Topology Diagram (same as CA_phase1):

graph LR
    N0[TCP Src] --> R1[Router1]
    N1[UDP Src] --> R1
    R1 --> R2[Router2]  // Bottleneck
    R2 --> N3[TCP Sink]
    R2 --> N4[UDP Sink]

Layout:

  • code/ — simulation code, analysis scripts, generated outputs
    • project2.tcl — main NS-2 simulation script (three scenarios)
    • run_complete_analysis.sh — runner for simulations, analysis, and visualization
    • scripts/ — Python/AWK scripts for analysis and plotting
    • plots/ — generated plots
    • logs/ — simulation logs
    • results/ — textual summaries
  • report/ — LaTeX report and bibliography
  • description/ — project prompt
  • ns-allinone-2.36.rc2/ — local NS-2 distribution

Quick start:

cd 02_Assignments/CA_phase2
./run_all.sh

This runs simulations, generates plots, and builds the report.

Hyperparameters: Change in code/project2.tcl (e.g., rates, intervals).

CA_PHASE2_mininet

  • Location: 02_Assignments/CA_PHASE2_mininet
  • Contents: P4-based Mininet experiments, Docker setup, codes for simple_int.p4, send/receive scripts.
  • Usage: Follow Codes/README.md for running P4 exercises.

Other_phases_need_to_be

Phase3

  • Location: 02_Assignments/Other_phases_need_to_be/Phase3
  • Contents: Distance vector routing implementation in C++, AODV simulation in NS-2, analysis scripts.
  • Usage: Run make to build, ./run_sweep.sh for experiments.

Phase4

  • Location: 02_Assignments/Other_phases_need_to_be/Phase4
  • Contents: Various routing algorithms (link state, path vector, etc.), wireless simulations, energy-aware AODV.
  • Usage: Use Makefiles and scripts for building and running simulations.

📜 03_Past_Courses

Archived coursework from previous terms, including sample solutions, code, and reports for reference and learning.

🏫 CN-Spring02

  • CAs/: Computer Assignments with sample solutions.

    • V1/: Advanced implementations (e.g., Socket Programming in C++, Wireless LAN Simulation with NS-3, Routing Protocols, TCP Congestion Control).
    • V2/: Alternative versions with code and documentation.
  • HWs/: Homework assignments with descriptions and solutions.

  • Midterm/: Midterm exam materials.

Key Technologies: C++, NS-3, TCL, LaTeX.

Usage: Review solutions for best practices; run code with provided Makefiles.

📝 HWs_last_term

  • Homework from the last term, covering topics like networking fundamentals, protocols, and implementations.

Contents: Descriptions, starter code, reports.


📖 04_Resources

  • CN Source/: Supplementary course notes, slides, and resources on Computer Networks topics (e.g., TCP/IP stack, routing algorithms).

6.829_OCW

MIT 6.829 OCW materials (currently empty).


Books

Reference materials for Computer Networks.

  • LogBook/: Personal notes, logs, and study aids on course topics, experiments, and concepts.

Usage: Use for quick references or to track learning progress.


CAs_last_term

Computer assignments from the last term.

  • CA1/: Qt-based multiplayer game with networking (TCP/UDP for communication).
    • base_codes/: Source code and assets.
    • description/: Assignment details.
    • release/: Compiled binaries and resources.

Key Technologies: Qt (C++), TCP/UDP sockets.

How to Run: Install Qt, compile with qmake, run the game executable.

Insights: Demonstrates real-time networking in games.


Exams

Exam materials for assessment and review.

  • Exams/: Final or other exam papers (currently empty).
  • midterm/: Midterm exam questions and solutions.
  • WireShark Quiz/: Quizzes on packet analysis using Wireshark.

Usage: Study for exams, practice Wireshark skills.


HomeWorks

Homework assignments from HW1 to HW6.

  • HW1/ — 🌐 Basic networking concepts (OSI, TCP/IP).
  • HW2/ — 🖥️ Web server implementation (multithreaded Python).
  • HW3/ — 📡 Reliable data transfer (RDT) protocols (stop-and-wait, GBN).
  • HW4/ — 🛤️ Distance vector routing (C implementation).
  • HW5/ — 🔍 Network analysis, traceroute (Python).
  • HW6/ — 🚀 Advanced topics, deep research.

Each HW folder contains descriptions, starter code, and reports.


LatexTemplate

LaTeX templates for academic reports, with Persian language support.

  • Template - Student/: Main template folder.
    • LaTeX_Common/: Common LaTeX utilities and styles.
    • Template - Student/: Student-specific template files.

Usage: Use for writing reports in LaTeX, supports xepersian for Persian text.


Reports

Generated reports and LaTeX documents for various topics.

  • 13.tex, 14.tex, 4_4__5_1__5_2.tex: Individual report files.
  • CH3/: Chapter 3 report (chapter3.tex).
  • Day14/: Day 14 report (Day14.tex), with LaTeX_Common/ and Template - Student/.

Usage: Compile with LaTeX for PDF reports.


Slides

Lecture slides and presentation materials.

  • CH1/ to CH6/: Slides for each chapter.
  • lec/: Lecture materials, including estr/.
  • Lecture Slides/: Main lecture presentations.
  • PYQs/: Previous Year Questions.
  • tutorial/: Tutorial slides (T01/ to T12/).
  • Workshop/: Workshop materials (Workshop - 1/ to 3/).

Usage: View or present using PDF viewers.


tutorials

Tutorial exercises and labs.

  • exercises/: Exercise materials.
    • simple_int/: Simple P4 program for packet introspection.

Usage: Follow tutorials for P4 and Mininet learning.


🌍 University_Assignments

Collection of assignments from various universities' Computer Networks courses:

  • Advanced_CN_Assignments/ — 🔐 DNS resolution, DNSSEC validation, network traffic analysis, dynamic routing protocols.
  • CN_Lab_Assignments/ — 🔌 Socket programming (TCP/UDP), inter-process communication (pipes, queues), device drivers, RPC.
  • Course_Network_Assignment/ — 🖥️ Client-server architectures, reliable data transfer, routing algorithms, P4 SDN.
  • CUHK_CSCI4430/ — 🏗️ Network topology design, transport protocols, content delivery networks (CDN).
  • IITD_CN_Assignments/ — 📊 NS-3 simulations for congestion control, network analysis.
  • IITD_COL334_CN/ — 🌐 Internet architecture, distributed file transfer, reliable transport.
  • UoA_COMPSCI7039_CNA/ — 🚀 Non-blocking web servers, alternating bit/Go-Back-N, routing (DV, Poison Reverse).

Each includes code, reports, and detailed READMEs. Great for comparative learning!


LaTeX pipeline and Persian text handling

This repo contains helper scripts to wrap ASCII/English runs in Persian LaTeX with \lr{...} safely.

Scripts:

  • scripts/latex_lr_wrapper.py — masking-based safe wrapper (preferred). Default: reads 02_Assignments/CA_phase1/report/report_per.tex and writes report_per_lr.tex.
  • scripts/wrap_english_lr.py — heuristic wrapper (fast but riskier).
  • scripts/add_lr_simple.py — simpler wrapper used during development.
  • scripts/fix_lr_artifacts.py — post-fix aggressive removals to prevent \lr{} inside command arguments and table preambles; keep backups.

Recommended flow (safe):

cp 02_Assignments/CA_phase1/report/report_per.tex 02_Assignments/CA_phase1/report/report_per.tex.bak
python3 scripts/latex_lr_wrapper.py               # produces report_per_lr.tex
# inspect report_per_lr.tex, then
python3 scripts/fix_lr_artifacts.py report_per_lr.tex
# compile with xelatex if Persian fonts required
cd 02_Assignments/CA_phase1/report
xelatex report_per_fixed.fixed.tex
# run twice to resolve references

If compilation fails, open the .log and paste the first error and surrounding lines in an issue — the wrapper/fixer can be adjusted.


Troubleshooting (common errors & fixes)

  1. "ns: command not found"
  • Solution: install ns-2 or provide --ns-path /path/to/ns.
  1. Matplotlib import errors
  • Solution: pip3 install matplotlib and ensure Python3 used by scripts is same as python3 executable.
  1. LaTeX errors caused by \lr{} inside table preamble or macro arguments
  • Solution: run scripts/fix_lr_artifacts.py and inspect the fixed file; revert to .bak if necessary.
  1. Missing PNGs in report
  • Ensure results/plots/*.png exist; re-run experiments with --skip-sim disabled or regenerate plots using --skip-sim if traces are present.
  1. Permission denied when running scripts
  • Run: chmod +x run_all.sh or use python3 script.py directly.
  1. For P4/Mininet: Ensure Docker is installed and run start_docker.sh.

If you encounter a different error, paste the exact error and the few lines of context; I will update scripts or instructions accordingly.


Contribution & git workflow

  • Branching: git checkout -b feature/<short-desc> for new features
  • Commit messages: be explicit about why the change was made

Example commit message:

feat: add smoke-run helper and update README for CA_phase1

- Adds run_all.sh wrapper
- Documents reproduction steps and expected outputs
  • Avoid committing large outputs (results_full/, ns-allinone*) — add them to .gitignore and create separate submission bundles containing only required artifacts.

Packaging results for submission

Recommended minimal submission contents in a ZIP:

  • codes/ (scripts used to run experiments)
  • report/ (LaTeX source and compiled report.pdf)
  • results/plots/, results/aggregate.json, results/summary_table.tex
  • small README with reproduction steps and git commit hash

Create ZIP example:

git rev-parse --short HEAD > COMMIT_HASH
zip -r submission.zip codes report results/plots results/aggregate.json COMMIT_HASH

Last updated: February 2026 — maintained by course author

Total size
3.24 GB
Files
21,117
Last updated
Sep 11
Pre-warmed CDN
US EU US EU

Contributors