|
NetBurner 3.5.8
PDF Version |
Example Path: examples/VLan
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:
The serial port interface provides an interactive menu to display interface and VLAN information, as well as other system parameters.
The application automatically creates the following VLAN interfaces:
predef.hThis example already enables MULTIHOME for you with the SDK override feature, so it builds as-is. To do the same in your own project:
overload/nbrtos/include/predef-overload.h in your project directory#define MULTIHOME to enable multiple interface support#define NUM_MULTI_INTERFACES (10))This approach overrides the system predef.h for your project only, without modifying the SDK files directly.
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) |
The application displays comprehensive network information including:
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:
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.
AddVlanInterface(): Creates a new VLAN interface on a parent Ethernet portInterfaceBlock::vlan_tag_value: The VLAN tag for an interface (set at runtime from the serial menu)showIpAddressesSerial(): Displays interface info on serial consoleshowIpAddressesWeb(): Generates web page with interface informationshowLinkStatus(): Shows physical link statusgetTimeStringFromSeconds(): Converts seconds to HH:MM:SS formatgetLeaseTimeInfo(): Formats DHCP lease timing informationSourceName(): Returns human-readable IPv6 address source namespredef.h with #define MULTIHOME.cpp and .h filespredef.h contains #define MULTIHOMEUse the serial console commands to diagnose issues:
E - Check Ethernet hardware statusI - Verify interface configurationC - Review network counters for errorsA - Check ARP table for connectivityThis 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 functionality is conditionally compiled based on the IPV6 preprocessor definition. When enabled, the application provides: