Network Component  Version 6.6
MDK-Professional Middleware for IP Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Ethernet

Ethernet Interface Configuration

The Ethernet interface is configured using the Net_Config_ETH_n.h file. n stands for the number of the Ethernet interface. In general, most microcontrollers will have one Ethernet interface, thus the configuration file will be Net_Config_ETH_0.h. The options are set in the file directly or using the Configuration Wizard.

net_config_eth_0_h.png
Ethernet Interface Configuration File

The Ethernet configuration file contains the following settings:

  • Connect to hardware via Driver_ETH# defines the number of the Ethernet MAC peripheral on the microcontroller device to be used. Unless it contains multiple Ethernet MACs, this should always be "0".
  • MAC Address specifies the six byte Ethernet MAC address of the device. It must be unique for each Ethernet controller that is part of a LAN. The value FF:FF:FF:FF:FF:FF is not allowed. During mass-production, this value needs to be changed for every single device that is manufactured using the Runtime Configuration.
  • IP Address specifies a static local 4 bytes IP address. The value 255.255.255.255 is not allowed. This IP address is only used by the device if the Dynamic Host Configuration is disabled. If DHCP is enabled, the IP address is obtained automatically from the DHCP server or an AutoIP is used. A static IP address can also be changed at runtime.
  • Subnet mask defines the net mask. The value of the net mask has to to be in line with the above specified IP address.
  • Default Gateway specifies the IP address of the default gateway. It is used when accessing the external WAN. If the application is used on a local LAN only, then the value is irrelevant.
  • Primary DNS Server specifies the IP address of the primary DNS server. The DNS Client sends IP address resolution requests to this address. The setting is irrelevant if the DNS Client is disabled.
  • Secondary DNS Server specifies the IP address of the secondary DNS server. It is used if the primary DNS server is down or not accessible. In this case, the DNS Client automatically switches to the secondary DNS server if a non-zero address is provided. The setting is irrelevant if the DNS Client is disabled.
  • ARP Definitions configures various parameters of the Address Resolution Protocol that is used to cache the IP addresses of remote peers.
    • Cache Table size specifies the size of ARP cache table. It defines how many cache entries can be kept in the ARP cache. Increase this value when using multiple simultaneous IP connections.
    • Cache Timeout in seconds specifies the timeout for an ARP cache entry. After a timeout, the Permanent IPs are refreshed, and the Temporary IPs are removed from the cache. The Timeout (Keep-alive) Timer is reset on every access to the cache entry.
    • Number of Retries is the maximum number of retries to resolve the Ethernet MAC address of the remote peer.
    • Resend Timeout in seconds specifies the waiting interval between two re-sends. When this timeout has expired and no response has been received from the remote peer, the ARP request is resent.
    • Send Notification on Address changes enables or disables the Gratuitous ARP Service. When it is enabled, the embedded host will broadcast a Gratuitous ARP notification at startup, or when the local IP address has changed.
  • IGMP Group Management enables or disables sending or receiving IP Multicast packets. In order to receive Multicast packets, a host must first join a Host Group with a specified Host Group IP address.
    • Membership Table size specifies the size of IGMP Host Group table. It defines how many Host Groups a host can join.
  • If the NetBIOS Name Service is enabled, the device can be accessed by its local host name in a LAN. For example:
    ping my_device_server
    instead of
    ping 192.168.0.100
  • If Dynamic Host Configuration is enabled, the device obtains all network parameters like IP address, net mask, default gateway, primary and secondary DNS servers automatically from the DHCP server on the LAN. Enable also the option NetBIOS Name Service to access the hardware by its name. DHCP requires UDP Sockets to be enabled as it uses one UDP socket for communication with the DHCP server.
    • Vendor Class Identifier (VCI) specifies a string, which is added to the DHCP request message. The VCI can be used to selectively identify a device on a DHCP server (option 60). For example, the DHCP server can assign an IP address to a specific Vendor Class group and ignore all other DHCP clients with a different VCI.
    • Bootfile Name enables or disables the DHCP option 67. If this option is enabled, a DHCP client requests also a Bootfile Name parameter from a DHCP server. When enabled, the user needs to provide a dhcp_client_notify() notification function in his application.
    • NTP Servers specifies that a list of NTP servers (option 42) is also requested from the DHCP server.

IP Address Assignment

The IP address for the Ethernet network interface is assigned in several ways using the following modes:

  • Static IP
    The IP address, network mask and default gateway are configured manually in the system configuration file. However, it is possible to change the IP address at runtime. The static configuration specifies also a primary and optional secondary DNS server. To make use of the static IP configuration, you need to disable DHCP.
  • Dynamic Host Configuration Protocol (DHCP)
    This mode is mostly used. It requires a centralized DHCP server in the local area network (LAN). DHCP server maintains a database of leased IP addresses, and assigns to the client an unused IP address. It specifies also a network mask and a default gateway to use, when the system wants to access the internet. The DHCP server specifies also a primary and optional secondary DNS server. The DNS server is used to resolve the IP address for a known host name.
    The system first tries the DHCP mode, and if it fails after a timeout of 60 seconds, the system starts an auto-configuration mode (AutoIP mode). It randomly selects an IP address and checks, if it is in use. If the chosen IP address is not used, the system starts using it. Otherwise the system tries a different random IP address. In this mode an IP address and network mask are assigned. The default gateway is not assigned, because it is not known. Connecting to the Internet is thus not possible from the AutoIP mode. The IP address is picked from the link-local IP address block (169.254.1.0 - 169.254.254.255). The network mask is 255.255.0.0.
Note
  • In AutoIP mode, a DHCP client is still trying to obtain an IP address every 120 seconds. On success the IP address is re-assigned. The system then starts using a new, DHCP assigned IP address and the mode is changed back to DHCP mode. The AutoIP mode is an extension of the DHCP mode.
  • All available functions for using Ethernet are explained in Ethernet section of the Reference.