Network Core Example Applications#
This section describes the examples that are related to the TCP/IP module of Micrium OS.
Network Module(s) Initialization Example#
Description#
This example shows how to initialize network module(s). It basically calls the self-contained module examples when the module is available and the example is enabled. See Example Applications section for further information about how to enable an example. It accomplishes the following tasks:
Initialize the network core using:
Initialize network application module(s), when it is part of your project and the example activated using the following example:
Configuration#
No specific configuration applies to this example. See sub-module example(s) for further information about the configuration.
Location#
/examples/net/ex_network_init.c
/examples/net/ex_network_init.h
API#
API | Description |
---|---|
Ex_NetworkInit() | This function performs the different example steps mentioned in the section Description . The function must be called by your application task prior to calling any other file system Network examples. |
Notes#
This example doesn't start the network core. Once the module are initialized the network interface must be started as described by Network Core Start Interfaces Example
Network Core Initialization Example#
Description#
This is a generic example for the TCP/IP core module initialization. It accomplishes the following tasks:
Change default task's stacks size, if specified by the example configuration
Initialize the TCP/IP core module
Add one Ethernet controller, if enabled.
Add one WiFi module, if enabled.
Change default the task's priority, if specified by the example configuration
By default, this example will assume the presence of an Ethernet controller and a WiFi module when available in Micrium OS. The example assumes that the default interfaces are named "eth0" for the Ethernet controller and "wifi0" for the WiFi module. |
---|
Configuration#
Mandatory#
The following #define must be added in ex_description.h to allow the default main example (ex_main.c) to initialize the network module correctly:
#define | Description |
---|---|
EX_NETWORK_INIT_AVAIL | Lets the upper example layer know that the Network Initialization example is present and must be called by other examples. |
Optional#
The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:
#define | Default value | Description |
---|---|---|
EX_NET_CORE_TASK_STK_SIZE | Not defined, used default set by the core (1024) | When defined, the default stack size assigned to the TCP/IP core task stack is changed at run time to this value. |
EX_NET_CORE_SRV_TASK_STK_SIZE | Not defined, used default set by the core (512) | When defined, the default stack size assigned to the TCP/IP core services task stack is changed at run time to this value. |
EX_NET_CORE_TASK_PRIO | Not defined, used default set by the core (16) | When defined, the TCP/IP core task priority is changed at run time to this value. |
EX_NET_CORE_SRV_TASK_PRIO | Not defined, used default set by the core (28) | When defined, the TCP/IP core services task priority is changed at run time to this value. |
Location#
/examples/net/core_init/ex_net_core_init.c
/examples/net/core_init/ex_net_core_init.h
API#
API | Description |
---|---|
Ex_Net_CoreInit() | Initialize the Network TCP/IP core and add an Ethernet Interface and/or a WiFi Interface. |
Notes#
This example doesn't start the network core. Once the module is initialized, the network interface must be started as described by Network Core Start Interfaces Example
Start Network Interface(s) Example#
Description#
This is a generic example that shows how to start network interface(s). It accomplishes the following tasks:
If Ethernet is available:
Configure IP addresses
Start the Ethernet Interface
Wait setup completed (DHCP, IPv6 Autoconf and more)
If WiFi is available:
Configure IP addresses
Start the Ethernet Interface
Wait setup completed (DHCP, IPv6 Autoconf and more)
Configuration#
Optional#
The following #define can be added to ex_description.h, as described in Example Applications section, to change default configuration value used by the example:
#define | Default value | Description |
---|---|---|
EX_NET_CORE_IF_ETHER_MAC_ADDR | DEF_NULLUse default provided by the BSP | Specify the MAC address to assign to the Ethernet interface |
EX_NET_CORE_IF_ETHER_IPv4_DHCP_EN | DEF_ENABLED | Specify if DHCP-IPv4 must be performed on the Ethernet interface |
EX_NET_CORE_IF_ETHER_IPv4_STATIC_ADDR | "10.10.10.111" | Change the static IPv4 address to assign to the Ethernet interface.If DHCP fails, you can always access the target using this address.If defined to DEF_NULL, no static address will be configured. |
EX_NET_CORE_IF_ETHER_IPv4_STATIC_MASK | "255.255.255.0" | Specify the static IPv4 address mask to assign to the Ethernet interface. |
EX_NET_CORE_IF_ETHER_IPv4_STATIC_GATEWAY | "10.10.10.1" | Specify the static IPv4 address gateway to assign to the Ethernet interface. |
EX_NET_CORE_IF_ETHER_IPv6_DAD_EN | DEF_DISABLED | Specify if IPv6 Duplicate Address detection must be performed on IPv6 address on the Ethernet interface |
EX_NET_CORE_IF_ETHER_IPv6_AUTOCONF_EN | DEF_ENABLED | Specify if IPv6 Autoconf must be performed on the Ethernet interface |
EX_NET_CORE_IF_ETHER_IPv6_AUTOCONF_DAD_EN | DEF_ENABLED | Specify if IPv6 Duplicate Address detection must be performed on IPv6 Autoconf address on the Ethernet interface |
EX_NET_CORE_IF_ETHER_IPv6_STATIC_LOCAL_ADDR | "fe80::1111:1111" | Change the static IPv6 address to assign to the Ethernet interface.If Autoconf fails, you can always access the target using this address.If defined to DEF_NULL, no static address will be configured. |
EX_NET_CORE_IF_ETHER_IPv6_STATIC_LOCAL_PREFIX_LEN | 64u | IPv6 static address prefix len |
EX_NET_CORE_IF_WIFI_MAC_ADDR | DEF_NULL | Specify the MAC address to assign to the WiFi interface |
EX_NET_CORE_IF_WIFI_IPv4_DHCP_EN | DEF_ENABLED | Specify if DHCP-IPv4 must be performed on the WiFi interface |
EX_NET_CORE_IF_WIFI_SSID | "Wifi_AP_SSID" | Specify the Wi-Fi Access point to connect on |
EX_NET_CORE_IF_WIFI_PASSWORD | "password" | Specify the Wi-Fi Access point password |
EX_NET_CORE_IF_WIFI_IPv4_STATIC_ADDR | "192.168.1.222" | Change the static IPv4 address to assign to the WiFi interface.If DHCP fails, you can always access the target using this address.If defined to DEF_NULL, no static address will be configured. |
EX_NET_CORE_IF_WIFI_IPv4_STATIC_MASK | "255.255.255.0" | Specify the static IPv4 address mask to assign to the WiFi interface. |
EX_NET_CORE_IF_WIFI_IPv4_STATIC_GATEWAY | "192.168.1.1" | Specify the static IPv4 address gateway to assign to the WiFi interface. |
EX_NET_CORE_IF_WIFI_IPv6_DAD_EN | DEF_DISABLED | Specify if IPv6 Duplicate Address detection must be performed on IPv6 address on the WiFi interface |
EX_NET_CORE_IF_WIFI_IPv6_AUTOCONF_EN | DEF_ENABLED | Specify if IPv6 Autoconf must be performed on the WiFi interface |
EX_NET_CORE_IF_WIFI_IPv6_AUTOCONF_DAD_EN | DEF_ENABLED | Specify if IPv6 Duplicate Address detection must be performed on IPv6 Autoconf address on the WiFi interface |
EX_NET_CORE_IF_WIFI_IPv6_STATIC_LOCAL_ADDR | "fe80::1111:2222" | Change the static IPv6 address to assign to the WiFi interface.If Autoconf fails, you can always access the target using this address.If defined to DEF_NULL, no static address will be configured. |
EX_NET_CORE_IF_WIFI_IPv6_STATIC_LOCAL_PREFIX_LEN | 64 u | IPv6 static address prefix len |
Location#
/examples/net/core_init/ex_net_core_init.c
/examples/net/core_init/ex_net_core_init.h
API#
API | Description |
---|---|
Ex_Net_CoreStartIF() | Configure and starts network interface(s) and wait setup complete. |
Notes#
The following API can be called instead of Ex_Net_CoreStartIF() , if you want to control the start flow and you don't want to wait for the setup completion on all interfaces.
API | Description |
---|---|
Ex_Net_CoreStartEther() | Start the Ethernet Interface. |
Ex_Net_CoreStartWiFi() | Start the WiFi Interface. |
Network Socket Example Applications#
This section describes the examples that are related to the TCP/IP module of Micrium OS.
TCP Echo Client#
Description#
This is a generic example that shows how to create a simple TCP echo client. It accomplishes the following tasks:
Open a socket
Configure socket's address
Connect to the server
Transmit data to the server
Receive echo response from the server
Close socket
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_tcp_client.c
/examples/net/socket/ex_net_sock.h
/examples/net/socket/ex_net_sock_tcp_server.py
API#
API | Description |
---|---|
Ex_Net_SockTCP_Client() | Create a TCP Echo client |
Notes#
The file ex_net_sock_tcp_server.py, can be used on any PC to create the associate TCP echo server.
TCP Echo Server#
Description#
This is a generic example that shows how to create a simple TCP echo IPv4 or IPv6 server. It accomplishes the following tasks:
Open a socket
Configure socket's address
Bind the socket.
Receive data on the socket
Transmit to source the data received.
Close socket on fatal fault error.
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_tcp_server.c
/examples/net/socket/ex_net_sock.h
API#
API | Description |
---|---|
Ex_Net_SockTCP_ServerIPv4() | Create an Echo server which accepts IPv4 connection |
Ex_Net_SockTCP_ServerIPv6() | Create an Echo server which accepts IPv6 connection |
Notes#
None
UDP Echo Client#
Description#
This is a generic example that shows how to create a simple UDP echo client. It accomplishes the following tasks:
Open a socket
Configure socket's address
Transmit data to the server
Receive echo response from the server
Close socket.
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_udp_client.c
/examples/net/socket/ex_net_sock.h
API#
API | Description |
---|---|
Ex_Net_SockUDP_Client() | Create an UDP Echo client |
Notes#
None
UDP Echo Server#
Description#
This is a generic example that shows how to create a simple UDP echo IPv4 or IPv6 server. It accomplishes the following tasks:
Open a socket
Configure socket's address
Bind the socket.
Receive data on the socket
Transmit to source the data received.
Close socket on fatal fault error.
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_tcp_server.c
/examples/net/socket/ex_net_sock.h
API#
API | Description |
---|---|
Ex_Net_SockUDP_ServerIPv4() | Create an Echo server which accepts IPv4 connection |
Ex_Net_SockUDP_ServerIPv6() | Create an Echo server which accepts IPv6 connection |
Notes#
None
Multicast Echo Server#
Description#
This is a generic example that shows how to create an UDP Multicast echo server using IPv4 address. It accomplishes the following tasks:
Join the multicast group
Open a socket
Configure socket's address
Bind the socket.
Receive data on the socket
Transmit to source the data received.
Close socket on fatal fault error.
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_mcast_echo_server.c
/examples/net/socket/ex_net_sock.h
API#
API | Description |
---|---|
Ex_Net_SockMCastEchoServer() | Create a Multicast Echo server which accept IPv4 connection |
Notes#
The file ex_net_sock_mcast_echo_client.py, can be used on any PC to create the associate TCP echo client.
TCP SSL/TLS Client Connection#
Description#
This is a generic example that shows how to connect a client to a server over SSL/TLS. It accomplishes the following tasks:
Install CA certificate
Open a TCP socket
Configure socket's option to be secure
Configure socket's address
Connect; establish a secure connection with the server.
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_secure_client.c
/examples/net/socket/ex_net_sock.h
/examples/net/socket/ex_go_daddy.cer
API#
API | Description |
---|---|
Ex_Net_SockSecureClientConnect() | Initialize a client secure socket. |
Notes#
None.
TCP SSL/TLS Server#
Description#
This is a generic example that shows how to create a server that accept secure connection using SSL/TLS. It accomplishes the following tasks:
Open a TCP socket
Configure socket's option to be secure
Bind the socket
Listen
Configuration#
None.
Location#
/examples/net/socket/ex_net_sock_secure_serverc
/examples/net/socket/ex_net_sock.h
API#
API | Description |
---|---|
Ex_Net_SockSecureServerInit() | Initialize server's listen socket to accept connection over TLS/SSL. |
Notes#
None