NetBurner 3.5.8
PDF Version
VLAN

Example Path: examples/VLan

VLAN Example Application

Overview

This NetBurner application demonstrates the creation and management of multiple VLAN (Virtual Local Area Network) interfaces on a single Ethernet port. The application creates three different VLAN interfaces with different configurations and provides both web-based and serial console interfaces for monitoring network status.

To build this example MULTIHOME must be enabled in predef.h. Rather than edit the system file in nbrtos/include, this example uses the SDK override feature: it ships a local overload/nbrtos/include/predef-overload.h that defines MULTIHOME (and raises NUM_MULTI_INTERFACES) just for this project. The interfaces created are:

  • Ethernet 0, DHCP, VLAN ID 1
  • Ethernet 0, DHCP, VLAN ID 2
  • Ethernet 0, Static IP, VLAN ID 10

The serial port interface provides an interactive menu to display interface and VLAN information, as well as other system parameters.

Features

  • Multiple VLAN Interface Creation: Creates 3 VLAN interfaces on Ethernet 0
  • Mixed Configuration Support: Supports both DHCP and static IP configurations
  • Interactive Serial Menu: Command-line interface for network diagnostics
  • Web Interface: HTTP server displaying network interface information
  • IPv4 and IPv6 Support: Comprehensive IP address management and display
  • Real-time Network Monitoring: Link status, ARP tables, and interface statistics

VLAN Configuration

The application automatically creates the following VLAN interfaces:

  1. VLAN ID 1: Ethernet 0 with DHCP configuration
  2. VLAN ID 2: Ethernet 0 with DHCP configuration
  3. VLAN ID 10: Ethernet 0 with static IP (198.18.1.20/16)

Prerequisites

  • MULTIHOME Support: Must be enabled in predef.h
  • NetBurner Platform: Compatible NetBurner hardware platform
  • Network Infrastructure: VLAN-capable switch or router

Enabling MULTIHOME

This example already enables MULTIHOME for you with the SDK override feature, so it builds as-is. To do the same in your own project:

  1. Create overload/nbrtos/include/predef-overload.h in your project directory
  2. Add #define MULTIHOME to enable multiple interface support
  3. Add any other required definitions (this example also sets #define NUM_MULTI_INTERFACES (10))

This approach overrides the system predef.h for your project only, without modifying the SDK files directly.

Serial Console Commands

The application provides an interactive serial console with the following commands:

Command Description
A Show ARP table
C Show network counters
E Dump Ethernet information
I Show all network interfaces and IP addresses
W Display system tick count and uptime
? Show help menu
1-9 <vlan_id> Set VLAN tag on interface (1-9)

Example Usage

I # Show all interfaces
A # Display ARP table
1 100 # Set interface 1 to VLAN 100
W # Show system uptime
Address Resolution Protocol packet structure.
Definition arp.h:1035

Network Interface Information

The application displays comprehensive network information including:

IPv4 Information

  • IP Address
  • Subnet Mask
  • DNS Servers (Primary and Secondary)
  • Gateway Address
  • Auto-IP Address

IPv6 Information (if enabled)

  • Link-local addresses
  • Router-assigned addresses
  • DHCP-assigned addresses
  • Static addresses
  • DNS servers with source information
  • DHCP lease timing information

Physical Interface Details

  • MAC Address
  • Link Status (UP/DOWN)
  • Link Speed (MB)
  • Duplex Mode (Full/Half)

Web Interface

The application includes an HTTP server that serves a single page (index.html) listing every active network interface. The page shell is a static HTML file styled with a self-contained stylesheet (plain CSS, no framework or CDN); the live per-interface data is produced on the device as the page is served.

A <!--CPPCALL showIpAddressesWeb --> tag in index.html hands the HTTP socket to showIpAddressesWeb() in ip_util.cpp, which walks the interface list and formats each value straight into the page with fdprintf, using the same hI / I IP-address specifiers as the serial output. For each interface the page shows:

  • MAC address, VLAN tag, and link status (speed / duplex)
  • IPv4 configuration: IP, mask, DNS, gateway, and Auto-IP
  • Clickable IP links: open the device on that interface's IPv4 (or IPv6) address
  • IPv6 addresses with their source (Link-Local / Router / DHCP / Static) and DHCP lease timing

Access the web interface by navigating to any of the device's IP addresses in a web browser. Reload to refresh; newly-assigned IPv6 addresses may take a few seconds to appear.

Related Examples

  • ShowInterfaces — web view of a single network interface
  • MultiHome — multiple interfaces on one device without VLAN tagging

File Structure

project/
src/main.cpp # Main application logic and VLAN setup
src/ip_util.cpp # IP address display helpers (serial + web)
src/ip_util.h # Header file for IP utilities
html/index.html # Web interface page (static shell + CPPCALL)
html/style.css # Self-contained page stylesheet
html/logo.png # Header logo
overload/nbrtos/include/predef-overload.h # Enables MULTIHOME for this project

Key Functions

VLAN Management

Network Information Display

  • showIpAddressesSerial(): Displays interface info on serial console
  • showIpAddressesWeb(): Generates web page with interface information
  • showLinkStatus(): Shows physical link status

Utility Functions

  • getTimeStringFromSeconds(): Converts seconds to HH:MM:SS format
  • getLeaseTimeInfo(): Formats DHCP lease timing information
  • SourceName(): Returns human-readable IPv6 address source names

Building and Deployment

  1. Setup Project: Create new NetBurner project
  2. Enable MULTIHOME: Add predef.h with #define MULTIHOME
  3. Add Source Files: Include all .cpp and .h files
  4. Build: Compile using NetBurner development tools
  5. Deploy: Flash to NetBurner hardware

Network Setup Requirements

  • VLAN-Capable Switch: Network infrastructure must support VLAN tagging
  • Proper VLAN Configuration: Switch ports must be configured for appropriate VLAN IDs
  • IP Address Management: Ensure IP ranges don't conflict across VLANs

Troubleshooting

Common Issues

  1. MULTIHOME Not Enabled: Verify predef.h contains #define MULTIHOME
  2. Link Status Down: Check physical connections and cable
  3. DHCP Not Working: Verify DHCP server availability on VLANs
  4. Web Interface Inaccessible: Check IP address configuration and routing

Debug Commands

Use the serial console commands to diagnose issues:

  • E - Check Ethernet hardware status
  • I - Verify interface configuration
  • C - Review network counters for errors
  • A - Check ARP table for connectivity

Platform Compatibility

This application is designed for NetBurner embedded platforms with Ethernet capability. It supports both single and dual Ethernet configurations (commented code shows dual-port setup for platforms like the 54417).

IPv6 Support

IPv6 functionality is conditionally compiled based on the IPV6 preprocessor definition. When enabled, the application provides:

  • Multiple IPv6 address assignment methods
  • DHCP v6 lease management
  • Router advertisement processing
  • Comprehensive IPv6 status reporting