Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Wiki
    • Web Shop
    • Newsletter
    • RSS
  •   Jobs
  •   Videos
  •   Blog
  •   Sustainability
  • emNet
  • WebSocket
  • Technology
  • Add-Ons
  • Tools
SEGGER - emNet Ethernet Stack

emNet WebSocket protocol

The emNet WebSocket IoT (Internet of Things) protocol is an optional extension to emNet. The WebSocket add-on can be used with emNet or with a different TCP/IP stack that uses a socket API.

  • Converts a synchronous HTTP connection into an asynchronous data connection.
  • Can traverse firewalls using the well known HTTP port.
  • Can be used with or without web server.
  • Seamless integration with emWeb web server.
  • Low memory footprint.
  • Optimized API for embedded systems.
  • Independent of the TCP/IP stack: Any stack with sockets can be used.
  • Project for executable on PC for Microsoft Visual Studio included.
  1. 1.emNet Websocket protocol – ideal for use in many situations
  2. 2.WebSocket backgrounds
  3. 3.Data framing
  4. 4.Principle of operation
  5. 5.Requirements
  6. 6.Resource Usage
  7. 7.Relevant parts

emNet Websocket protocol – ideal for use in many situations

The WebSocket protocol is an encapsulation transport protocol for use on top of the TCP/IP protocol to simplify communication through firewalls. It is simple, lightweight and open. Its characteristics make it ideal for use in many situations, including constrained environments such as for communication in Machine to Machine (M2M) and Internet of Things (IoT) contexts.

WebSocket backgrounds

The WebSocket protocol is an IoT (Internet of Things) protocol that allows to upgrade a regular synchronous HTTP connection into an asynchronous bidirectional data tunnel. It allows to establish a regular HTTP connection with a webserver, checking if both sides, client and server, understand the WebSocket protocol depending on the answer sent back by the webserver.

The non intrusive test for checking the WebSocket protocol being supported is compatible with the HTTP/1.1 standard and will return a page with an error code in worst case if the protocol is not supported by the webserver. The webserver service for serving regular pages remains fully operational while coexisting with the WebSocket protocol.

The WebSocket protocol is using the TCP/IP protocol for data, using the HTTP/1.1 protocol only to initially establish a WebSocket connection.

WebSocket
(Application layer)

Application layer protocol:
VNC / MQTT / ...
Application layerApplication layer protocoll:
Websocket
Transport layerTransport layer protocol:
TCP
Networkl layerLink layer protocol:
IPv4 / IPv6
Link layerLink layer protocol:
Ethernet, WiFi

An advantage of the WebSocket protocol is that it establishes a connection through the HTTP protocol. This allows an easier handling in terms of firewalls as typically the standard port TCP 80 is allowed for outgoing connections, allowing WebSocket clients to work without problems. For a WebSocket server, offering webpages and WebSocket tunneled protocols only a single port is required to be opened in the firewall or allowed to be forwarded by a router from the Internet to your local network.

Data framing

The WebSocket protocol combines the following properties of TCP and UDP:

TCP properties

  • Lost data is retransmitted.
  • Data is received in the correct order.
  • The connection status can be checked by using TCP KEEPALIVES.

UDP properties

  • Data can be sent in small frames (while being part of a larger message).
  • The length of the frame is known (the complete message length is not).
  • Control frames (UDP: other data) can be sent between data frames.

Principle of operation

Application data sent using the WebSocket protocol can be described as UDP like framing of data within a TCP data stream. While this might sound complex at first, the protocol itself is not.

The main purpose of the WebSocket protocol is to allow a device with limited resources sending one big block of data in chunks (called a frames in the WebSocket protocol) whenever data is ready/generated instead of collecting the data before sending. At the same time control commands should be able to be processed anytime between frames. At the same time the TCP protocol ensures that data is not lost and frames will be sent and received in the correct order.

The WebSocket protocol achieves these goals by sending all data in frames that have a header upfront. The encapsulation of the protocol is shown below:

 

WebSocket_LayerEncapsulation

Requirements

TCP/IP stack: The emNet WebSocket add-on requires a TCP/IP stack. It is optimized for emNet, but any RFC-compliant TCP/IP stack that has a socket API can be used. The shipment includes a Win32 simulation, which uses the standard Winsock API as well as an implementation which uses the socket API of emNet.

Resource Usage

The ROM usage depends on the compiler options, the compiler version and the used CPU. The memory requirements of the WebSocket add-on presented in the tables below have been measured on a Cortex-M4 system. Details about the further configuration can be found in the sections of the specific example.

The following resource usage has been measured on a Cortex-M4 system using SEGGER Embedded Studio V3.10e, size optimization.

ROM Usage on an Cortex-M4 System

Add-onROM
emNet WebSocket protocolApproximately 1.7 KByte

RAM Usage on an Cortex-M4 System

Add-onRAM
emNet WebSocket contextApproximately 30 bytes

Relevant parts

DocumentDownload
[RFC 6455]Direct link: The WebSocket Protocol

More Information

Purchase

  • Pricing

Technology

  • Drivers
  • FIND protocol
  • IPv6
  • Performance
  • Port Multiplication
  • Resource usage
  • Structure
  • Tasks & Interrupt Usage
  • Ethernet-APL

Add-Ons

  • CoAP Server/Client
  • Domain name resolution
  • NetBIOS
  • NTP Client
  • PPP/PPPoE
  • PTP OC Client
  • SMTP Client
  • SNMP Agent
  • SNTP Client
  • UPnP
  • WebSocket

Tools

  • embOS/IP Switch Board

About us

  • The Company
  • Partners
  • Job Offers
  • Media
  • Contact us

Support

  • Technical Support
  • Blog
  • Forum
  • Wiki

Downloads

  • Application Notes
  • Embedded Studio
  • embOS
  • emCompress
  • emCrypt
  • emFile
  • emLib
  • emLoad
  • emModbus
  • emNet
  • emPower
  • emSecure
  • emSSH
  • emSSL
  • emUSB-Device
  • emUSB-Host
  • emVNC
  • emWin
  • Flasher
  • Free Utilities
  • IoT
  • J-Link / J-Trace
  • Linux Studio
  • SystemView
  • CE / REACH

Social Media

Headquarters

SEGGER Microcontroller GmbH

Ecolab-Allee 5
40789 Monheim am Rhein, Germany
info@segger.com
Tel.: +49-2173-99312-0
Fax: +49-2173-99312-28

Locations

USA: SEGGER Microcontroller Systems LLC

Boston area
101 Suffolk Lane
Gardner, MA 01440, USA
us-east@segger.com
Tel.: +1-978-874-0299
Fax: +1-978-874-0599

Silicon Valley
Milpitas, CA 95035, USA
us-west@segger.com
Tel.: +1-408-767-4068

China: SEGGER Microcontroller China Co., Ltd.

Room 218, Block A, Dahongqiaoguoji
No. 133 Xiulian Road
Minhang District, Shanghai 201199, China
china@segger.com
Tel.: +86-133-619-907-60

ISO 9001 certified

ISO 9001

30+ years of experience

First-class embedded software tools since 1992
  • Imprint
  • Disclaimer
  • Privacy Policy

© 2023 SEGGER - All rights reserved.