DHCP Server Application (DHCPD)
Overview
This NetBurner application demonstrates how to create and deploy a DHCP (Dynamic Host Configuration Protocol) Server on your NetBurner device. The application provides automatic IP address assignment to devices on your network, making it useful for creating standalone networks or testing environments.
Features
- DHCP Server Implementation: Creates a fully functional DHCP server that can assign IP addresses to network clients
- Conflict Detection: Automatically detects existing DHCP servers on the network before starting to prevent conflicts
- Web Interface: Includes an HTTP server for potential configuration and monitoring
- Network Diagnostics: Built-in system diagnostics for troubleshooting
- Multi-Interface Support: Can operate on different network interfaces
How It Works
Startup Sequence
- Network Initialization: The application initializes the network stack and waits for an active network connection
- DHCP Server Detection: Scans the network for existing DHCP servers to avoid conflicts
- User Intervention: If another DHCP server is detected, the application prompts the user to resolve the conflict
- Server Launch: Once no conflicts are detected, launches the DHCP server on the specified interface
- Continuous Operation: Runs indefinitely, serving DHCP requests
Key Components
- FindOtherDHCPServer(): Implements network scanning to detect existing DHCP servers
- Sends DHCP DISCOVER messages to probe for active servers
- Uses a 5-second timeout to wait for responses
- Returns true if another server is found, false otherwise
- AddMyDHCPServer(): Initializes and starts the DHCP server functionality
- Operates on the specified network interface
- Handles DHCP client requests and IP address allocation
- DhcpServCheck(): Callback function for processing DHCP responses during server detection
Usage
Compilation and Deployment
- Ensure you have the NetBurner development environment set up
- Include the necessary NetBurner libraries:
- Compile and flash to your NetBurner device
Operation
- Power on your NetBurner device
- The application will automatically:
- Initialize network services
- Check for existing DHCP servers
- Prompt you if conflicts are detected
- If conflicts exist: Disable other DHCP servers on the network and press any key to retry
- Once running: The device will serve DHCP requests to network clients
Network Configuration
- The DHCP server will operate on the first available network interface by default
- Client devices connecting to the network will automatically receive IP addresses
- The web server runs on port 80 for potential configuration access
Important Considerations
Production Deployment
- Remove diagnostics: The code includes
EnableSystemDiagnostics() which should be removed for production use
- Security: Consider implementing access controls if deploying in production environments
- Network planning: Ensure the IP address pool doesn't conflict with other network infrastructure
Network Conflicts
- Multiple DHCP servers on the same network can cause IP address conflicts
- Always verify no other DHCP servers are active before deployment
- Common sources of DHCP servers include routers, other embedded devices, and server systems
Dependencies
- NetBurner NNDK (NetBurner Network Development Kit)
- Custom memory allocation module (
MyAlloc.h)
- Standard NetBurner networking libraries
Technical Details
- Language: C++
- Platform: NetBurner embedded devices
- Threading: Uses NetBurner RTOS (Real-Time Operating System)
- Network Stack: NetBurner TCP/IP stack
- Memory Management: Custom buffer management for DHCP packets
Troubleshooting
Common Issues
- There is an active DHCP server on this net
- Another DHCP server is detected on the network
- Disable other DHCP servers or move to an isolated network segment
- Network timeout during startup
- Check network connectivity and cable connections
- Verify network interface configuration
- Clients not receiving IP addresses
- Confirm DHCP server started successfully
- Check network segmentation and VLAN configuration
- Verify firewall settings aren't blocking DHCP traffic
Debug Information
The application outputs status messages to the console including:
- Application name and NNDK revision information
- DHCP server conflict detection results
- Startup progress indicators