Skip to content

A C++-based cellular network simulator implementing 2G to 5G communication models using object-oriented principles.

Notifications You must be signed in to change notification settings

vaibhav-init/Cellular-network-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cellular Network Simulator

Project Diagram

Overview

This project is a C++-based cellular network simulator that models cellular communication systems using key OOP principles — inheritance, polymorphism, abstraction, and data hiding.

The simulator represents a simplified cellular framework consisting of:

  • UserDevice — Represents individual user connections with service types (DATA/VOICE).
  • CellTower — Manages frequency allocation and user capacity per channel.
  • CellularCore — Handles message generation and overall communication control with capacity limits.

Current Implementation Status

Part 1: Simulation Framework

  • UserDevice: Encapsulates user information with private data members and getter/setter methods.
  • CellTower: Manages connected users and channel allocation tracking.
  • CellularCore: Handles message capacity and user management.

Part 2: 2G Communication

  • TwoG Class: Derived from CellularSystem.
  • TDMA: 16 users per 200 kHz frequency band.
  • Capacity: 80 users (1 MHz total / 200 kHz * 16 users).
  • Messages: 5 (Data), 15 (Voice).

Part 3: 3G Communication

  • ThreeG Class: Derived from CellularSystem.
  • CDMA: 32 users per 200 kHz frequency band.
  • Capacity: 160 users (1 MHz total / 200 kHz * 32 users).
  • Messages: 10 per user.

Part 4: 4G Communication

  • FourG Class: Derived from CellularSystem.
  • OFDM: 30 users per 10 kHz sub-channel.
  • MIMO: Supports up to 4 antennas in parallel.
  • Capacity: 12,000 users (1 MHz / 10 kHz * 30 users * 4 antennas).
  • Messages: 10 per user.

Part 5: 5G Communication

  • FiveG Class: Derived from CellularSystem.
  • High Frequency: Operates at 1800 MHz with 10 MHz bandwidth.
  • Massive MIMO: Supports up to 16 antennas.
  • Capacity: 4,800 users (10 MHz / 1 MHz * 30 users * 16 antennas).
  • Messages: 10 per user.

OOP Features Used

  • Encapsulation: Private data members with getter/setter methods
  • Inheritance: CellularSystem base class with specific generation derived classes
  • Polymorphism: Virtual functions for generation-specific behavior (e.g., calculateMaxUsers)
  • Exception Handling: Custom SimulatorException for error management
  • Templates: Custom Vector<T> and SharedPtr<T> classes

Build Instructions

Prerequisites

  • C++17 compatible compiler (g++ recommended)
  • Make utility

Compilation

# Build debug version (with debug symbols)
make debug

# Build optimized version (with -O3 optimization)
make release

# Build both versions
make all

# Clean build artifacts
make clean

# Run the simulator (builds release if needed)
make run

Manual Running

After compilation, you can run the simulator directly using the generated binaries:

Release Version (Recommended):

./build/release/cellular_sim

Debug Version:

./build/debug/cellular_sim_debug

Output Binaries

  • Debug build: build/debug/cellular_sim_debug
  • Release build: build/release/cellular_sim

Input Format

The program uses an interactive command-line interface:

  1. Select Generation: Choose between 2G, 3G, 4G, or 5G.
  2. Core Capacity: Enter the message processing capacity (messages/sec) or 0 to auto-calculate for full potential.
  3. Number of Users: Enter the total number of users to simulate.
  4. Data Users: Enter the number of users requesting DATA service (remaining will be VOICE).

Example Session

Select generation:
 1) 2G
 2) 3G
 3) 4G
 4) 5G
Enter choice (1-4): 1
Enter core capacity (messages/sec) or 0 to auto-calc for full support: 0
Enter number of users: 50
Enter number of DATA users (0 - 50): 25

Output Format

The simulation outputs:

  • System Configuration: Bandwidth, channels, and theoretical capacity.
  • Allocation Results: Number of successfully connected users and core utilization.
  • Required Cores: Calculation of cores needed for full potential (for 4G/5G).
  • Channel Allocation: Detailed breakdown of users per channel.
  • First Channel Details: Specific list of users in the first frequency band.
  • User Details: List of all connected users with their assigned channels and frequencies.

File Structure

cellular_network/
├── header/                   # Header files
│   ├── UserDevice.h
│   ├── CellTower.h
│   ├── CellularCore.h
│   ├── CellularSystem.h
│   ├── TwoG.h, ThreeG.h, FourG.h, FiveG.h
│   ├── String.h              # Custom string class
│   ├── Vector.h              # Custom vector template
│   ├── SharedPtr.h           # Custom smart pointer template
│   ├── Thread.h              # Threading support
│   └── Mutex.h               # Synchronization primitives
├── src/                      # Source files
│   ├── UserDevice.cpp
│   ├── CellTower.cpp
│   ├── CellularCore.cpp
│   ├── CellularSystem.cpp
│   ├── TwoG.cpp, ThreeG.cpp, FourG.cpp, FiveG.cpp
│   ├── String.cpp
│   └── syscall_wrapper.cpp
├── io_files/                 # I/O library
│   ├── basicIO.h
│   ├── basicIO.cpp
│   └── syscall.S
├── main.cpp                  # Main simulation program
├── Makefile                  # Build configuration
└── README.md                 # This file

Implementation Notes

No Standard Library Usage

This project implements all required functionality from scratch:

  • String class: Custom implementation replacing std::string
  • Vector class: Template-based dynamic array replacing std::vector
  • SharedPtr class: Smart pointer implementation replacing std::shared_ptr
  • Threading: Custom wrapper classes for pthread
  • basicIO: Custom I/O library

Code Attribution

This code is original work. No external code sources were used.

About

A C++-based cellular network simulator implementing 2G to 5G communication models using object-oriented principles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •