TCP Server Help Documentation
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.
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.
# TCP Server Details
TCP_PORT_NO = 2000
JSON_FILE = ./conf/tcp_config.json
CUSTOMSTORAGE = ENABLED
# ENABLED || DISABLED
DATASTORE = ELASTIC
# ELASTIC || CUSTOM
HOSTNAME = 127.0.0.1
PORT = 9200
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
You can Store data in MySQL in tables TCP_ENTRY and TCP_RECEIVE. You can also 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.
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.
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.
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.
If you are using the SQlite storage for the TCP Server, then the database will be created and stored inside this folder.
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.
This folder contains the license agreement and license file that represent the TCP Server permissions and the other softwares used in the product.