TCP/IP Components
The TCP/IP Protocol Stack communicates with the Network Link Layer (NL2) that accesses the physical transport layer (network card) via a Real-time network device (RTND) driver running under the Real-Time Kernel. The components that make up the TCP/IP Stack are discussed below.
The NL2 loads network drivers and the TCP/IP Stack uses the drivers while running as a NL2 application. See
The NL2 supports delivering data to the specific receive queue by Ethernet type filtering. Multiple NL2 applications can use different network queues of the same interface. The TCP/IP Stack, running as a NL2 application, uses the default receive queue of the interface (which receives unfiltered data) and the transmit queue with the same number. Other NL2 applications can use other network queues of the interface at the same time.
The TCP/IP stack consists of an internal buffer management system, timer system, and, when running, uses multiple threads to accomplish its tasks. The priority of each thread can be set independently. The timer system of the TCP/IP stack uses a stack internal timer thread to handle all TCP/IP time-related functions.
Each network interface runs an interrupt service thread that handles all interrupt-related processing, and a receiving thread that handles all receive-related processing.
You can configure the TCP/IP Stack in the eRTOS RtConfig.rtreg file.
TCP/IP Stack Components
Buffer Management
The TCP/IP stack has an internal buffer management system for performance reasons. It is architected to statically allocate memory upon Stack startup. Buffers used by network drivers to receive and transmit data are not part of this memory. Packet data, sent and received by the stack, is copied by network drivers in driver receive and transmit functions.
The amount of memory needed by the Stack depends on many factors, including the size of your socket queue, the size of application buffers for transfer, the number of sockets, and the number of network interfaces, as well as the number of pre-allocated receive buffers for the device. Most of the pre-allocated memory by the Stack is used for your data. Internally, the TCP/IP stack uses very minimal data.
Memory Requirements
The TCP/IP Stack, when running, needs a block of memory to store its internal information (packet buffers and various control information). This block of memory is allocated during startup and is of fixed size specified by the Memory allocated for the TCP/IP Stack heap setting configured in the RtConfig.rtreg file The memory to allocate depends on how much memory is available on the system and how much network traffic is expected.
If you are not sure how much memory should be allocated for stack use, use a large value, such as 10,000. Fatal errors can occur when too little memory has been allocated to the TCP/IP Stack. The TCP/IP Stack will return WSAENOBUFS
to an application when memory reserves have been exhausted. This provides an indication to the user to increase this value.
Stack Timer System
The stack timer system is the one of the main components of TCP/IP. It is responsible for notifying the Stack of the amount of time that has elapsed. This is very important for a protocol stack. The TCP/IP stack must know how long a TCP packet takes to get to a remote system. The Stack must also know the amount of time an ARP entry has been in the ARP table. Additionally, the stack timer system uses a timer for its internal routing entries. The Stack uses a timer thread to handle all TCP/IP timer-related functions.
Related topics:
Receive Thread
The primary purpose of the TCP/IP Stack’s receive thread is to wait on notification from a driver’s Interrupt Service Thread (IST). Whenever there is new packet to be received, the driver’s IST signals the receive thread. The receive thread then starts processing the incoming packet from the device driver. It first calls the driver’s receive routine (RtndReceive() ) through the NL2, and then begins processing the packet. The Stack uses receive thread, which you can configure in the RtConfig.rtreg file, to process all incoming packets.
Interrupt Service Thread (IST)
The Interrupt Service Thread (IST) located in the interfacing driver is called within the context of the NL2 process. The IST is scheduled to run when an interrupt from the network interface card (NIC) occurs. The IST normally responds to receive interrupts by acknowledging the NIC for the interrupt and then signaling the receive thread.
Interface
An interface is used by the NL2 to associate an address with a Real-time Network Device (RTND) driver, which is responsible for configuring and interacting with Network Interface Cards (NICs). All NICs used by RTND drivers must be controlled by eRTOS.
Ethernet Filter Driver
An Ethernet Filter Driver is associated with an interface. It is primarily used to filter all incoming and outgoing traffic, and to generate new network traffic.
Loopback
The Loopback feature requires the TCP-IP Stack to be running. For more information on this feature, see the Multicast Data Reflector sample.
Related topics: