| app1_server.dSYM/Contents | ||
| docker | ||
| k8s | ||
| scripts | ||
| app1_server.c | ||
| app2_client.c | ||
| app3_hybrid.c | ||
| app4_monitor.c | ||
| app5_display.c | ||
| build-images.sh | ||
| cleanup-k8s.sh | ||
| create-kind-cluster.sh | ||
| create-registry-secret.sh | ||
| deploy-to-k8s.sh | ||
| diagnose-registry.sh | ||
| DISPLAY-APP-GUIDE.md | ||
| find-rhel9-repo.sh | ||
| install-rhel9-prerequisites.sh | ||
| kind-cluster-config.yaml | ||
| kubectl | ||
| load-images-to-kind.sh | ||
| Makefile | ||
| Makefile.container | ||
| motif_rpc.h | ||
| motif_rpc.x | ||
| motif_rpc_clnt.c | ||
| motif_rpc_svc.c | ||
| motif_rpc_xdr.c | ||
| overview-k8s-system.sh | ||
| push-images-to-registry.sh | ||
| README-kubernetes.md | ||
| README.md | ||
| RHEL9-TROUBLESHOOTING.md | ||
| rpc_compat.c | ||
| setup-kind-cluster.sh | ||
| test-podman-system.sh | ||
| test_system.sh | ||
| TESTING-GUIDE.md | ||
| verify-registry.sh | ||
SUN-RPC Motif Communication System
A distributed application system featuring 4 different applications that communicate using SUN-RPC (ONC-RPC) messages over UDP unicast and multicast protocols.
🚀 Quick Start
OCI Registry Deployment (Recommended):
# 1. Install RHEL9 host prerequisites first
./install-rhel9-prerequisites.sh
# 2. Build images with registry tags
./build-images.sh
# 3. Push to OCI registry
./push-images-to-registry.sh
# 4. Create registry pull secret for Kubernetes
./create-registry-secret.sh
# 5. Deploy to any Kubernetes cluster
./deploy-to-k8s.sh
Local KIND Deployment (Alternative):
# 1. Install prerequisites
./install-rhel9-prerequisites.sh
# 2. Build and deploy locally
IMAGE_VERSION=local ./build-images.sh
./create-kind-cluster.sh
./load-images-to-kind.sh
./deploy-to-k8s.sh
🌐 OCI Registry: code.it-speeltuin.eu/huub
🌟 Now powered by Podman for enhanced security and rootless containers!
See README-kubernetes.md for complete Kubernetes instructions.
Architecture Overview
The system consists of 4 applications that demonstrate different communication patterns:
-
Application 1 (app1_server) - Main RPC Server
- Central server that handles RPC requests from other applications
- Supports UDP unicast for point-to-point communication
- Broadcasts messages via UDP multicast
- Manages client registration and status tracking
-
Application 2 (app2_client) - RPC Client
- Pure client application that sends RPC requests
- Interactive menu for user operations
- Listens for multicast broadcasts
- Sends periodic heartbeats
-
Application 3 (app3_hybrid) - Hybrid Client/Server
- Acts as both RPC client and server
- Can receive RPC calls while also making calls to other applications
- Dual-mode operation for complex communication patterns
- Threaded design for concurrent client/server operations
-
Application 4 (app4_monitor) - Monitoring/Logging Application
- Passive monitoring of all multicast traffic
- Logs all communications to file
- Periodic status polling of other applications
- Statistical reporting and analysis
Communication Protocols
SUN-RPC (ONC-RPC) Procedures
The system defines the following RPC procedures:
SEND_MESSAGE- Send a message between applicationsGET_STATUS- Retrieve application status informationSEND_HEARTBEAT- Send heartbeat for monitoringBROADCAST_MESSAGE- Broadcast message to all applicationsREGISTER_APP- Register application for multicast groupSHUTDOWN_NOTIFY- Notify about application shutdown
UDP Multicast
- Multicast Group: 224.0.0.1
- Multicast Port: 8888
- Used for broadcasting messages to all registered applications
- Monitored by the monitoring application for logging
Deployment Options
🐳 Kubernetes Deployment with Podman (Recommended)
For a complete distributed environment with RHEL9 UBI containers powered by Podman:
Quick Start:
# Build images with Podman, setup KIND cluster, and deploy
./build-images.sh && ./setup-kind-cluster.sh && ./deploy-to-k8s.sh
🌟 Features:
- Rootless containers for enhanced security
- Daemonless architecture - no Docker daemon required
- Enterprise-grade RHEL9 UBI base images
See README-kubernetes.md for detailed Kubernetes deployment instructions.
🖥️ Local macOS/Linux Build
Prerequisites:
- GCC compiler with C99 support
rpcgenutility (part of Sun RPC/ONC-RPC)- POSIX threads library
- Network Services Library (libnsl on Linux)
Build Instructions:
# Build all applications (Linux/macOS)
make all
# Or build individual components
make rpc-stubs # Generate RPC stubs from .x file
make app1_server
make app2_client # ⚠️ Has macOS compatibility issues
make app3_hybrid # ⚠️ Has macOS compatibility issues
make app4_monitor # ⚠️ Has macOS compatibility issues
# Clean build artifacts
make clean
Generated Files
The build process generates the following files from motif_rpc.x:
motif_rpc.h- RPC header definitionsmotif_rpc_clnt.c- Client stub functionsmotif_rpc_svc.c- Server stub functionsmotif_rpc_xdr.c- XDR serialization functions
Running the Applications
🐳 Kubernetes Deployment (Recommended)
The easiest way to run the complete system:
# Deploy to KIND cluster
./deploy-to-k8s.sh
# Monitor the system
kubectl get pods -n motif-rpc --watch
kubectl logs -f deployment/motif-server -n motif-rpc
🖥️ Local Execution (macOS/Linux)
Server Only (macOS Compatible):
./app1_server
Full System (Linux Recommended):
# Start the main server
./app1_server
# In separate terminals, start client applications
./app2_client <server_host>
./app3_hybrid <server_host>
./app4_monitor <server_host>
Note: Use localhost or 127.0.0.1 if running locally.
Step 3: Interact with Applications
Each client application provides an interactive menu:
App2 Client Menu:
- Send message to server
- Get server status
- Send broadcast message
- Send heartbeat
- Register for multicast
- Exit
App3 Hybrid Menu:
- Send message to main server
- Get main server status
- Send broadcast message
- Send heartbeat to main server
- Show local status
- Exit
App4 Monitor Menu:
- Show statistics
- Poll application status
- Send test broadcast
- Force heartbeat
- Exit
Communication Examples
Unicast RPC Communication
App2 Client ---[RPC SEND_MESSAGE]---> App1 Server
App2 Client <--[RPC Response]--------- App1 Server
Multicast Broadcasting
App2 Client ---[RPC BROADCAST]---> App1 Server
App1 Server ---[UDP Multicast]---> All Applications
Monitoring
All Apps ---[UDP Multicast]---> App4 Monitor
App4 Monitor ---[Log to File]---> motif_monitor.log
File Structure
sun-rpc-motif/
├── motif_rpc.x # RPC protocol definition
├── Makefile # Build configuration
├── app1_server.c # Main RPC server
├── app2_client.c # RPC client
├── app3_hybrid.c # Hybrid client/server
├── app4_monitor.c # Monitoring application
├── README.md # This documentation
└── Generated files:
├── motif_rpc.h # RPC header
├── motif_rpc_clnt.c # Client stubs
├── motif_rpc_svc.c # Server stubs
└── motif_rpc_xdr.c # XDR functions
Logging and Monitoring
Server Logs
- All applications log to stdout with timestamps
- Format:
[timestamp] APP_TYPE: message
Monitor Logs
- App4 Monitor logs all activity to
motif_monitor.log - Includes multicast messages, heartbeats, and status polls
- Provides statistics on message counts and uptime
Status Information
- Each application maintains status including:
- Application ID and name
- Current status (OK, ERROR, BUSY, SHUTDOWN)
- Uptime information
- Message counters
Network Configuration
Firewall Considerations
- Ensure UDP ports are open for RPC communication
- Multicast group 224.0.0.1 must be accessible
- Port 8888 used for multicast communication
Multi-Host Deployment
- Replace
localhostwith actual hostnames/IPs - Ensure all hosts can reach each other via UDP
- Multicast routing must be configured for cross-subnet operation
Implementation Status
✅ Working Components
- 🐳 Kubernetes Deployment: Complete containerized system with RHEL9 UBI + Podman
- 🖥️ RPC Server: Fully functional on all platforms (Linux/macOS)
- 📡 Protocol Definition: Complete SUN-RPC interface defined in
motif_rpc.x - 🔧 Build System: Multi-platform Makefile + Podman builds
- 📚 Documentation: Complete system documentation
🌟 Kubernetes + Podman Features
- Rootless containers for enhanced security
- Daemonless architecture - no background daemon required
- Multi-container deployment with service discovery
- Persistent logging with volume mounts
- Health checks and resource limits
- External access via NodePort services
- Auto-scaling and rolling updates
⚠️ macOS Compatibility (Local Build)
The client applications have compilation issues on macOS due to RPC implementation differences. Use Kubernetes deployment for full functionality.
Quick Test
Kubernetes with Podman (Recommended):
# Full system test with Podman-powered containers
./deploy-to-k8s.sh && kubectl get pods -n motif-rpc --watch
macOS (Server Only):
./test_system.sh
Troubleshooting
Common Issues
-
"cannot create udp service" Error
- Port may be in use
- Check with
netstat -un | grep <port> - Wait a few seconds and retry
-
RPC Connection Failed
- Verify server is running and accessible
- Check firewall settings
- Confirm hostname/IP is correct
-
Multicast Not Working
- Check multicast routing:
route -n - Verify network interface supports multicast
- Some virtual networks may not support multicast
- Check multicast routing:
-
Build Errors on macOS
- Client applications currently don't compile due to RPC compatibility issues
- Server application works correctly
- Consider using Linux for full functionality
-
Build Errors on Linux
- Install missing dependencies:
sudo apt-get install libc6-dev rpcbind - Ensure
rpcgenis available in PATH
- Install missing dependencies:
Debug Mode
Add -DDEBUG to CFLAGS in Makefile for verbose output:
CFLAGS = -Wall -Wextra -std=c99 -g -O2 -DDEBUG
Advanced Features
Threading Model
- App1 Server: Single-threaded RPC server with multicast support
- App2 Client: Multi-threaded (main + multicast listener)
- App3 Hybrid: Multi-threaded (RPC server + client menu + multicast)
- App4 Monitor: Multi-threaded (multicast listener + heartbeat sender + menu)
Message Types
MSG_HEARTBEAT: Keep-alive messagesMSG_DATA: General data messagesMSG_COMMAND: Command messagesMSG_STATUS: Status inquiry messagesMSG_BROADCAST: Broadcast messages
Application IDs
APP_SERVER(1): Main serverAPP_CLIENT(2): Pure clientAPP_HYBRID(3): Hybrid appAPP_MONITOR(4): Monitor app
Security Considerations
- No authentication implemented (suitable for trusted networks only)
- UDP communications are not encrypted
- Consider adding SSL/TLS for production use
- Implement message validation for untrusted environments
Performance Notes
- UDP provides low-latency communication
- Multicast efficiently distributes messages to multiple recipients
- RPC provides reliable request-response semantics
- Threading enables concurrent operations
License
This is a demonstration system for educational purposes.