This repository contains a comprehensive benchmarking suite for comparing different Inter-Process Communication (IPC) mechanisms in C. The project implements and evaluates three primary IPC methods: Message Queues, Shared Memory, and UNIX Domain Sockets.
This project provides practical implementations and performance analysis of different IPC mechanisms, measuring both latency and throughput characteristics across varying data sizes. Each implementation includes sender/receiver programs that can handle both small messages (latency testing) and large data transfers (throughput testing).
## 🚀 Quick Start
### Prerequisites
- GCC compiler
- POSIX-compliant system (Linux)
- Python 3.x with matplotlib (for plotting)
### Compilation
Each IPC method can be compiled independently:
#### Message Queues
```bash
cd MQ/
gcc sender.c -o sender -lrt
gcc receiver.c -o receiver -lrt
cd SM/
gcc writer.c -o writer -lrt
gcc reader.c -o reader -lrtcd Socket/
gcc sender.c -o sender
gcc receiver.c -o receiverFor each IPC method:
- Start the receiver/reader in one terminal
- Start the sender/writer in another terminal
- Follow the interactive menu to run latency or throughput tests
- Shared Memory: Highest throughput (~7GB/s), lowest latency for large data
- UNIX Domain Sockets: Moderate performance, good balance of features
- Message Queues: Lower throughput but excellent for small message passing
- Latency Testing: Measures round-trip time for small messages
- Throughput Testing: Measures data transfer rates for large payloads
- Scalable Message Sizes: Supports messages from 1KB to 100MB
- Chunking Support: Automatic message segmentation for size limits
- Uses POSIX message queues (
mqueue.h) - Implements automatic chunking for large messages
- Maximum single message: 8KB (system limit)
- Handles messages up to 100MB through chunking
- Uses POSIX shared memory (
shm_open,mmap) - Atomic operations for synchronization
- Memory barriers for data consistency
- Supports up to 110MB shared region
- Stream-based communication
- Built-in flow control and reliability
- No message size limitations
- Connection-oriented protocol
The Plots/ directory contains:
- Performance comparison graphs
- Latency vs. block size analysis
- Throughput vs. block size analysis
- Python script for generating custom plots
Generate plots:
cd Plots/
python3 plots.pyThis project demonstrates:
- System Programming: Low-level IPC implementations
- Performance Analysis: Benchmarking methodologies
- Concurrency: Multi-process synchronization
- POSIX Standards: Cross-platform system programming
- Data Visualization: Performance metric presentation
Test small message round-trip times to measure communication overhead.
Transfer large data blocks to measure maximum data transfer rates.
Run the same tests across all three IPC methods to compare performance characteristics.
Each IPC method includes:
- Interactive menu system
- Configurable message sizes
- Performance timing measurements
- Error handling and cleanup
- Detailed status reporting
- Individual README files in each subdirectory
- Inline code comments
- Comprehensive report in
Report/directory - Performance analysis and conclusions
This is an academic project demonstrating IPC concepts. Feel free to:
- Extend the benchmarking suite
- Add new IPC mechanisms
- Improve performance measurements
- Enhance visualization capabilities
This project is for educational purposes. Please refer to your institution's academic policies regarding code sharing and attribution.
Author: Harish Hatmode
Course: Networks for AI/ML
Assignment: IPC Performance Analysis