Feedback
Feedback

Click or drag files to this area to upload. You can upload up to 2 files.

Network protocol stack

As we saw in Lesson 1, the actual Wi-Fi protocol stack consists of the lower two layers, MAC and PHY, running on the nRF70 Series. The host MCU, on the other hand, consists of all the upper layers needed for network communication.

Let’s take a look at the different layers that make up the network protocol stack.

Wi-Fi Driver

The Wi-Fi driver, or the WI-Fi host stack as it is also called, is the lowest layer running in the host MCU and is mainly responsible for interfacing with the Wi-Fi stack running on the nRF70 Series IC.

The driver communicates with the nRF70 Series IC using the SPI/QSPI interface. The driver uses the QSPI/SPI interface to send commands to the nRF70 Series IC, and to transfer the data to and from the device.

L2

The layer above this contains the L2 network technology responsible for routing the Wi-Fi traffic beyond the Wi-Fi access point.

The driver supports the following L2 technologies:

  • Ethernet
  • 802.15.4
  • Bluetooth
  • PPP

The most common one is Ethernet, which is used in the Wi-Fi samples in the nRF Connect SDK. This is enabled through the Kconfig CONFIG_NET_L2_ETHERNET.

IPv4 and IPv6

The layer above this again defines the Internet Protocol address (IP address), which essentially provides the location for the IP packet.

The original IP address (IPv4) defines the addresses as 32-bit numbers, but due to the expansion of the Internet, this turned out to be too few addresses. As a solution, IPv6 was introduced, which defines the addresses as 128-bit numbers. These two versions are in simultaneous use today.

These are enabled through the Kconfigs CONFIG_NET_IPV4 and CONFIG_NET_IPV6.

TCP and UDP

On top of this, we have the transportation layer, which is made up of two communication protocols, the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).

  • TCP is a connection-oriented protocol that uses a three-way handshake to establish a connection between server and client before beginning to send data. It provides reliable, ordered and error-checked delivery of a stream of bytes.
  • UDP is a connectionless protocol that does not require an established connection, but rather transmits packets (called datagrams) directly to the receiver. As opposed to TCP, this does not provide ordered or error-checked delivery.

Being a simpler protocol, UDP has fewer overhead bits and no handshake. This creates a number of advantages such as the lower power consumption associated with the absence of handshakes. However, this can lead to a higher data loss and packets can arrive out of order but can be solved by the application protocol.

On the other hand, TCP is a more complex protocol. It offers packet awareness, which means the transceivers are aware of the order of packets being sent so any lost packet can be detected and re-transmitted and any disruption in the packet order can be corrected. Of course, this results in increased overhead and power consumption.

TLS and DTLS

On top of this, we have either Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS), which provide security for TCP and UDP, respectively.

  • TLS is an encryption protocol designed to provide security over a TCP connection. When establishing a connection between the server and client, the client requests a TLS connection. One of the main ways of achieving this is to use a different port number for TLS connections.
  • DTLS is an implementation of TLS that is specifically designed to be used over datagram-based communication and is intended to provide similar security guarantees. To do this, DTLS requires a handshake prior to transmitting messages, where each handshake packet has a specific sequence number to solve the fact that UDP does not provide ordered delivery.

From an application perspective, the difference between using TLS and DTLS is insignificant, as both protocols provide the same type of security.

Sockets

The next layer in the network protocol stack is the socket API. The socket API is what the application and the application layer protocols use to interface with the protocol stack.

A network socket is a software endpoint that allows communication between different processes or applications over a network. It provides a programming interface for network communication, enabling processes running on different devices to exchange data.

In a network communication scenario, you can think of a socket as a door through which information can enter or leave a device. It acts as a communication channel that facilitates data transmission between two endpoints, typically on different devices connected to a network.

Sockets use the client-server model, where one device acts as a server and waits for incoming connections, while another device acts as a client and initiates the connection. The server socket listens for incoming requests, and the client socket establishes a connection with the server socket.

Definition

Socket: A socket is a software structure that serves as an endpoint for sending and receiving data across a network.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

Forgot your password?
Enter your email address, and we will send a link to reset your password.