1.4 TCP/IP Berkeley UDP Relay

The Berkeley UDP Relay configuration demonstrates the use of multiple sockets for both sending and receiving. There are three different sub-functions of this application:

  • UDP Relay, which accepts UDP packets on one socket, and sends the packets out on a different socket

  • UDP Relay Client, which generates UDP traffic that is compatible with the UDP Relay Server

  • UDP Relay Server, which receives and checks traffic for a packet count and reports is any packets are dropped

TCP/IP Berkeley UDP Relay MCC Configuration

The following Project Graph diagram shows the Harmony components included in the Berkeley UDP Relay demonstration application.

  • MCC is launched by selecting Tools > Embedded > MPLAB® Code Configurator from the MPLAB X IDE and after opening the project, TCP/IP demo project is ready to be configured and regenerated.

  • TCP/IP Root Layer Project Graph

    The root layer project shows that USART1 peripheral is selected to do read and write operation for TCP/IP commands.

    This is the basic configuration with SYS_CONSOLE, SYS_DEBUG and SYS_COMMAND modules. These modules are required for TCP/IP command execution.

    tcpip_same70_v71_project

    FreeRTOS component is required for RTOS application. For bare-metal (non-RTOS) FreeRTOS component should not be selected.

    NOTE - The above diagram contains FreeRTOS component and that is required for RTOS application. For bare-metal(non-RTOS) FreeRTOS component shouldn't be selected.

    tcpip_same70_v71_project
  • TCP/IP Configuration

    1. SAM E70 Xplained Ultra

      tcpip_same70_v71_project

    2. SAM V71 Xplained Ultra

      tcpip_same70_v71_project

  • TCP/IP Required Application

    TCP/IP demo use these application module components for this demo.

    Announce module to discover the Microchip devices within a local network.

    DHCP Client module to discover the IPv4 address from the nearest DHCP Server.

    DNS Client provides DNS resolution capabilities to the stack.

    Berkeley API module provides the Berkeley_Socket_Distribution (BSD) wrapper to the native Microchip TCP/IP Stack APIs. During this component selection, the required transport and network modules are also selected.

  • TCPIP Data Link Layer

    Internal ethernet driver(gmac) is enabled with the external LAN8740 PHY driver library for SAME70 demonstartion.

    For SAM V71 demonstration , LAN8061 PHY driver ia selcted along with GMAC Internal ethernet driver.

    The MIIM Driver supports asynchronous read/write and scan operations for accessing the external PHY registers and notification when MIIM operations have completed.

TCP/IP Berkeley UDP Relay Hardware Configuration

This is the section describes the hardware configuration for ATSAM E70/V71 Xplained Ultra Evaluation Kit and one can be used for the respective application demonstration.

  1. This section describes the required default hardware configuration use SAM E70 Xplained Ultra Evaluation Kit

    • Ensure ERASE jumper is Open.

    • Open the J805 Jumper

    • Refer to the SAM E70 Xplained Ultra User Guide

      required_hardware
    • Insert the LAN8740 PHY daughter board on the ETHERNET PHY MODULE header.

    • Connect the micro USB cable from the computer to the DEBUG USB connector on the SAM E70 Xplained Ultra Evaluation Kit

    • Establish a connection between the router/switch with the SAM E70 Xplained Ultra Evaluation Kit through the RJ45 connector

      rqeuired_hardware
  2. This section describes the required default hardware configuration use SAM V71 Xplained Ultra Evaluation Kit

    • No hardware related configuration or jumper setting changes are necessary

    • Ensure ERASE jumper is Open

    • Refer to the SAM V71 Xplained Ultra User Guide

      required_hardware
    • Connect the micro USB cable from the computer to the DEBUG USB connector on the SAM V71 Xplained Ultra Evaluation Kit

    • Establish a connection between the router/switch with the SAM V71 Xplained Ultra Evaluation Kit through the RJ45 connector

      required_hardware

TCP/IP Berkeley UDP Relay Running Application

This table list the name and location of the MPLAB X IDE project folder for the demonstration.

Project NameTarget DeviceTarget Development BoardDescription
sam_e70_xult.XATSAME70Q21BSAME70 Xplained Ultra + LAN8740 PHY Daughter boardDemonstrates the Berkeley UDP Relay on development board with ATSAME70Q21B device and LAN8740 PHY daughter board. This implementation is based on Bare Metal ( non-RTOS).
sam_e70_xult_freertos.XATSAME70Q21BSAME70 Xplained Ultra + LAN8740 PHY Daughter boardDemonstrates the Berkeley UDP Relay on development board with ATSAME70Q21B device and LAN8740 PHY daughter board. This implementation is based on Freertos.
sam_v71_xult.XATSAMV71Q21BSAMV71 Xplained UltraDemonstrates the Berkeley UDP Relay on development board with ATSAMV71Q21B device and KSZ8061 PHY daughter board. This implementation is based on Bare Metal (non-RTOS).
sam_v71_xult_freertos.XATSAMV71Q21BSAME70 Xplained UltraDemonstrates the Berkeley UDP Relay on development board with ATSAMV71Q21B device and KSZ8061 PHY daughter board. This implementation is based on Freertos.

The following Project Graph diagram shows the Harmony components included in the FreeRTOS TCP/IP Berkeley UDP Relay demonstration application.

There are several different commands available in the demonstration from the console port:

  • current - Displays the current configuration

  • start - Starts the packet relay service

  • stop - Stops the packet relay service

  • relayhost < host name > - Sets the host to which packets are to be relayed

  • relayport < port number > - Sets the port to which packets are to be relayed

  • ipv4port < port number > - Sets the IPv4 port that the relay server will listen to for packets to relay

  • ipv6port < port number > - Sets the IPv6 port that the relay server will listen to for packets to relay

  • relayclienthost < host name > - Sets the host to which packets are to be sent

  • relayclientiter < number > - The number of packets to generate

  • relayclientstart - Starts the relay client. This command must be used after the general application start. After a start is called, and the first packet is received by either the relay or the relay server, periodic updates will be sent to the console with information about the number of packets and bytes received.

Running Demonstration Steps

  1. Build and download the demonstration project on the target board.

  2. If the board has a UART connection:

    1. A virtual COM port will be detected on the computer, when the USB cable is connected to USB-UART connector.

    2. Open a standard terminal application on the computer (like Hyper-terminal or Tera Term) and configure the virtual COM port.

    3. Set the serial baud rate to 115200 baud in the terminal application.

    4. See that the initialization prints on the serial port terminal.

    5. When the DHCP client is enabled in the demonstration, wait for the DHCP server to assign an IP address for the development board. This will be printed on the serial port terminal.

      • Alternatively: Use the Announce service or ping to get the IP address of the board.

      • Run tcpip_discoverer.jar to discover the IPv4 and IPv6 address for the board.

  3. Execution:

  • After the successful board bring up, the console output becomes

    tcpip_same70_v71_project
  • To test the UDP packet relay with IPv4, send the following commands,

    • relayclienthost < ip address of the relay client >

    • relayclientiter < number of packets to relay >

    • relayhost < ip address of the host to which packets are to be relayed >

    • relayport < port number to which packets are to be relayed >

    • ipv4port < port number to which the relay server listens to, for packets to relay >

    • current

    • start

    • relayclientstart

  • Output - The above steps will relay the UDP packet from the host address set using the relayclienthost command to the destination address set by the command relayhost.

    The relay packet will be received at the port set by command relayport.