Embedded TCP/IP stack  3.9.4
FNET Shell Demo Quick Start

Requirements

Tools used during this quick start:

Step by step

Follow these steps to run the FNET Shell demo application:

  • Prepare your evaluation board according to your board User Manual.
  • Use USB or RS-232 male/female DB-9 serial cable to connect your PC (through COM port) to the evaluation board.
  • Connect the evaluation board to an Ethernet network.
  • Power the board up.
  • Invoke the terminal program on the PC to which the evaluation board is connected and configure it to:
    • Bits per second: 115200.
    • Data bits: 8.
    • Parity: none.
    • Stop bits: 1.
    • Flow control: None.

      fnet_serial_setup.jpg
      Serial port setup
  • Launch IDE.
  • Open the project:
    fnet\fnet_demos\boards\<board_name>\shell\<compiler_name>\
    
  • In the IDE, choose a project target you want to compile.
  • Compile, load (or flash) the application to the board and run the project.
  • In your terminal program window you should see the FNET application Shell welcome message:
    Parameters loaded from Flash.
    
    ************************************************
     FNET Shell Application
    ************************************************
     FNET TCP/IP Stack for MK64FN1
     Version 3.7.0
     Built Nov  9 2016 at 15:34:08 by IAR
    ************************************************
     Interface        : eth0
     IPv4 Address     : 0.0.0.0 <manual>
     IPv6 Address     : fe80::211:22ff:fe33:4455 <autoconfigurable> ScopeID:1
     IPv4 Subnet mask : 255.0.0.0
     IPv4 Gateway     : 0.0.0.0
     IPv4 DNS         : 0.0.0.0
     MAC Address      : 00:11:22:33:44:55
     MTU              : 1500
     Link Status      : unconnected
     Free Heap        : 30272
     HTTP Server      : disabled
     DHCP Client      : disabled
     AUTOIP Service   : disabled
     TELNET Server    : disabled
     LLMNR Server     : disabled
     MDNS Server      : disabled
    
     Enter 'help' for command list.
    ************************************************
    
    SHELL>
    
  • Shell application monitors network interface connection status using Link-Detection service (enabled by FNET_CFG_LINK). Whenever the network interface indicates that it has been connected, application begins the auto-configuration process using DHCPv4. If DHCPv4 server has not been discovered on local network, the application start Auto-IP service. Whenever the network interface indicates that it has been disconnected, the application disables bound protocols on this interface.
    Note
    On connect/unconnect scripts are defined by FAPP_CFG_LINK_CONNECT_SCRIPT and FAPP_CFG_LINK_UNCONNECT_SCRIPT in fapp_user_config.h
    So if network cable is connected, in your terminal program window you should see:
    eth0: connected => Script: dhcp autoip; mdns; llmnr;
    ************************************************
     DHCPv4 Client started.
    ************************************************
    Press [Ctr+C] to cancel.
    DHCP: Discovering...
    DHCP: Discovering...
    DHCP: Discovering...
    Cancelled
    ************************************************
     Auto-IP service started.
    ************************************************
    Press [Ctr+C] to cancel.
    AutoIP: Probing...
    AutoIP: Probing...
    AutoIP: Probing...
    
    ************************************************
     IPv4 parameters updated :
    ************************************************
     Interface        : eth0
     IPv4 Address     : 169.254.71.33 <autoconfigurable>
     IPv6 Address     : fe80::204:9fff:fe13:1845 <autoconfigurable> ScopeID:1
     IPv4 Subnet mask : 255.255.0.0
     IPv4 Gateway     : 0.0.0.0
     IPv4 DNS         : 0.0.0.0
    ************************************************
     mDNS server started.
     Name             : fnet
    ************************************************
    ************************************************
     LLMNR server started.
     Host Name        : fnet
    ************************************************
    SHELL>
    
  • There is additional possibility to start any other service (http, telnet etc.) automatically during power-up by setting the FAPP_CFG_STARTUP_SCRIPT_ENABLED parameter to 1 and setting the FAPP_CFG_STARTUP_SCRIPT parameter to command line string.
  • You may start mDNS server (if not started already during start-up), which allows name resolution for hosts on the same local link. It is natively supported by Apple OSs and named "Bonjour".
    If HTTP server is enabled, the application registers the "_http._tcp.local" service in mDNS server. So the HTTP server can be discoverable by in MacOS Safari browser using Bonjour.
    SHELL> mdns
    ************************************************
     mDNS server started.
     Name             : fnet
    ************************************************
    
  • You may start LLMNR server (if not started already during start-up), which allows name resolution for hosts on the same local link. It is natively supported by Windows OSs.
    SHELL> llmnr
    ************************************************
     LLMNR server started.
     Host Name        : fnet
    ************************************************
    
    So you can use "fnet" instead of IP address to find this node on local network.
  • The Main Shell is now ready to accept user commands. Try help command to display a list of all the commands available within the shell:
    SHELL> help
    >   help                                 - Display this help message
    >    set [<parameter> <value>]           - Set parameter
    >    get [<parameter>]                   - Get parameters
    >   bind <IP6 address>                   - Bind IPv6 Address
    > unbind <IP6 address>                   - Unbind IPv6 Address
    >   info                                 - Show interface info
    >   stat                                 - Show network statistics
    >   dhcp [release|autoip]                - Start DHCP client
    > autoip [release]                       - Start Auto-IP service
    >   http [release]                       - Start HTTP Server
    >    exp                                 - File Explorer submenu...
    > telnet [release]                       - Start Telnet Server
    >    dns <host name> 4|6 [<server ip>]   - Resolve IPv4|6 address of <host name>
    >  llmnr [release]                       - Start LLMNR Server
    >   mdns [release]                       - Start MDNS Server
    >   save                                 - Save parameters to the FLASH
    >  reset                                 - Reset the board
    >   ping [-c <count>][-i <seconds>]
            [-p <pattern>][-s <size>]
            [-h <hoplimit/ttl>] <ip>        - Send ICMP ECHO requests
    SHELL>
    
  • All computers, connected to an Ethernet network running the IPv4 protocol, need several network-specific parameters:
    • IPv4 address for the system;
    • IPv4 address of the Gateway for non-local traffic;
    • IPv4 network mask (netmask) for the system to distinguish between local or non-local traffic;
  • You are able to change the default network parameters manually:
    • By using Shell commands:
      set address <board IP address>
      set gateway <gateway IP address>
      set netmask <netmask IP address>
      set mac <ethernet MAC address>
      
    • By changing the default values in the fnet_user_config.h source file.
      Your local system administrator is able to assign a unique IPv4 address for the board, and also provide you with the IPv4 addresses of the gateway and the netmask.
  • You may start the DHCP IPv4 client (if not started already during start-up) to obtain the address parameters automatically from your network DHCPv4 server:
    SHELL> dhcp
    Press [Ctr+C] to cancel.
    DHCP: Discovering...
    
    ************************************************
     DHCP has updated/renewed parameters:
    ************************************************
     Interface        : eth0
     IP address       : 10.171.88.141
     Subnet mask      : 255.255.254.0
     Gateway          : 10.171.88.254
     DNS              : 10.171.88.254
    SHELL>
    
  • You may also also start (if not started during start-up) the Auto-IP service to obtain automatically the IPv4 link-local address within the 169.254/16 prefix that is valid for communication with other devices connected to the same physical (or logical) link:
    SHELL> autoip
    ************************************************
     Auto-IP service started.
    ************************************************
    Press [Ctr+C] to cancel.
    AutoIP: Probing...
    AutoIP: Probing...
    AutoIP: Probing...
    
    ************************************************
     IPv4 parameters updated :
    ************************************************
     Interface        : eth0
     IPv4 Address     : 169.254.53.98 <autoconfigurable>
     IPv4 Subnet mask : 255.255.0.0
     IPv4 Gateway     : 0.0.0.0
     IPv4 DNS         : 0.0.0.0
    
    Note
    You may start Auto-IP service automatically, if no DHCPv4 server was discovered, by adding the autoip parameter to the dhcp command.
  • You may enter the save command to save the all run-time parameters to non-volatile memory (it is located in the last erase page of the on-chip flash memory).
    SHELL> save
    Parameters saved
    SHELL>
    
    Note
    The save command does not save the ip parameter in case it was allocated by a DHCP server to avoid IPv4 address conflict during the system startup.
  • You should now be able to "ping" the board from one of your workstations. The ping program is a very useful diagnostic tool used to check that the board`s IP information is properly configured.
  • The ping tool can be used from the command-line environment on the host PC:
    ping <your_board_IP_adress> 
    By default the ping routine will send a test ICMP frame to the board four times and will write a summary message on the screen. If everything works as expected, you should see an output similar to this:
    C:\Temp>ping 192.168.0.22
    
    Pinging 192.168.0.22 with 32 bytes of data:
    Reply from 192.168.0.22: bytes=32 time=10ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    Reply from 192.168.0.22: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.0.22:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 10ms, Average = 2ms
    
    C:\Temp>ping fe80::204:9fff:fe12:4938%19
    
    Pinging fe80::204:9fff:fe12:4938%19 with 32 bytes of data:
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    Reply from fe80::204:9fff:fe12:4938%19: time<1ms
    
    Ping statistics for fe80::204:9fff:fe12:4938%19:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
  • The PING application can be started from the board, by typing the command ping into your terminal program window.
    In your terminal program window you should see:
    SHELL> ping 192.168.0.5
    ************************************************
     PING
    ************************************************
     Remote IP addr   : 192.168.0.5
     Message Size     : 63
     Num. of messages : 4
     Pattern          : 0
     Hoplimit (TTL)   : 64
    Press [Ctr+C] to cancel.
    ************************************************
    Reply from 192.168.0.5
    Reply from 192.168.0.5
    Reply from 192.168.0.5
    Reply from 192.168.0.5
    SHELL>
  • In the next step, you can run the HTTP Server on the board, by typing the command http into your terminal program window.
    In your terminal program window you should see:
    SHELL> http
    ************************************************
     HTTP server started.
     IPv4 Address     : 192.168.0.22
     IPv6 Address     : fe80::204:9fff:fe12:4938
    ************************************************
    SHELL>
    
  • Then run your Web browser and navigate to the server address (the address you have assigned to the system or obtained from the DHCP server):
    http:// 192.168.0.22
    
    or
    http:// [fe80::204:9fff:fe12:4938]
    
  • You should see a Web page served by the FNET HTTP server:


    fnet_quick_start_web.png
    Demo Web Page
  • Also you can run the Telnet Server on the board, by typing the command telnet into your terminal program window.
    In your terminal program window you should see:
    SHELL> telnet
    ************************************************
     Telnet Server started.
     IPv4 Address     : 192.168.0.22
     IPv6 Address     : fe80::204:9fff:fe12:4938
    ************************************************
    SHELL>
    
  • Then run your Telnet client. Start PuTTYtel application and enter the Telnet server IP address (the address you have assigned to the system or obtained from the DHCP server):

    fnet_telnet_config.jpg
    PuTTYtel Configuration
  • Press [Open] to open a telnet session. In your telnet program window you should see the FNET application Shell welcome message:

    fnet_telnet_session.jpg
    Telnet session
  • If you need to get know an IP address of the domain/host name (like www.google.com or others), you may use DNS client/resolver, by typing the command dns <host_name> 4|6 into the command shell window.
    For example, if you want to get know the IPv4 address of www.google.com, enter dns www.google.com 4 in your terminal program window:
    SHELL> dns www.google.com 4
    ************************************************
     Resolving        : www.google.com
     DNS Server       : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address : 216.58.208.100       TTL=1241513984
    
    For example, if you want to get know the IPv6 address of www.google.com, enter dns www.google.com 6 in your terminal program window:
    SHELL> dns www.google.com 6
    ************************************************
     Resolving        : www.google.com
     DNS Server       : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address : 2a00:1450:4017:802::2004     TTL=167772160
    
    Note
    Be sure that the dns parameter is set to correct IP address of the DNS server on your network. It can be set manually by the set command or can be obtained automatically by the DHCP IPv4 client service.
  • If you need to get know current date and time, you may use SNTP client, by typing the command sntp <server ip> 4|6 into the command shell window.
    For example, you may use public pool of NTP servers addressed by "pool.ntp.org". Use the "dns" command to resolve its IP addresses.
    SHELL> dns pool.ntp.org 4
    ************************************************
     Resolving        : pool.ntp.org
     DNS Server       : 192.168.0.1
    Press [Ctr+C] to cancel.
    ************************************************
     Resolved address : 52.209.118.149       TTL=1627389952
     Resolved address : 89.163.241.149       TTL=1627389952
     Resolved address : 213.251.53.187       TTL=1627389952
     Resolved address : 108.59.2.24  TTL=1627389952
     Resolved address : 207.171.17.42        TTL=4100195584
     Resolved address : 212.25.19.23         TTL=1427308544
     Resolved address : 174.127.124.192      TTL=1427308544
     Resolved address : 193.243.171.138      TTL=1427308544
     Resolved address : 89.36.18.22  TTL=1427308544
     Resolved address : 199.249.224.53       TTL=1427308544
     Resolved address : 85.214.25.217        TTL=1427308544
     Resolved address : 178.63.120.205       TTL=1427308544
     Resolved address : 199.188.48.59        TTL=1427308544
    SHELL> sntp 89.163.241.149
    ************************************************
     SNTP Resolving
     SNTP Server      : 89.163.241.149
    Press [Ctr+C] to cancel.
    ************************************************
     UTC: 2017-6-8 8:38:14.886
    
    Note
  • If one SNTP server is failed, try another one from the resolved address list.
  • If you do not have access to public NTP servers, for testing you may use a local SNTP server provided by the http://tftpd32.jounin.net/ application.

© 2005-2017 by Andrey Butok. http://fnet.sourceforge.net