This
FreeRTOS Labs project is adding multiple interfaces and multiple endpoint support to the currently single interface only FreeRTOS-Plus-TCP TCP/IP stack. While the resultant multiple interface version is fully functional, it is still undergoing optimisation, test coverage and documentation improvements, and memory safety checks. Until that work is complete the code is available as a branch of the
FreeRTOS-Plus-TCP GitHub repo.
FreeRTOS-Plus-TCP Mulitple Interface Demo Project
For the FreeRTOS Windows Simulator
On this page:
This demo application is available in the labs/ipv6_multi
branch of the FreeRTOS-Plus-TCP repository. It can be found in the demos/Multi_interface_demo
directory of the above repository.
This demo demonstrates the multiple interface (or rather the multiple endpoint) functionality of the FreeRTOS-Plus-TCP IPv6 and multiple interface library.
When a device has multiple interfaces, a generated IP packet can be sent to any of those interfaces. But choosing the correct one is important since the packet might not get through to the desired destination in case of separated subnets. Additionally, sending the packet to all interfaces will only create unnecessary network traffic.
The demo uses two different classes of IP addresses. Since the Windows Simulator environment does not have multiple interfaces which can be used by FreeRTOS, the demo is configured to use just one interface: Ethernet. The IP addresses can be changed according to your needs by modifying the below macros:
In FreeRTOSConfig.h
#define configIP1_ADDR0 192
#define configIP1_ADDR1 168
#define configIP1_ADDR2 0
#define configIP1_ADDR3 200
and in
main.c
#define configIP2_ADDR0 10
#define configIP2_ADDR1 0
#define configIP2_ADDR2 1
#define configIP2_ADDR3 6
The demo shall attempt to ping the two different IP address present on different subnet masks which are configured in
main.c
as shown below. Using a network analyser such as
Wireshark you should be able to see that the IP addresses used to ping the below IP address belong to the same subnet. That is,
10.0.1.6
will be used to ping
10.0.1.10
and
192.168.0.200
will be used to ping
192.168.0.1
.
#define democonfigCLASS_A_IP_ADDRESS "10.0.1.10" /* IP address of another device on the network with configured static IP that can be pinged. */
#define democonfigCLASS_C_IP_ADDRESS "192.168.0.1" /* IP address of the router. */
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.
The project is pre-configured to build with the
free Express edition of Microsoft Visual C++
(MSVC). MSVC Express Edition 2010 was used.
The demo includes the following standard demo configurations:
-
Two sets of tasks which try to ping the class A and class C IP addresses as
configured using the macros
democonfigCLASS_A_IP_ADDRESS
and democonfigCLASS_C_IP_ADDRESS
as shown above.
-
Download the source code via cloning the
"labs/ipv6_multi"
branch of the FreeRTOS-Plus-TCP repository.
-
Open the Visual Studio solution file Multi_interface_demo.sln
from within the Visual Studio IDE. The solution file is located
in the "demos/Multi_interface_demo" directory.
-
The demo uses WinPCap to create a virtual network connection by
accessing raw Ethernet data on a real network connection - so 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 (See the image below).
-
You will need to configure another device to use a different class of IP address than
the one your router uses. That is, if the router uses 192.x.x.x (Class C), then the
other device should use 10.x.x.x (
democonfigCLASS_A_IP_ADDRESS
) and vice versa.
Using a PC
If you are using a PC as a second device, you need to go to "Control Panel > Network and
Sharing Center > Change adapter settings
". There you can see all the adapters your PC has.
Choose the one which you want to use for this demo. Right click on it and choose "Properties
".
You will be shown a window as shown below.
Select the "Internet Protocol Version 4 (TCP/IPv4)" and click on Properties. A new
window should open. Make the changes so that it looks like the below image.
Note that the IP address shown in the image (and the one you put in the settings)
should be same as democonfigCLASS_A_IP_ADDRESS.
-
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.
-
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.
-
Select "Build Solution" from the IDE's Build menu (or press F7)
to build the application.
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.