Download FreeRTOS
 

Quality RTOS & Embedded Software

LIBRARIES
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

FreeRTOS-Plus-TCP Demo Projects
Embedded TCP/IP Examples For Windows Simulator

On this page:


IPv4 WinSIM Demo

Source Code and Project Files

This demo application is available in the FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator directory of the official FreeRTOS zip file download and on the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator repository on GitHub.

Target Hardware

The project uses the FreeRTOS Windows simulator. The Windows simulator provides a convenient evaluation platform, but it does not exhibit real time behavior. Simulated time is much slower than real time.

Compiler / Tool Chain

The project is pre-configured to build with the free Express edition of Microsoft Visual C++ (MSVC). MSVC Express Edition 2010 was used.

Functionality

The demo includes the following standard demo configurations:
  • Two sets of UDP client and server tasks, where the client task sends data to the server task. One set of tasks uses the standard sockets interface. The other set of tasks uses the zero copy sockets interface.

The project can optionally be built to also include:

  • A simple TCP echo client task, where the task sends data to a server (address configured using configECHO_SERVER_ADDR[0-3] and echoECHO_PORT) and waits for the echo reply. The reply is checked for correctness.

  • A simple TCP echo server task, where the task waits for incoming connections using FreeRTOS_listen(). When a connection is made and data is received, the task responds backs with the same data.

Build Instructions

  1. Download the source code via the FreeRTOS downloads page that contains the source code and project files. Extract the zip file into a convenient location, ensuring the directory structure is maintained.

  2. Open the Visual Studio solution file FreeRTOS_Plus_TCP_Minimal.sln from within the Visual Studio IDE. The solution file is located in the "FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator" directory.

  3. The demo uses WinPCap to create a virtual network connection by accessing raw Ethernet data on a real network connection. Many computers have more than one real network port. Set configNETWORK_INTERFACE_TO_USE in FreeRTOSConfig.h. to tell the demo which real port should be used to create the virtual port.

    Available port numbers are displayed on the console when the application is executed (see the image in the Usage Instructions section below).

  4. Follow the instructions provided on the Echo Client example documentation page to set up an echo server and set the address of the echo server in FreeRTOSConfig.h. Alternatively, a TCP echo server and/or client can be set up by setting the macros mainCREATE_TCP_ECHO_TASKS_SINGLE and mainCREATE_TCP_ECHO_SERVER_TASK to 1.

  5. The virtual port has its own MAC address. Set the constants configMAC_ADDR0 to configMAC_ADDR5 to ensure the MAC address used by the virtual network connection is unique on the network. The constants are located at the bottom of FreeRTOSConfig.h.

  6. If the IP address assignment is managed by a DHCP server then no further configuration is required.

    If IP address assignment is not managed by a DHCP server then set ipconfigUSE_DHCP to 0 in FreeRTOSIPConfig.h, then edit the constants at the bottom of FreeRTOSConfig.h that set the default values for a static IP address, DNS server address, gateway address and netmask to ensure they are valid for the Ethernet network. The IP address will be valid if the first three octets of the IP address match the first three octets of other IP addresses on the same network - each IP address must be unique on the network.

  7. Select "Build Solution" from the IDE's Build menu (or press F7) to build the application.


Usage Instructions

  • The following constants are defined in main.c to allow tasks to be included or excluded from the build:


    /* Set the following constants to 1 or 0 to define which tasks to include and
    exclude. */

    #define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1
    #define mainCREATE_TCP_ECHO_TASKS_SINGLE 0
    #define mainCREATE_TCP_ECHO_SERVER_TASK 0

Debug Instructions

The standard Visual Studio key used to start a debug session and break on entry to main() is F10.

The same host computer is used to build the application, debug the application, and (because the Win32 simulator is used) run the application. There are no special debugging instructions.


IPv6 WinSIM Demo

Source Code and Project Files

This demo application is available in the main branch of the FreeRTOS repository. It can be found in the FreeRTOS/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo directory of the above repository. This demo demonstrates several protocols (UDP, TCP, ICMP/ping, NTP) of the FreeRTOS-Plus-TCP IPv6 and multiple interface library. It will use both IPv6 and IPv4 for each of the protocols mentioned.

The FreeRTOS-Plus-TCP Multiple Interface Visual Studio project file is in the following directory: Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo. In the .props file, you will find several macros that indicate the location of source files:

  • $(FREERTOS_SOURCE_DIR) The kernel sources
  • $(FREERTOS_INCLUDE_DIR) The kernel header files
  • $(DEMO_COMMON_SOURCE_DIR) The location of the common directory of the demos
  • $(PLUS_TCP_SOURCE_DIR) The FreeRTOS-Plus-TCP source files
  • $(PLUS_TCP_INCLUDE_DIR) The FreeRTOS-Plus-TCP header files
  • $(UTILITIES_SOURCE_DIR) The location of the tcp_utilities directory

You can changes these macros to let the project work with a different source tree.

Target Hardware

The project uses the FreeRTOS-Plus-TCP FreeRTOS Windows simulator. The Windows simulator provides a convenient evaluation platform, but it does not exhibit real time behaviour. Simulated time is much slower than real time.

Compiler / Tool Chain

The project is pre-configured to build with the free Express edition of Microsoft Visual C++ (MSVC). MSVC Express Edition 2010 was used.

Functionality

The IPv6_Multi_WinSim_demo demo performs some basic network activities:

  • ARP address resolution for IPv4 addresses on the LAN
  • Neighbour Discovery for IPv6 addresses on the LAN
  • Look up an IPv4 or IPv6 address using DNS, either asynchronous or synchronous
  • Look up a local host (IPv4/6) using LLMNR (not considered safe anymore)
  • Talk with an NTP server and fetch the time using UDP, with IPv4/6
  • Download a file from any public server using TCP/HTTP
  • Ping any server on the web or on the LAN, with IPv4 or IPv6

The demo can be easily adapted to your own needs. It works like a command line interface (CLI) that performs the above tasks.

Here are some examples:


http4 google.co.uk /index.html
http6 amazon.com /index.html
ping4 10.0.1.10
ping6 2001:470:ec54::
dnsq4 yahoo.com
ntp6a 2.europe.pool.ntp.org

The last line will first lookup the mentioned NTP server, send a request, and wait for a reply. The time will be printed in the logging.

Although it is called a CLI, the demo does not have a STDIN. The commands are hard-coded in main.c The keywords can have some single-letter suffices: 4 or 6 ( for IPv4/6 ), "a" to do an asynchronous DNS lookup, and "c" to clear all caches before starting the task.

Build Instructions

  1. Download the source code via cloning the main) branch of the FreeRTOS-Plus-TCP repository.

  2. Open the Visual Studio solution file FreeRTOS_Plus_TCP_IPv6_Multi.sln from within the Visual Studio IDE. The solution file is located in the "FreeRTOS/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo" directory.

  3. The demo uses WinPCap to create a virtual network connection by accessing raw Ethernet data on a real network connection – and thus can only work with wired network interfaces. Many computers have more than one real network interface. Set configNETWORK_INTERFACE_TO_USE in FreeRTOSConfig.h. to tell the demo which real interface should be used to create the virtual interface. Available interface numbers are displayed on the console when the application is executed.
    The virtual interface has its own MAC address. Set the constants configMAC_ADDR0 to configMAC_ADDR5 to ensure the MAC address used by the virtual network connection is unique on the network. The constants are located at the bottom of FreeRTOSConfig.h.

  4. IP address assignment is done statically in this case. It is not managed by a DHCP server. The IP address configured will be valid if the first three octets of the IP address match the first three octets of other IP addresses on the same network – each IP address must be unique on the network.

  5. Select "Build Solution" from the IDE's Build menu (or press F7) to build the application.

Usage Instructions

The following constants are defined in main.c to allow tasks to be included or excluded from the build:


/* Set the following constants to 1 or 0 to define which tasks to include and

exclude. */

#define mainCREATE_TCP_ECHO_TASKS_SINGLE 1 /* 1 */
#define mainCREATE_TCP_ECHO_SERVER_TASK 0
#define mainCREATE_UDP_ECHO_TASKS_SINGLE 0
mainCREATE_TCP_ECHO_TASKS_SINGLE:
When set to 1, a set of tasks are created that send TCP echo requests to the standard echo port (port 7), then wait for and verify the echo reply, from within the same task. (Tx and Rx are performed in the same RTOS task.) The IP address of the echo server must be configured using the configECHO_SERVER_ADDR0 to configECHO_SERVER_ADDR3 constants in FreeRTOSConfig.h.

mainCREATE_TCP_ECHO_SERVER_TASK:
When set to 1, a task is created that accepts connections on the standard echo port (port 7), then echos back any data received on that connection.

mainCREATE_UDP_ECHO_TASKS_SINGLE:
When set to 1, a task is created that sends data to the address configECHO_SERVER_ADDR_STRING (IPv4/IPv6) where it is expected to echo back the data, which, the created tasks receives.

More details on how to run the demo can be found in the FreeRTOS_Plus_TCP_IPv6_Demo readme.

Debug Instructions

The standard Visual Studio key used to start a debug session, and break on entry to main(), is F10. The same host computer is used to build the application, debug the application, and (because the Win32 simulator is used) run the application. There are no special debugging instructions.


Old Demos with Other Open Source TCP/IP Stacks
Read further for additional information on legacy TCP/IP demos.

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.