Introduction

In the Internet of things world, most of the components are sensors that sends data to the central server. The data can be either Binary or Text based. The TCP Server can be used to collect such data with simple custom format to reduce bandwith usage. This document provides a simple step by step guide to set up the Server.

TCP Data Configuration

The TCP Packet can be custom defined as you needed. The configuration of the TCP Data should be provided in a JSON format. The data packet has two parts, the control part and the payload. The Control byte should be as specified in the configuration below.

conf/tcp_conf.json

{
"control_byte": {
"next": 1,
"packet_order": 2,
"dup": 1,
"qos": 1,
"reserved": 2,
"keepalive": 1
},
"Packet_Id": 2,
"Payload_length": 2,
"seqno": 2,
"client_id_length": 1
}

The payload_length should be less than 4. The numbers in the configuration represents the number of bytes allocated for the particular data fragment.

The default definition file is placed inside tcp_conf.json

TCP Server Configuration

The TCP Server by default starts at port 2000 and can be customized to run on a different port in the TCPServer.conf. If you want to use any port below 1024, you need to run the TCP Server as Sudo user of Linux or Mac or Administrator in Windows. Further the TCP Format to be used by the TCP Server needs to be specified in this configuration file.

conf/TCPServer.conf

# TCP Server Details
[TCP]
TCP_PORT_NO = 2000
JSON_FILE = ./conf/tcp_config.json
#############################CUSTOM STORAGE###########################
[DATASTORE]

CUSTOMSTORAGE = ENABLED
# ENABLED || DISABLED

DATASTORE = ELASTIC
# ELASTIC || CUSTOM

[ELASTIC]
HOSTNAME = 127.0.0.1
PORT = 9200

[CUSTOM]
INTERCEPT_FILEPATH = ./lib/custom_store.py

Starting TCP Server

You can start the TCP Server using the runTCPServer.sh/.bat inside the bin/ folder. The TCP Server will be ready to receive the data from your edge devices

Default Data Storage

store it in MySQL in tables TCP_ENTRY and TCP_RECEIVE. You can write your own visualization as needed. We are working on the visualisation as part of the IOT Platform which will be available in the upcoming version.

TCP_ENTRY table will have details of the connected clients, their remote IP address and connection log. TCP_RECEIVE will have data of the received data. The table columns will be based on the defined data fromat.

Custom Data Storage

The TCP Server also provides a custom data storage option into the Big data engines. You can enable the storage to Elastic and the Elastic integration works by default. If you want to choose some other Big data engine like GE Predix or some ML like Apache Spark ML or Storm, you can implement a custom interface like custom_store.py present inside the lib/ folder.

Building TCP Client

The TCPClient.c file in the lib/ folder will have an example code on C for sending data to the Server. This code is written based on the tcp_config.json present in the conf/ folder. Contact Support if you are looking for any help in building clients.

Package Structure

This gives you the details about TCPServer Product Package. When you unzip the file, a folder Bevywise will be created. The contents of the TCPServer are in BevyWise/TCPServer/ location.

bin/

This folder contains the executable file required to run TCP Server. The runTCPServer.sh file runs the TCPServer for Linux, MAC and Raspbian OS. The Windows version does not have the bin/ folder and the executable exe will be avlailable below the Bevywise/TCPServer folder.

conf/

In this folder the configuration file for the TCPServer are stored. The tcp_config.json to specify the data format, tcpserver.conf to enable/ disable custom storage and modifying the port and tcp conf file, db.conf to update MySQL information are available inside this folder.

data/

If you are using the SQlite storage for the TCP Server, then the database will be created and stoerd inside this folder.

lib/

This folder contains the core library files which are required for connecting the clients with the TCPServer and sample client programs which can be used to test and work with the TCP Server.

license/

This folder contains the license agreement and license file that represent the TCP Server permissions and the other softwares used in the product.