A C# console application that simulates the Token Ring network protocol, featuring token passing, concurrent node communication, CRC-based error detection, binary data encoding, and random noise injection.
This project was originally developed as a university assignment for the Computer Networks course, using C# and .NET.
The objective was to simulate the Token Ring protocol at the Data Link Layer by implementing a logical ring topology with concurrent nodes, token passing, frame transmission, CRC-based error detection, and random noise injection to emulate transmission errors.
This repository contains a refactored version of the original assignment, featuring cleaner code, improved readability, modern C# syntax, better object-oriented design, and enhanced project documentation while preserving the original simulation behavior.
The assignment required implementing a console-based simulation of the Token Ring protocol with the following requirements:
- Simulate a logical ring consisting of at least 10 concurrent nodes.
- Implement continuous token passing when the network is idle.
- Allow message transmission only after capturing the free token.
- Simulate the complete frame lifecycle (source → destination → source).
- Implement random bit corruption on a predefined communication link.
- Detect transmission errors using the CRC (Cyclic Redundancy Check) algorithm with the generator polynomial
1011. - Display the intermediate CRC calculation steps for debugging purposes.
-
🔄 Token Ring Simulation
- Logical ring topology
- Network consisting of 15 concurrent nodes
- Continuous token circulation
- Token capture and release
-
📦 Frame Transmission
- Source and destination addressing
- Payload transmission between nodes
- Complete frame lifecycle
- Transmission status confirmation
-
🛡️ CRC Error Detection
- Binary payload conversion
- CRC generation using the
1011generator polynomial - Frame integrity verification
- Optional CRC debugging mode
-
⚡ Noise Simulation
- Random bit flipping
- Predefined faulty communication link
- Binary payload visualization
- Transmission error detection
-
🧵 Concurrent Execution
- Independent node execution using Tasks
- Thread-safe frame exchange with
BlockingCollection - Continuous network simulation
-
🖥️ Console Visualization
- Color-coded event logging
- Token passing visualization
- Message transmission logs
- CRC calculation output
The following diagram illustrates the relationships between the core components used in the Token Ring protocol simulation.
Program
│
▼
Node
┌──────────┬────┴────┬──────────┐
▼ ▼ ▼ ▼
Frame CRC Noise BinaryConverter
TokenRingProtocolSimulation/
├── .gitignore
├── TokenRingProtocolSimulation.sln
│
├── Images/
│ ├── 01-token_ring_simulation.png
│ ├── 02-successful_transmission.png
│ ├── 03-crc_debug_mode.png
│ └── 04-crc_error_detection.gif
│
└── TokenRingProtocolSimulation/
├── BinaryConverter.cs
├── CRC.cs
├── Frame.cs
├── Node.cs
├── Noise.cs
├── Program.cs
└── TokenRingProtocolSimulation.csproj
- C# 12.0
- .NET 8
- Task Parallel Library (TPL)
- Async / Await
- BlockingCollection
- Visual Studio 2022
- Token Ring network protocol simulation
- Concurrent node communication using Tasks
- CRC-based error detection and verification
- Random bit corruption on a predefined faulty link
- Refactored codebase with modern C# practices
-
Object-Oriented Programming (OOP)
The simulation is organized into dedicated classes (Node,Frame,CRC,Noise, andBinaryConverter), each with a clear responsibility. -
Concurrency
Multiple network nodes execute concurrently usingTask, simulating independent stations communicating over a shared network. -
Thread-Safe Communication
BlockingCollectionis used to safely exchange frames between concurrent nodes without race conditions. -
Asynchronous Programming
asyncandawaitare used to simulate network latency while keeping the application responsive. -
Token Ring Protocol
The project demonstrates controlled medium access through continuous token passing, ensuring that only the node holding the token can transmit data. -
Frame-Based Communication
Messages are encapsulated into frames containing source and destination addresses, payload, CRC, and transmission status information. -
CRC (Cyclic Redundancy Check)
A simplified CRC algorithm generates and verifies the Frame Check Sequence (FCS) using polynomial division with the generator polynomial1011. -
Binary Data Encoding
ASCII messages are converted into binary form before transmission and CRC calculation. -
Network Fault Simulation
A predefined faulty communication link randomly flips a payload bit to simulate transmission errors. -
Error Detection
Corrupted frames are detected through CRC verification, demonstrating how transmission errors can be identified without correcting the data. -
Encapsulation
Internal node state and frame information are managed through properties and controlled access to class members.
The simulation starts by creating a logical ring of interconnected nodes. A free token continuously circulates through the network until one of the nodes captures it to initiate a transmission.
A node captures the free token, creates a data frame, computes the CRC checksum, and sends the message to the destination node. After successful delivery and CRC verification, the sender releases a new free token.
CRC Debug Mode displays the complete polynomial division process used to generate the Frame Check Sequence (FCS), showing every XOR operation together with the final remainder.
This demonstration shows a frame passing through the predefined faulty network link. A random bit is flipped, the receiver recomputes the CRC, detects a non-zero remainder, reports a CRC error, and the sender marks the transmission as failed before releasing the token.
- Windows 10 / Windows 11
- .NET 8 SDK
- Visual Studio 2022 (recommended)
- Clone the repository.
git clone <repository-url>-
Open the solution in Visual Studio 2022.
-
Restore the NuGet packages (if required).
-
Build the solution.
Build → Build Solution
or simply press:
Ctrl + Shift + B
- Run the application.
F5
or click Start in Visual Studio.
- When prompted, choose whether to enable CRC Debug Mode by entering:
y
to display the complete CRC calculation process, or
n
to run the standard simulation.
- The simulation creates a logical Token Ring network, circulates a free token between nodes, performs frame transmissions, simulates transmission errors on the predefined faulty link, and verifies frame integrity using the CRC algorithm.
This project is released under the MIT License.



