NetBurner 3.5.6
PDF Version
Get MOD54417 Switch Port

GetSwitchPort Application

Overview

The GetSwitchPort application is a network monitoring utility designed for the MOD54417 platform that demonstrates how to determine which physical Ethernet port received a specific MAC address. This application listens for UDP Multicast traffic and identifies the source switch port for each received packet.

Purpose

This example demonstrates how to use the GetSwitchSourcePort() function to determine which physical interface an Ethernet MAC address was last received by. This is particularly useful for network topology discovery, device location tracking, and network diagnostics in switched environments.

Features

  • Multicast UDP Listening: Listens for UDP packets on Multicast address 224.1.2.3:23456
  • Switch Port Detection: Identifies which physical Ethernet port received each packet
  • MAC Address Tracking: Maps Ethernet MAC addresses to their source ports
  • Real-time Monitoring: Continuously monitors and reports network traffic
  • Data Display: Shows received packet data in a readable format

Technical Details

Network Configuration

  • Multicast Address: 224.1.2.3
  • UDP Port: 23456
  • Timeout: 1 second per packet receive attempt

Port Mapping

The application maps bit flags returned by GetSwitchSourcePort() to physical port numbers:

Bit Flag Physical Port
0x1 Port 0
0x2 Port 1
0x4 Port 2
0x8 Port 3
0x10 Port 4
0x20 Port 5
0x40 Port 6
0x80 Port 7

Dependencies

The application requires the following NetBurner libraries:

Operation

  1. Initialization: The application initializes the network stack and enables system diagnostics
  2. Network Wait: Waits up to 5 seconds for an active network connection
  3. Multicast Registration: Registers to receive UDP packets on the specified multicast address and port
  4. Packet Processing: Continuously processes incoming UDP packets:
    • Validates each received packet
    • Extracts the source MAC address
    • Determines the source switch port using GetSwitchSourcePort()
    • Displays packet information including size, source IP, and switch port
    • Shows the packet data in hexadecimal format

Output Format

For each received packet, the application displays:

Rxed [bytes] Bytes From [source_ip] on port [port_number]
[hexadecimal data dump]

Example:

Rxed 64 Bytes From 192.168.1.100 on port 2
[packet data in hex format]

Use Cases

  • Network Topology Mapping: Identify which devices are connected to which switch ports
  • Device Location: Locate specific devices in a switched network
  • Network Diagnostics: Troubleshoot connectivity and switching issues
  • Security Monitoring: Track device movement between ports
  • Asset Management: Maintain inventory of connected devices and their locations

Platform Requirements

  • NetBurner MOD54417 development board
  • NetBurner Development Kit (NNDK)
  • Switched Ethernet network environment
  • Multicast-capable network infrastructure

Build Instructions

Compile using the NetBurner tool chain with the standard NNDK build process. Ensure all required libraries are linked and the target platform is set to MOD54417.

Notes

  • System diagnostics are enabled for development purposes and should be disabled in production code
  • The application runs indefinitely until manually stopped
  • Port numbering is zero-based (0-7 for an 8-port switch)
  • Unknown or invalid port mappings return -1