RawIpSocket Sample

Description

This sample runs a raw IP echo client and/or raw IP echo server, depending on the specified command line options.

Source Files

File Description
RawIpSocket .h Header File.
RawIpSocket.c Source File.
RawIpSocket_VS<Visual Studio Version>.vcxproj Project file for supported versions of Visual Studio.
RawIpSocket_VS<Visual Studio Version>.vcxproj.filters Filters file for supported versions of Visual Studio.
RawIpSocket_VS<Visual Studio Version>.sln Solution file for supported versions of Visual Studio.

Building the Sample

Build the sample using either the RTSSRelease or RTSSDebug build configurations.

Running the Sample

  1. Run the sample as a server on an RTX64 system with the RT-TCP/IP Stack running.
  2. Run the sample as a client on a second RTX64 system with the RT-TCP/IP Stack running.

NOTE: Both systems must have a physical Ethernet interface with the configured IPv4 address. The interfaces must be connected via the Ethernet switch or connected directly.

Usage

Server example: rtssrun RawIpSocket

Client example: rtssrun RawIpSocket /c server_ipv4_address

Options

Server options:

/b source_ip_address – the IPv4 address to bind the socket to, if specified

/w socket_window – the socket window, default is 500000 (SO_SNDBUF and SO_RCVBUF socket options)

/m packet_count – the packet count, the default behavior is to run forever

/r report_count – the report count, default is 500

 

Client Options:

/c destination_ip_address – the server IPv4 address

/b source_ip_address – the IPv4 address to bind the socket to, if specified

/w socket_window – the socket window, the default is 500000 (SO_SNDBUF and SO_RCVBUF socket options)

/m packet_count – the packet count, the default count is 10000

/r report_count – the report count, the default count is 500

/l packet_size – the packet size, the default size is 1024 (4 to 65515, IP header not included)

/t select_tout_ms – the timeout of the select socket call, in milliseconds. If the client does not receive a response before this timeout, it sends the next packet. The default timeout is 1000 (used only on receive).

/h (1/0) – 1 means include IP header on send, the default is 0 (don’t include the IP header)

Remarks

The RawIpSocket sample runs one raw IP socket per upper-level protocol. This sample uses the protocol number 250.

This sample binds the socket to the IP port 0x7FFF, which is used as the RAW IP port by the RT-TCP/IP Stack.

The client has a flag for demonstrating how to include the IP header with outgoing packets (/h 1). The sample does not include IP header by default, which is different from standard RT-TCP/IP stack outgoing packets. Received packets always include the IP header.

The RawIpSocket sample only supports the RTSS Release and RTSS Debug build configurations. This sample cannot be built as a Windows application.

The connect() is not supported by RT-TCPIP Stack, the application must use sendto() and recvfrom().

There is a known issue where the RT-TCP/IP Stack sends and reassembles IP datagrams for a raw IP socket greater than 64K.

APIs Referenced

RTAPI

Supported Windows API

Winsock BSD API

See Also

Using RAW Sockets