TCP/IP Module Level Design
This document describes the internal functionality of the mbed TLS TCP/IP module.
The module itself is a generic implementation that covers the standard BSD socket and Windows Socket functionality and it is not required to use this Module in combination with the SSL/TLS module. An application is allowed to provide other transport functions instead.
The TCP/IP module provides a generic communication channel. It provides the following basic functions:
This module can be used between hosts to provide a basic means of communication over the internet. There is no interaction with other components.
To setup a TCP/IP communication channel one system must listen and one must connect. The system that listens must accept the connection. Data can then be sent and received. The connection can be closed. The host that listens is called the server and the one that connects is the client. To achieve the above the following functions provided:
All functions are prefixed net_ for coherence.
A server typically listens on an interface to a port for clients that want to connect. When such a connection request is received, the server may accept by binding the local server socket (IP address + port number) to the remote client socket. The TCP/IP channel is then ready for data communication.
A client typically connects to a known host and port. If a server is listening and accepts the connection a TCP/IP communication channel is ready for use.
When a TCP/IP communication channel has been set up (see the sections above) either side can send and receive data. It is advisable to somehow coordinate the sending and receiving of data to avoid collisions. After either side is done sending data it can close the connection.
When a socket is set to blocking it waits when requesting data, with non-blocking it returns with an error code if the requested data is not available.
Only built-in socket and host structures are used.
There is no internal state structure. State is communicated through return codes and by keeping a socket identifier. The following diagrams are typical for TCP/IP client-server communication:
The following scenarios are described:
Setting up a connection
This scenario describes how a connection is set up between a client and a server host.
Failing to setup a connection
This scenario describes how a connection set up between a client and a server host fails.
Complex usage: TCP/IP setup, communication and breakdown
This scenario describes how a TCP/IP communication usually takes place. It covers setup, communication and breakdown.
All uses are: