Contact Us

CATEGORIES

Whoops…Nothing found

Try other keywords in your search

Internet Protocol Guide, TCP and UDP in Control

 4 Minutes

 0 Likes

 86 Views

In this guide we will be going over the Internet Protocol and two Transport Protocols, TCP and UDP. We will describe what these protocols are, how they relate to each other, and how to use TCP and UDP in Pixera Control to send and receive data.



Internet Protocol/IP

The Internet Protocol, IP, is used to have data move between networks and eventually arrive at a preset destination. This data is normally too large to be sent all at once, and so it is sent in smaller ‘packets’. These packets are then received and assembled together at the end destination. Transport Protocols will handle the incoming packets differently with benefits and negatives to their process, the two most common being TCP and UDP.


TCP (Transmission Control Protocol)

The Transmission Control Protocol, or TCP, is seen as reliable because it ensures the packets being received will arrive in the exact order they are meant to. Due to this, TCP requires extra steps and wait time to make sure all packets are present. It first must be connected to the recipient and keep this connection. Also, any missing packets will lead to longer loading time as TCP waits for the packets to be resent.

 

UDP (User Datagram Protocol)

The User Datagram Protocol, UDP, is the opposite of TCP regarding its benefits and negatives. UDP does not create a connection to send or receive packets. The packets will also be delivered in whatever order they arrive and not sorted into the correct order. Due to these stripped features, UDP works quickly, albeit not as reliably.

 

Use Cases

As for deciding whether to use TCP or UDP will depend on the message being sent and the time the message must arrive. If reliability is required with no mistakes in the message's order, then TCP is a safer choice, especially if waiting time is not an issue.

If the message must be sent as quickly as possible, in massive quantities, is simple, or can be organized by the receiver some other way, then UDP is your best bet.

 

TCP in Pixera

There are three prebuilt modules in Pixera Control that can be used for sending and receiving via TCP. These are the ‘TcpServer’, ‘TcpClient’, and ‘TcpConnection’ modules. Each of these modules has a send action which will send a message and may require a handle to receiver (For ‘TcpServer’). Each module also has a receive action which will display the message given from the sender.

 

TcpServer Module

This module will create a TCP server in Pixera for sending and receiving messages to clients. In the module's ‘Properties’ you must set the ‘Port’ and the ‘Adapter IP’ of the server. Keep in mind the ‘Default’ selection of ‘Adapter IP’ will be the selected adapter in ‘Settings/Discovery/Main Network Adapter’. Once inited the server will be created and clients can now connect to the server. The ‘IsOpen’ action will show if the server has a connection and the ‘CTConn’ action will show how many connections there are.

 

TcpClient Module

This module will create a TCP client connection in Pixera for sending and receiving messages from a server. In the module's ‘Properties’ you must set the ‘IP’, ‘Port’, and ‘Adapter IP’ of the TCP server you will connect to. Once inited the client will be created and connect to the server. The ‘IsConnected’ action will show if the client has a connection to a server.

 

TcpConnection Module

This module will allow you to create either a TCP client (Connect Mode) or a TCP server (Listen Mode). This way you can switch between these use cases in one module. However, the module can only provide a single TCP connection unlike the ‘TcpServer’ module which can take multiple client connections. To use the module, you must set a variety of settings in the module's ‘Properties’. These include: ‘Adapter IP’, ‘Mode’ which will be either ‘Connect’ for a client or ‘Listen’ for a server, ‘Port’, ‘Destination IP’, and ‘Reconnect Timeout s’ which will tell the module how long to wait before trying to reconnect using the given ‘Properties’. The ‘IsConnected’ action will show if there is a connection and the ‘IsListening’ action will show if the module is listening as a server.

 

Pixera TCP Example

Here are a couple examples of test setups using the module's discussed.

This first image shows a ‘TcpServer’ module connected to two ‘TcpClient’ modules. As you can see the 'CtConn' action is displaying two connections as a result.

 

In this second image there are now two ‘TcpConnection’ modules. One is set to ‘Listen’, so it is acting as a server, and the other is set to ‘Connect’, so it is acting as a client.

 

UDP in Pixera

There are three prebuilt modules in Pixera Control that can be used for sending and receiving via UDP. These are the ‘Udp’, ‘UdpBroadcast’, ‘UdpMulticast’ modules. The difference between these modules involves how the message is being sent, either via Unicast, Broadcast, or Multicast, respectively.

The ‘Udp’ module sends via Unicast, meaning its message will be sent to one location only.

The ‘UdpBroadcast’ module sends via Broadcast, meaning its message will be sent to all locations on the given IP.

The ‘UdpMulticast’ module sends via Multicast, meaning its message will be able to be sent to multiple locations alongside other Udp Multicast messages.

Each of these modules have a send action which will send a message and a receive action which will display the message given from the sender. Each also has an ‘IsOpen’ action which will display whether the module is ready for sending or receiving messages.

 

Udp Module

This module will create a UDP setup in Pixera for sending and receiving messages. In the module's ‘Properties’ you must set the ‘IP’, ‘Port’ which is the port to send to, ‘Port Receiving’ which is the port to receive a message from. and the ‘Adapter IP’. Keep in mind the ‘Default’ selection of ‘Adapter IP’ will be the selected adapter in ‘Settings/Discovery/Main Network Adapter’. Once inited the module will be ready to send or receive messages.

 

UdpBroadcast Module

This module will create a UDP setup in Pixera set to Broadcast for sending and receiving messages. In the module's ‘Properties’ you must set the ‘Broadcast IP’, ‘Port’ which is the port to send to, ‘Port Receiving’ which is the port to receive a message from. and the ‘Adapter IP’. Keep in mind the ‘Default’ selection of ‘Adapter IP’ will be the selected adapter in ‘Settings/Discovery/Main Network Adapter’. Once inited the module will be ready to send or receive messages.

 

UdpMulticast Module

This module will create a UDP setup in Pixera set to Multicast for sending and receiving messages. In the module's ‘Properties’ you must set the ‘Broadcast IP’, ‘Port’ which is the port to send to, ‘Port Receiving’ which is the port to receive a message from. and the ‘Adapter IP’. Keep in mind the ‘Default’ selection of ‘Adapter IP’ will be the selected adapter in ‘Settings/Discovery/Main Network Adapter’. Once inited the module will be ready to send or receive messages.

 

Pixera UDP Example

Here is an examples of a test setup using the Udp module discussed.

This image shows two ‘Udp’ modules where ‘IsOpen’ is true showing the modules being active and ready to send messages back and forth between each other.

 

Expansion

From these basic modules you can create any module you may need for sending or processing messages going through the protocols. There are also other protocols which can be explored in their own modules, all which can be found in the ‘Control/Library/Protocols’ section of Pixera.

 

Pixera 1.9.175 |13.11.2023

Was this article helpful?