logo slogan

embOS/IP

TCP/IP structure

 

 

embOS/IP


embOS/IP is a CPU independent TCP/IP stack. embOS/IP is a high- performance library that has been optimized for speed, versatility and memory footprint. It is is written in ANSI C and can be used on virtually any CPU.

 

 

Main features

 

ANSI C socket.h-like API for user applications. An application using the standard C socket library can easily be ported to use embOS/IP.

 

For IPv6 there is an additional moduel click here

 

  • Very simple device driver structure.

  • High performance

  • Small footprint

  • Runs "out-of-the-box"

  • No configuration required

  • Works seamlessly with embOS in multitasking environment

  • Zero data copy for ultra fast performance

  • Standard sockets Interface

  • Raw Socket Support

  • Non-blocking versions of all functions

  • Connections limited only by memory availability

  • Nagle Algorithm (Slow start)

  • Delayed ACKs

  • BSD style "Keepalive" option

  • Re-assembly of fragmented packets

  • Optional drivers for the most common devices are available.

 

For IPv6 there is an additional moduel click here

 

embOS/IP is offered in a BASE package which includes the most important protocols related to Ethernet communication and the stack itself. Depending on the engineer's needs there are several protocols available as an add-on as well as the embOS/IP PRO software which adds a device driver, web serverfunctionality and email client for extended communication via Internet.

 

Additional modules

embOS/IP BASE

embOS/IP PRO

Device driver

ACD
ARP
AutoIP
DHCPc
DHCPs
DNSc
FTP Client*
FTP Server*
ICMP
IPv4
IPv6*
Loopback device
Multicast
NetBIOS Name Service*
PPP/PPPoE*
RAW Sockets
SMTP Clien*t
SNTP Client*
TCP
UDP
UPnP*
VLAN
Web Server*

 

Included          Optional

 

ACD (Address Collision Detection)

The embOS/IP ACD module allows the user specific configuration of the behavior if an IPv4 address collision is detected. This means that more than one host in the network is using the same IPv4 address at the same time. This is discovered sending ARP discover packets to find hosts with the same addresses in the network.

 

ARP (Address Resolution Protocol)

Communication between specific Ethernet participants is done in knowledge of their hardware addresses (MAC). ARP (Address Resolution Protocol) is a protocol to resolve the MAC address behind an IP address

in a network by sending broadcast ARP requests asking the client with the desired IP address to answer back with its MAC address that is needed for further direct communication between these two Ethernet participants.

 

AutoIP

The embOS/IP AutoIP module adds the dynamic configuration of IPv4 Link-Local addresses to embOS/IP. This functionality is better known as AutoIP. The AutoIP implementation covers the relevant parts of the RFC 3972.

In general AutoIP is a method to negotiate a IPv4 address in a network without the utilization of a server such as a DHCP server. AutoIP will try to use IPv4 addresses out of a reserved pool from the addresses 169.254.1.0 to 169.254.254.255 to find a free IP that is not used by any other network participant at this time.

To achieve this goal AutoIP sends ARP probes into the network to ask if the address to be used is already in use. This is determined by an ARP reply for the requested address. Upon an address conflict AutoIP will generate a new address to use and will retry to use it by sending ARP probes again.

 

DHCP (Dynamic Host Configuration Protocol)

DHCP stands for Dynamic Host Configuration Protocol. It is designed to ease configuration management of large networks by allowing the network administrator to collect all the IP hosts soft configuration information into a single computer. This includes IP address, name, gateway, and default servers. Refer to [RFC 2131] - DHCP - Dynamic Host Configuration Protocol for detailed information about all settings which can be assigned with DHCP.

DHCP is a client/server protocol, meaning that the machine with the DHCP database serves requests from DHCP clients. The clients typically initiate the transaction by requesting an IP address and perhaps other information from the server. The server looks up the client in its database, usually by the client's media address, and assigns the requested fields. Clients do not always need to be in the server's database.

If an unknown client submits a request, the server may optionally assign the client a free IP address from a pool of free addresses kept for this purpose. The server may also assign the client default information of the local network, such as the default gateway, the DNS server, and routing information.

 

DNS (Domain Name System)

As IP addresses in a large network or even the internet are hard to remember the Domain Name System provides a mechanism to resolve the IP address assigned to a domain from a DNS server. This can either be an internet DNS server resolving requests for a domain into the assigned IP address or even a local DNS server that might be part of an Active Directory infrastructure, answering local name requests to find out the IP address of a company internal server as well as forwarding requests not known to its own database to an internet DNS server.

 

ICMP (Internet Control Message Protocol)

The ICMP (Internet Control Message Protocol) can be used to determine the status of participants in a network by providing the possibility to send test data to another client and receiving an answer to that. This way ICMP provides a simple way to determine the availability of another network participant.

Typically ICMP is a good test when it comes to problems in a network as a first test to check if the other side is generally available. On most operating systems the simple command "ping" can be used to utilize ICMP. Most ICMP clients provide statistics most important the "ping" that shows the responsiveness of a network and between two participants by the time the request took to be answered.

 

IPv4 (Internet Protocol v4)

The IPv4 (Internet Protocol version 4) is the main protocol used in nowadays networks and the internet. IPv4 is typically presented in a dotted decimal form of four numbered blocks with values from 0 to 255 . Each block is presented by one single byte resulting in a block of four bytes when being presented in hexadecimal.

Combined with a netmask of the same characteristics network segments can be built to separate a network infrastructure into smaller blocks such as reserved ranges that can be freely used for private networks such as a home network as well as global ranges assigned and maintained by the IANA (Internet Assigned Numbers Authority) department that is part of the ICANN (Internet Corporation for Assigned Names and Numbers).

 

Loopback device

The loopback device registers an interface with the address 127.0.0.1/8 that allows accessing services on the same device. This allows a client to access a server resource on itself.

 

Multicast

Multicast is a technique to distribute a packet to multiple receivers in a network by sending only one packet. Handling of who will receive the packet is not done by the sender but instead is done by network hardware such as routers or switched hubs that will duplicate the packet and send it to everyone that participates the chosen group.

The target does not actively participate by sending a join request. The network hardware periodically broadcasts membership queries throughout the network that have to be answered with a membership report in case we want to participate in the queried group.

 

RAW Sockets

RAW sockets describes the possibility to freely send and receive data not using typical protocols such as TCP and UDP and their overhead. RAW sockets can be used to define and use a new protocol as the data can either be sent with a typical IP header being generated for data to be sent or completely defining the entire packet data excluding the transport layer header such as the Ethernet header for own purposes.

This allows implementing new protocols as well as building hardware that is able to accept incoming data that does not rely on TCP or UDP protocol or even to build network traffic capture devices that log the incoming data.

 

TCP (Transmission Control Protocol)

TCP (Transmission Control Protocol) is a connection oriented protocol used between two network participants where one participant acts as server listening to incoming connections and the other one acting as client establishing a connection to the server. Once a connection is established both sides are able to send and receive freely.

TCP is secured against packet loss by using a handshake mechanism known as "ACK" not necessarily relying on only sending one packet per ACK. Packets that are lost during a session can be recovered as each side knows which data has been ACKed by the other side as received and can retransmit the lost data.

TCP is the right protocol for all kind of data transfers where the data content is important and no data might get lost. TCP is used by many application protocols such as HTTP, FTP, SMTP and many others.

 

UDP (User Datagram Protocol)

UDP (User Datagram Protocol) is a connectionless protocol that can be used to address data to one network participant by sending to its IP address directly or to distribute data to the whole network by sending data to a network broadcast address.

UDP does not recognize lost packets but is faster due to not maintaining a session. It is typically used for applications that rely on throughput such as live video/audio streaming where it does not matter when a packet gets lost in between. UDP broadcasts are typically used by applications where the location of the other side is yet to be discovered.

Typical samples for such applications is a DHCP client searching for a DHCP server or a client trying to discover one or more devices with yet unknown addresses in a network.

 

VLAN (Virtual Local Area Network)

VLAN technology can be used to separate multiple devices operating on the same physical network into completely separated networks without seeing each other. A typical usage would be to have 2 departments separated from each other but using the same infrastructure such as a shared switch or router. Only devices using the same VLAN ID will be able to see each other.

For this to happen 4 bytes are added in front of the packet type field in the Ethernet frame pushing the original packet type field back by 4 bytes. The Ethernet frame will still be of a maximum length 1518 bytes including CRC what means that instead of a maximum of 1500 bytes that can be transferred the amount of bytes that can be transferred per Ethernet frame will shrink to 1496 bytes per packet.

VLAN tagged packets are typically forwarded by any switch as they are as the type field has been simply replaced and in most cases only the destination MAC, source MAC and packet type is checked. In this case the packet is simply of an unknown protocol and will be forwarded by the switch.

 

 

Basic concepts

 

embOS/IP structure

embOS/IP is organized in different layers, illustrated in the follwoing diagram. A short description of each layer's functionality follows below.

 

Application layer

The API Layer is the interface between embOS/IP and the user application. It uses the embOS/IP API to transmit data over an TCP/IP network. The embOS/IP API provides functions in Berkley socket style, such as connect(), bind(), listen(), etc.

 

Transport layer

The transport layer provides end-to-end communication services for applications. The two relevant protocols of the transport layer protocol are the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP). TCP is a reliable connection-oriented transport service. It provides end-to-end reliability, resequencing, and flow control. UDP is a connectionless transport service.

 

Internet layer

All protocols of the Transport layer use the Internet Protocol (IP) to carry data from source host to destination host. IP is a connectionless service, providing no end-to-end delivery guarantees. IP datagrams may arrive at the destination host damaged, duplicated, out of order, or not at all. The Transport layer is responsible for reliable delivery of the datagrams when it is required. The IP protocol includes provision for addressing, type-of-service specification, fragmentation and reassembly, and security information.

 

Link layer

The Link layer provides the implementation of the communication protocol used to interface to the directly-connected network. A variety of communication protocols have been developed and standadized. The most commonly used protocol is Ethernet (IEEE 802.3). In this version of embOS/IP is only Ethernet supported.

 

 

Encapsulation

The four layers structure is defined in RFC 1122. The data flow starts at application layer goes over the transport layer, the network layer, and the link layer. Every protocol adds an protocol-specific header and encapsulates the data and header from the layer above as data. On the receiving side the data will be extracted in the complementary direction. The opposed protocols does not know which protocol on the layers above and below are used. The following illustration shows the encapsulation of data within an UDP datagram within an IP packet.

 

encapsulation

 

    Tasks and interrupt usage

     

    embOS/IP can be used in an application in three different ways.

    • One task dedicated to the stack

    • Two tasks dedicated to the stack

    • Zero tasks dedicated to the stack (Superloop)

    The default task structure is one task dedicated to the stack.

     

    One task dedicated to the stack

    This is the simplest way to use the TCP/IP stack. One task is dedicated to the stack. It is called IP_Task and handles housekeeping operations, resends and handling of incoming packets. The "Read packet" operation is performed from within the ISR. Since the "Read packet" operation is called directly from the ISR, no additional task is required. The length of the interrupt latency will be extended for the time period which is required to process the "Read packet" operation.

    one task

     

     

    Two tasks are dedicated to the stack.

     

    The first is called IP_Task and handles housekeeping operations, resends and handling of incoming packets. The second one is called IP_RxTask and handles the "Read packet" operation. IP_RxTask is woken up from the interrupt service routine, if new packets are available. The interrupt latency is not extended, since the "Read packet" operation has been moved from the interrupt service routine to IP_RxTask.

 

two tasks

 

 

Zero tasks dedicated to the stack (Superloop)

 

embOS/IP can also be used without any additonal task for the stack, if an application task calls periodically IP_Exec(). The "Read packet" operation is performed from within the ISR. Since the "Read packet" operation is called directly from the ISR, no additional task is required. The length of the interrupt latency will be extended for the time period which is required to process the "Read packet" operation

 

zero tasks