- Overview
- Features
- Architecture
- Quick Start
- Installation
- Usage Guide
- Configuration
- API Reference
- Examples
- Troubleshooting
- Contributing
- License
IoTher is a production-grade, real-time IoT device simulator that implements MQTT-style publish/subscribe messaging. Built in C/C++, it allows developers to simulate complex IoT ecosystems with multiple devices, virtual sensors, and real-time data flow - all without requiring an internet connection or physical hardware.
| Problem | IoTher Solution |
|---|---|
| Expensive IoT hardware | Virtual sensors that behave like real ones |
| Internet dependency | Complete local simulation |
| Slow development cycles | Instant device spawning and testing |
| Complex debugging | Real-time terminal dashboard with colored output |
| Limited testing scenarios | Unlimited virtual devices with configurable behaviors |
- MQTT-Style Protocol: Full publish/subscribe pattern with topic-based routing
- Virtual Sensors: Temperature, humidity, pressure, light, motion, power consumption
- Multi-Device Simulation: Run 100+ devices simultaneously as threads
- Real-Time Dashboard: Live monitoring with colored terminal output
- Zero Internet: Complete local simulation environment
- Comprehensive Logging: All messages and metrics logged for analysis
| Feature | Implementation |
|---|---|
| Language | C (broker) + C++11 (client) |
| Concurrency | POSIX threads with mutex locking |
| Network | TCP sockets, non-blocking I/O |
| Protocol | Custom MQTT-style binary/text |
| Performance | < 1ms latency for local messages |
| Memory | ~5MB for 100 connected devices |
-
Environmental Sensor Node
- Temperature (18-35°C)
- Humidity (30-80%)
- Barometric Pressure (980-1020 hPa)
-
HVAC Controller
- Temperature Setpoint (20-25°C)
- Fan Speed (0-100%)
- Climate control logic
-
Smart Lighting System
- Luminosity (100-1000 lux)
- Power Consumption (10-150W)
- Ambient light sensing
-
Security Hub
- Motion detection (binary)
- Door/Window sensors
- Alert generation
┌─────────────────────────────────────────────────────────────┐
│ TERMINAL UI │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ IoTher Dashboard (Optional) │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
▲
│ WebSocket/HTTP
│
┌─────────────────────────────────────────────────────────────┐
│ MQTT-STYLE BROKER │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ Connection │ │ Topic │ │ Message │ │
│ │ Manager │ │ Router │ │ Queue │ │
│ └────────────┘ └────────────┘ └────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────────────────────────────────────┐ │
│ │ Thread Pool (100 clients) │ │
│ └──────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│Device 1 │ │Device 2 │ │Device 3 │ │Device N │
│(Sensors)│ │ (HVAC) │ │ (Light) │ │(Custom) │
└─────────┘ └─────────┘ └─────────┘ └─────────┘
Device → Broker → Topic Match → Subscribers
│ │ │ │
│ PUB │ │ │
├────────►│ │ │
│ │ Route │ │
│ ├─────────►│ │
│ │ │ Broadcast │
│ │ ├───────────►│
│ │ │ │
│ ACK │ │ │
│◄────────┤ │ │
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install build-essential g++ make
# Fedora/RHEL
sudo dnf groupinstall "Development Tools"
sudo dnf install gcc-c++ make
# Arch Linux
sudo pacman -S base-devel gcc
# macOS
xcode-select --install
brew install gcc makegit clone https://github.com/yourusername/iother.git && cd iother && make && ./scripts/run.sh# 1. Clone the repository
git clone https://github.com/yourusername/iother.git
cd iother
# 2. Build the project
make clean
make all
# 3. Run the simulation
./scripts/run.sh
# 4. Stop the simulation (Ctrl+C in each terminal)# Build and install to /usr/local/bin
make install
# Now you can run from anywhere
iother_broker & # Run broker in background
iother_device # Run device simulator# Dockerfile
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y build-essential
COPY . /iother
WORKDIR /iother
RUN make
CMD ["./scripts/run.sh"]# Build Docker image
docker build -t iother:latest .
# Run container
docker run -it iother:latest# Show help
make help
# Build only broker
make broker
# Build only client
make client
# Run with specific device count
./src/client/iother_device --devices 5
# Run with custom config
./src/broker/iother_broker --config config/iother.confOnce the simulation is running, you can use these commands:
| Command | Action |
|---|---|
s |
Show all device statuses |
q |
Quit simulation |
p |
Pause data flow |
r |
Resume data flow |
c |
Clear dashboard |
h |
Show help |
// Create a custom device in C
IoTherDevice* device = iother_device_create("Custom_Sensor");
iother_add_sensor(device, "Temperature", "°C", "sensors/temp", 18.0, 35.0);
iother_subscribe(device, "commands/#");
iother_start(device);[broker]
port = 1883 # Listening port
max_clients = 100 # Maximum concurrent clients
log_file = iother.log # Log file path
enable_metrics = true # Enable performance metrics
heartbeat_interval = 30 # Heartbeat in seconds
[simulation]
default_publish_interval = 3000 # Default interval (ms)
enable_wildcards = true # Enable topic wildcards
enable_retained = false # Enable retained messages
max_queue_size = 1000 # Maximum message queue
[security]
enable_authentication = false # Enable client auth
allow_anonymous = true # Allow anonymous clients
max_connections_per_ip = 5 # Rate limiting
[dashboard]
enable = true # Enable dashboard
refresh_rate = 2 # Dashboard refresh (seconds)
max_history = 100 # Messages per topicexport IOTHER_PORT=1883
export IOTHER_MAX_CLIENTS=200
export IOTHER_LOG_LEVEL=debug
export IOTHER_CONFIG_PATH=/etc/iother/config// Initialize broker
int iother_broker_init(int port, int max_clients);
// Publish message
int iother_publish(const char* topic, const char* message);
// Subscribe client
int iother_subscribe(int client_id, const char* topic);
// Get statistics
BrokerStats iother_get_stats(void);class IoTherDevice {
public:
// Constructor
IoTherDevice(const std::string& id, const std::string& type);
// Add virtual sensor
void addSensor(const Sensor& sensor);
// Subscribe to topic
void subscribe(const std::string& topic);
// Start device
void start();
// Send custom message
void sendCustomMessage(const std::string& topic, const std::string& message);
// Get device status
DeviceStatus getStatus();
};# Publish message format
PUB:<topic>:<message>
# Subscribe message format
SUB:<topic>
# Unsubscribe message format
UNSUB:<topic>
# Received message format
MSG:<topic>:<publisher>:<message>
# Control messages
PING, PONG, STATUS, DISCONNECT
#include "device_simulator.h"
int main() {
IoTherDevice device("Custom_Sensor", "Temperature");
// Add sensor with custom range and interval
Sensor temp("Temperature", "°C", "sensors/temp",
15.0, 40.0, // Min/Max
1000); // Publish every 1 second
device.addSensor(temp);
device.subscribe("commands/temp");
device.start();
// Keep running
std::cin.get();
return 0;
}// Alert generator
void checkThresholds(double temperature) {
if (temperature > 35.0) {
device.sendCustomMessage("alerts/high_temp",
"Temperature exceeds threshold: " +
std::to_string(temperature));
}
}# Python dashboard using the same protocol
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 1883))
sock.send(b"SUB:#")
while True:
data = sock.recv(1024).decode()
if data.startswith("MSG:"):
print(f"Received: {data}")| Issue | Solution |
|---|---|
| "Address already in use" | Port 1883 is occupied. Kill existing process: pkill iother_broker |
| Build fails | Install build tools: sudo apt-get install build-essential |
| No output in terminal | Check if broker is running: `ps aux |
| High CPU usage | Reduce device count or increase publish intervals |
| Connection refused | Verify broker is running: `netstat -an |
# Run broker in debug mode
./src/broker/iother_broker --debug
# Enable verbose logging
export IOTHER_LOG_LEVEL=debug
./src/client/iother_device --verbose# Increase system limits
ulimit -n 4096
# Optimize for many devices
./src/broker/iother_broker --max-clients 500 --queue-size 5000| Metric | Value |
|---|---|
| Max Throughput | 50,000 msgs/sec |
| Avg Latency | < 1ms |
| Memory per Device | ~50KB |
| CPU per Device | < 0.1% |
| Max Devices | 1000+ |
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/iother.git
cd iother
# Install development dependencies
sudo apt-get install valgrind gdb clang-format
# Run tests
make test
# Check memory leaks
valgrind --leak-check=full ./src/broker/iother_broker- C: Follow C99 standard with POSIX extensions
- C++: Use C++11 features only
- Formatting: Run
clang-formatbefore committing - Comments: Document all public APIs
- Tests: Include unit tests for new features
- MQTT Protocol Specification for inspiration
- Open source community for tools and libraries
- All contributors who help IoTher breathe
Made with ❤️ for the IoT community
Let your devices breathe with IoTher