Professional Documents
Culture Documents
Web Interface
AN_0014_KA_Web_0v3
Date: 2015/03/31
Summary
1Foreground...........................................................................................................3
1.1Local laws restrictions .....................................................................................................................3
1.2Document Copyrights ......................................................................................................................3
1.3Disclaimer ........................................................................................................................................3
1.4Modifications ....................................................................................................................................3
2Changelog............................................................................................................4
3Introduction to Kairos.............................................................................................5
4Introduction to Radio Activity Remote Control Tools ...................................................6
4.1Setup and Management Tools Family..............................................................................................6
4.2Monitor and Surveillance Tools Family.............................................................................................6
5Integrated Web Server...........................................................................................7
5.1Security.............................................................................................................................................7
5.2Brief Manual Reference....................................................................................................................8
5.2.1Installation.................................................................................................................................8
5.2.2Login.........................................................................................................................................9
5.2.3Overview.................................................................................................................................10
5.2.4Audio.......................................................................................................................................12
5.3Customization example: Radioactivity Operator Station................................................................13
5.3.1Configuration..........................................................................................................................13
5.3.2Overview/Home......................................................................................................................15
5.3.3Audio.......................................................................................................................................16
5.4Technical overview.........................................................................................................................18
5.4.1Login Page..............................................................................................................................18
5.4.2DSP Page...............................................................................................................................21
5.4.3Send Pocsag Message...........................................................................................................25
6Introduction to HTTP Protocol................................................................................27
6.1Overview.........................................................................................................................................27
6.2HTTP session.................................................................................................................................27
6.3Request methods ..........................................................................................................................27
6.4HTTP session state........................................................................................................................28
6.5Encrypted connections...................................................................................................................28
6.6Request message...........................................................................................................................28
6.7Response message........................................................................................................................28
6.8Example session............................................................................................................................29
7Introduction to WebSocket Protocol........................................................................30
7.1Technical overview.........................................................................................................................30
7.2WebSocket protocol handshake.....................................................................................................30
7.3URI scheme....................................................................................................................................31
8Introduction to JSON ...........................................................................................32
9References..........................................................................................................35
9.1RFC References.............................................................................................................................35
9.2DMR References............................................................................................................................35
9.3Radio Activity Informative Documents............................................................................................35
9.4Radio Activity Manuals...................................................................................................................35
1 Foreground
This manual is intended for use by experienced technicians familiar with RF and IP technology, and in particular:
• analog and digital transmission
• DMR features and protocols
• data networks (LANs)
• data exchange protocols and standards
• basic concepts of electronic.
This document is not intended to deepen the basic knowledge, unless some brief clarification where needed., it
contains information required for installation, setup and maintenance of a KAIROS based radio infrastructure.
The information in this document is subject to change without notice and its only purpose is to describe the
product specified in the introduction section.
This document is dedicated to the Radio Activity partners only, and may not be in any part reproduced or
retransmitted in any form or mean without an explicit written authorization of Radio Activity Srl.
1.3 Disclaimer
The information in this document are carefully controlled, up-dated and are believed to be entirely reliable.
However, no responsibility is assumed for inaccuracies. Furthermore, Radio Activity reserves the right to make
changes to any products herein to improve readability, function, or design. Radio Activity does not assume any
liability arising out of the applications or use of any product or circuit described herein; nor does it cover any
license under its patent rights nor the rights of others.
1.4 Modifications
CAUTION: Changes or modifications not expressly approved by RF Innovations may void the user’s authority to
operate the equipment legally, as well as any warranty provided.
2 Changelog
3 Introduction to Kairos
The KA-XXX is a “soft radio” in which all the mo-demodulation and filtering processes are achieved through SW
algorithms implemented in Digital Signal Processing (DSP) devices. This technique assures repeatability and
perfect matching between the base stations.
Since a new protocol or a new standard is only a SW upgrade, the investment is future proof.
The KA-XXX has got an effective SW and HW platform that realizes a powerful embedded workstation. Its LINUX
core, thanks to the continuous upgrading from thousands of developers around the world, interfaces naturally IP
devices and networks. It allows also an high level of customizations to satisfy the most exigent Customer’s
needs, without troubles and reducing the development time.
The radio performances are at the top level in the market, because it is designed for infrastructure applications
where radiofrequency pollution is a well known problem.
Excellent resistance to adjacent channel and blocking, noiseless transmitter and soft diversity reception reduce
in-field troubles and give excellent coverage and clean communications .
5.1 Security
To ensure safe access to the equipment are implemented the following functionality:
• SSL Secure Protocol: in addition to the standard HTTP it is the result of simply layering the Hypertext
Transfer Protocol (HTTP) on top of the SSL or TLS protocol, thus adding the security capabilities of
SSL/TLS to standard HTTP communications protocol on port 80 is also implemented the security
protocol HTTPS
• HTTP Session: to ensure the identity of the user and its rights in all operations are used HTTP sessions,
authentication cookies are the common method used by web servers to know whether the user is
logged in or not, and which account they are logged in with
5.2.1 Installation
Although no installation is needed for Kairos Web Interface, to use it, you will need a Kairos equipment, a
browser capable device and an IP connection between the two. Any kind of, valid, IP connection is accepted this
include wire, Wi-Fi. Please note that you may have to configure your network appropriately to not filter the
Kairos IP and the standard HTTP port 80.
Examples of configuration: Kairos-Ethernet cable-PC; Kairos-network—PC; Kairos-Wi-Fi router-mobile device
Examples of client hardware: PC, Laptop, Tablet, Smartphone
The Kairos acts as a standard web server on this port and accepts any kind of http client. For an optimal
experience we recommend a device that supports the latest version of Mozilla Firefox (current version 36), in
this manual all the example are referred to this browser (Please note some other modern browsers can be used
).
5.2.2 Login
Open Firefox browser and type in the URL box the IP of the Kairos:
If you receive a connection error, check the connection with Kairos equipment and the IP then retry.If the
connection is correctly configured you will be redirect to the login page:
Insert the new account information then press “Add”, only after the new account has been created delete the
default one. Note: only accounts with level above 30 can use the “Accounts” page.
Note: On each login, a session is created, that expires after a certain time of inactivity. After the session has
expired, on the first user action, he will be redirected to the login page.
5.2.3 Overview
This page presents details about Kairos Equipment. All the values of the parameters are updated in real time.
5.2.4 Audio
5.3.1 Configuration
On each page of Operator Station on the right-bottom side can be found a link named “edit”. To edit the
configuration tap this link. Six IP addresses can be configured but only for the first four, the audio functions will
be available, the last two will be visible only in the overview page. To edit the IP fields use the touch keyboard,
when finished press “Save configuration”. Save the file “config.js” in the folder:
/home/ra/www/js/configuration_file.
To control the if the connection is active, go to Home page and check if all the configured box/IP are not empty.
When a connection fails the message “Failed to connect to…” will be shown in the box.
5.3.2 Overview/Home
The default page is the overview page. Based on configuration, presents the real time status of the Kairos. Each
equipment has a dedicated box for his parameters:
This page was designed for monitoring purposes so the only possible interactions are: change page from the top
menu or see the detail of one equipment by touching one of the Kairos boxes.
By selecting one of the equipment, the user, will be lead to a custom version of Kairos Web Interface. The only
custom part is the top menu that is divided in two levels: detail level and top level. Top level contains the links to
Operator Station functionalities: overview and audio. Detail level contains the links to Kairos Web Interface
functionalities, for more details please read Kairos Web Interface Manual.
5.3.3 Audio
The audio page is the main tool, for the user, to interact with the Kairos network. For each Kairos is present a
column and on each row controls for a channel, this way any “cell” has the needed controls for a given channel
present on a certain Kairos. The possible channels are Analog, Timeslot A, and Timeslot B. The only unified
controls are the Push to talk and mode buttons. This buttons offer actions for the selected microphone. To select
a microphone, the user, must touch the “Microphone” label. If a microphone is selected the label background is
green, otherwise is white. Only one microphone can be selected at once so when a new one is selected the
previously selected microphone becomes not selected.
Push to talk: starts a live audio stream from operator station to Kairos that is transmitted via RF by the last. If the
mode is set to local, the audio is transmitted only by the selected Kairos otherwise, if the mode is set to network,
the selected Kairos will, also, send the audio to the radio network. The behavior of the network mode is subject
to the configuration and hierarchy of the Kairos radio network.
Note: a standalone Kairos will have the same behavior in both modes.
When one of the configured Kairos has a channel used for a conversation, the background color of the speakers
become yellow. This way the user can always know the status of the channels, additionally he can also the
conversation by enabling at least one of the two speakers. Each of the two speaker (left and right) corresponds
to the physical speaker. If more that one channel has enabled the left or the right audio, the output will be the
audio mix of the channels. For the Timeslot A and B any time a conversation is signaled the fields “dst” and “src”
are filed with information about the destination, of the call, and the source. This feature is not present for
Analog channels. For each channel is available a volume setting, on each tap the volume rises, a new tap when
the volume is at the max level will cause the volume to go at min level.
Configuration note: to use the microphone without the permission request from browser the following
configuration has been made in about:config: media.navigator.permission.disabled=true (only for Mozilla
Firefox)
Client request:
GET /page/login.html HTTP/1.1
Host: 172.33.17.40
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://172.33.17.40/index.html
Connection: keep-alive
Cache-Control: max-age=0
Server response:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 5832
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
Expires: 0
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Radio Activity Smart Repeater Interface - Login</title>
<link href="/css/base.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/core.js"></script>
<script type="text/javascript" src="/js/FileSaver.js"></script>
<link rel="icon" href="favicon.ico" />
</head>
<body style="background: url(/img/back_blue.png) repeat center; width: 100%;" ondragstart="return false;"
ondrop="return false;" oncontextmenu="return false">
<div style="min-height:100%; margin: 0 auto;background: url(/img/back_red.png) repeat center;overflow-
y:auto;">
<div style="min-height:100%; margin: 0 auto;background: url(/img/t.gif) repeat center;overflow:hidden;">
<div style="width:60em;height:3.5em;background: url(/img/testata.png);overflow:hidden;margin-
left:1em;margin-top: 1em;"><!-- -->
<div style="position:relative;width:auto;height:auto;left:0em;">
<ul id="menuo" style="width:auto;">
<li><a id="main_home" class="not_selected" onclick="window.location='/entry_point.html';return null;"
type="text/html" target="_self">Home </a></li>
<li><a id="main_audio" class="not_selected" onclick="window.location='/mon_cons.html';return null;"
type="text/html" target="_self">Audio </a></li>
<li><a id="pocsag" class="not_selected" onclick="window.location='/page/pocsag.html';return null;"
type="text/html" target="_self">POCSAG</a></li>
<li><a id="extra" class="not_selected" onclick="window.location='/page/extra.html';return null;"
type="text/html" target="_self">Extra</a></li>
</ul>
</div>
</div>
<div id="body" style="clear:both;width:60em;min-height:100%;background-color:#f5f5f5;overflow-y:auto;margin-
left:1em; oncontextmenu="return false">
<div style="float:left;padding-right: 10px; margin-left: -5px;position:relative;height:auto;min-
height:100vh;left:4px;background-color:#f5f5f5;">
<br/>
<div style="display:inline;">
<ul id="menuv" style="background-color:#f5f5f5">
<li class="header"> </li>
</ul>
</div>
<div style="margin-top:30px;">
<div class="spalla" style="position:relative;float:none;z-index: 3;"></div>
<div class="spalla" style="position:relative;top:-14px;float:none;background:#f5f5f5;z-index: 2;padding:22px 0px
12px 0px;">
<a href="?lang=UK"><img class="flag UK" style="margin-left:2px;" src="/img/t.gif" title=".Inglese" /></a>
<a href="?lang=IT"><img class="flag IT" src="/img/t.gif" title=".Italiano" /></a>
<a href="?lang=FR"><img class="flag FR" src="/img/t.gif" title=".Francese" /></a>
<a href="?lang=DE"><img class="flag DE" src="/img/t.gif" title=".Tedesco" /></a>
Client request:
POST /page/login.html HTTP/1.1
Host: 172.33.17.40
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://172.33.17.40/page/login.html
Connection: keep-alive
Content-Length: 23
Content-Type: application/x-www-form-urlencoded
user=kairos&pass=kairos
Server Response:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 5329
refresh: 0; url=/entry_point.html
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
Expires: 0
Set-Cookie: Kairos=rl3q1Xgr0NdpJOUi0SNVPLUXOU8d; Path=/;
Client Request:
GET /entry_point.html HTTP/1.1
Host: 172.33.17.40
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Referer: http://172.33.17.40/entry_point.html
Cookie: Kairos=rl3q1Xgr0NdpJOUi0SNVPLUXOU8d
Connection: keep-alive
Server Response:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 15259
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
Expires: 0
Access-Control-Allow-Origin: *
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Radio Activity Smart Repeater Interface - Home</title>
<link href="/css/base.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/core.js"></script>
<script type="text/javascript" src="/js/FileSaver.js"></script>
<link rel="icon" href="favicon.ico" />
</head>
<body style="background: url(/img/back_blue.png) repeat center; width: 100%;" ondragstart="return false;"
ondrop="return false;" oncontextmenu="return false">
<div style="min-height:100%; margin: 0 auto;background: url(/img/back_red.png) repeat center;overflow-
y:auto;">
<div style="min-height:100%; margin: 0 auto;background: url(/img/t.gif) repeat center;overflow:hidden;">
<div style="width:60em;height:3.5em;background: url(/img/testata.png);overflow:hidden;margin-
left:1em;margin-top: 1em;">
<div style="position:relative;width:auto;height:auto;left:0em;">
<ul id="menuo" style="width:auto;">
<li><a id="main_home" class="selected" onclick="window.location='/entry_point.html';return null;"
type="text/html" target="_self">Home </a></li>
<li><a id="main_audio" class="not_selected" onclick="window.location='/mon_cons.html';return null;"
type="text/html" target="_self">Audio </a></li>
<li><a id="pocsag" class="not_selected" onclick="window.location='/page/pocsag.html';return null;"
type="text/html" target="_self">POCSAG</a></li>
<li><a id="extra" class="not_selected" onclick="window.location='/page/extra.html';return null;"
type="text/html" target="_self">Extra</a></li>
</ul> </div></div>
<div id="body" style="clear:both;width:60em;min-height:100%;background-color:#f5f5f5;overflow-y:auto;margin-
left:1em; oncontextmenu="return false">
<div style="float:left;padding-right: 10px; margin-left: -5px;position:relative;height:auto;min-
height:100vh;left:4px;background-color:#f5f5f5;">
<br/><div style="display:inline;">
<ul id="menuv" style="background-color:#f5f5f5">
<li class="header"> </li> </ul> </div>
<div style="margin-top:30px;">
<div class="spalla" style="position:relative;float:none;z-index: 3;"> </div>
<div class="spalla" style="position:relative;top:-14px;float:none;background:#f5f5f5;z-index: 2;padding:22px 0px
12px 0px;">
<a href="?lang=UK"><img class="flag UK" style="margin-left:2px;" src="/img/t.gif" title=".Inglese" /></a>
<a href="?lang=IT"><img class="flag IT" src="/img/t.gif" title=".Italiano" /></a>
<a href="?lang=FR"><img class="flag FR" src="/img/t.gif" title=".Francese" /></a>
<a href="?lang=DE"><img class="flag DE" src="/img/t.gif" title=".Tedesco" /></a>
<a href="?lang=ES"><img class="flag ES" src="/img/t.gif" title=".Spagnolo" /></a> </div>
<div class="spalla" style="position:relative;top:-28px;float:none;text-align:center;background:#dde4e8;z-index:
1;padding-top:20px;height: 130px;">
<table class="glb_info" width="140"><tbody>
<tr class="nfocus"><td colspan="2">Equipment:</td></tr>
<tr class="mfocus"><td>Name:</td><td>KAIROS</td></tr>
<tr class="mfocus"><td>IP:</td><td>172.33.17.40</td></tr>
<tr class="nfocus"><td colspan="2">Software:</td></tr>
<tr><td>Name:</td><td>ka_bst</td></tr>
<tr><td>Vers.:</td><td>1.3.4.0</td></tr>
<tr><td>Date:</td><td>31-3-2015</td></tr>
<tr class="nfocus"><td colspan="2">Interface v2259</td></tr>
</tbody></table> </div></div></div>
<div class="lower_part" id="page_low_content">
<div class="main_content">
<div class="box" id="b15"><div class="titolo"><ul><li>DSP</li><li id="b15_wait" class="wait"
></li></ul></div><div class="corpo" id="b15_content" ><ul><div style="width:100% "><div class="value"
id="f0"><table ><tbody><tr><td style="border:none;"></td></tr><tr><td style=
" border-style:none;">PPS Signal from GPS</td><td style=" background-color:#FF0000;">Present</td><td style="
background-color:#FF0000;">Valid</td><td style=" background-color:#CECECE;">Lock</td></tr><tr><td style="
border-style:none;">PPS Signal from PTP</td><td style="
background-color:#00FF00;">Present</td><td style=" background-color:#00FF00;">Valid</td><td style="
background-color:#CECECE;">Lock</td></tr><tr><td style=" border-style:none;">External PPS Signal</td><td
style=" background-color:#00FF00;">Present</td><td style=" backgro
und-color:#00FF00;">Valid</td><td style=" background-color:#CECECE;">Lock</td></tr><tr><td style=" border-
style:none;">Superaudio Tone</td><td style=" background-color:#FF0000;">Present</td><td style=" background-
color:#FF0000;">Valid</td><td style=" background-color:#CE
CECE;">Lock</td></tr></tbody></table></div></div><div style="width:100% "><div class="value"
id="f1"><table><tbody><tr><td style=" border-style:none;">Synchronization from RF Signal or 4FSK</td><td
style=" background-color:#CECECE;">Lock</td></tr><tr><td style=" border-s
tyle:none;">Synchronization from Internal Reference</td><td style=" background-
color:#00FF00;">Lock</td></tr></tbody></table></div></div><div style="width:100% "><div class="value"
id="f2"><table style="min-width:250px;"><tbody><tr><td style="border:none;"></td></tr><tr>
<td style="background-color:#00FF00; text-align:center;text-color:white; ">DSP Correctly
Synchronized</td></tr></tbody></table></div></div><div style="width:100% "><div class="value" id="f3"> 0d 0h
2m 36s</div></div><div style="width:100% "><div class="value" id="f4"><ta
ble class="values_table"><tbody><tr><td style="border:none;"></td></tr><tr><td class="m_v"
style="background-color:#00FF00;">TX PLL Lock</td></tr><tr><td class="m_v" style="background-
color:#00FF00;">RX PLL Lock</td></tr><tr><td class="m_v" style="background-color:#00FF0
0;">DSP<->PLD Communication</td></tr></tbody></table></div></div><div style="width:100% "><div
class="value" id="f5"><table class="values_table"><tbody><tr><td style="border:none;"></td></tr><tr><td
class="m_v" style="background-color:#00FF00;">Analog Features</td></tr><
tr><td class="m_v" style="background-color:#FF0000;">DMR Features</td></tr><tr><td class="m_v"
style="background-color:#00FF00;">ETSI Tier III Features</td></tr><tr><td class="m_v" style="background-
color:#00FF00;">Simulcast Features</td></tr></tbody></table></div></div>
<div style="width:100% "><div class="value" id="f6"><table class="values_table"><tbody><tr><td
style="border:none;"></td></tr><tr><td class="m_v" style="background-color: #00FF00;" colspan="2"> DSP
Ready</td></tr><tr><td class="m_v" style="background-color: #00FF00;" col
span="2">TRX Active</td></tr><tr><td class="m_v" style="background-color: #CECECE;" colspan="2">Calibration
Running</td></tr><tr><td class="m_v" style="background-color: #00FF00;" colspan="2">Calibration
OK</td></tr><tr><td class="m_v" style="background-color: #00FF00;"
colspan="2">Interrups from PLD</td></tr><tr><td class="m_v" style="background-color: #CECECE;">Main RX
Fail</td><td class="m_v" style="background-color: #CECECE;">Diversity RX Fail</td></tr><tr><td class="m_v"
style="background-color: #CECECE;">PTT Carrier</td><td class=
"m_v" style="background-color: #CECECE;">PTT Modem</td></tr><tr><td class="m_v" style="background-color:
#CECECE;">Squelch</td><td class="m_v" style="background-color: #CECECE;">TCS-DPL</td></tr><tr><td
class="m_v" style="background-color: #CECECE;">TX DMR TS A</td><td c
lass="m_v" style="background-color: #CECECE;">TX DMR TS B</td></tr><tr><td class="m_v" style="background-
color: #CECECE;">RX DMR TS A</td><td class="m_v" style="background-color: #CECECE;">RX DMR TS
B</td></tr></tbody></table></div></div><div style="width:100% "><div cla
ss="value" id="f8"> <table class="values_table"><tbody><tr><td style="border:none;"></td></tr><tr><td
class="m_h">DMR Packets Out of Window</td><td acolspan="2" class="m_v">0</td></tr><tr><td
class="m_h">Analog Packets Out of Window</td><td colspan="2" class="m_v">0</
td></tr><tr><td class="m_h">Safety margin for DMR Packets</td><td colspan="2"
Used to send a new message to POCSAG terminal and monitor history of sent message.
Client request:
POST /page/dom/send_pocsag.html HTTP/1.1
Host: 172.33.17.40
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://172.33.17.40/page/pocsag.html
Content-Length: 129
Cookie: Kairos=rl3q1XgrT9dsJVUiJNW19pWyOU8d
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Server Response:
HTTP/1.1 200 OK
Content-Length: 57
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate
Expires: 0
Connection: Keep-Alive
Content-Type: application/xml
6.1 Overview
HTTP functions as a request-response protocol in the client-server computing model. A web browser, for
example, may be the client and an application running on a computer hosting a web site may be the server. The
client submits an HTTP request message to the server. The server, which provides resources such as HTML files
and other content, or performs other functions on behalf of the client, returns a response message to the client.
The response contains completion status information about the request and may also contain requested content
in its message body.
A web browser is an example of a user agent (UA). Other types of user agent include the indexing software used
by search providers (web crawlers), voice browsers, mobile apps, and other software that accesses, consumes,
or displays web content.
HTTP resources are identified and located on the network by Uniform Resource Identifiers (URIs)—or, more
specifically, Uniform Resource Locators (URLs)—using the http or https URI schemes. URIs and hyperlinks in
Hypertext Markup Language (HTML) documents form webs of inter-linked hypertext documents.
HTTP/1.1 is a revision of the original HTTP (HTTP/1.0). In HTTP/1.0 a separate connection to the same server is
made for every resource request. HTTP/1.1 can reuse a connection multiple times to download images, scripts,
stylesheets, etc after the page has been delivered. HTTP/1.1 communications therefore experience less latency
as the establishment of TCP connections presents considerable overhead.
The Status-Line and other header fields must all end with <CR><LF> (a carriage return followed by a line feed).
The empty line must consist of only <CR><LF> and no other whitespace.
<html>
<head>
<title>An Example Page</title>
</head>
<body>
Hello World, this is a very simple HTML document.
</body>
</html>
The ETag (entity tag) header field is used to determine if a cached version of the requested resource is identical
to the current version of the resource on the server. Content-Type specifies the Internet media type of the data
conveyed by the HTTP message, while Content-Length indicates its length in bytes. The HTTP/1.1 webserver
publishes its ability to respond to requests for certain byte ranges of the document by setting the field Accept-
Ranges: bytes. This is useful, if the client needs to have only certain portions of a resource sent by the server,
which is called byte serving. When Connection: close is sent, it means that the web server will close the TCP
connection immediately after the transfer of this response.
Most of the header lines are optional. When Content-Length is missing the length is determined in other ways.
Chunked transfer encoding uses a chunk size of 0 to mark the end of the content. Identity encoding without
Content-Length reads content until the socket is closed.
A Content-Encoding like gzip can be used to compress the transmitted data.
The handshake resembles HTTP so that servers can handle HTTP connections as well as WebSocket connections
on the same port. However the specific fields involved, and what follows after the handshake, do not conform to
the HTTP protocol.
Note that each line ends with an EOL (end of line) sequence, \r\n. There must be an extra blank line at the end.
The client sends a Sec-WebSocket-Key which is a random value that has been base64 encoded. To form a
response, the GUID 258EAFA5-E914-47DA-95CA-C5AB0DC85B11 is appended to this base64 encoded key. The
base64 encoded key will not be decoded first. The resulting string is then hashed with SHA-1, then base64
encoded. Finally, the resulting reply occurs in the header Sec-WebSocket-Accept.
Once the connection is established, the client and server can send WebSocket data or text frames back and forth
in full-duplex mode. The data is minimally framed, with a small header followed by payload. WebSocket
transmissions are described as "messages", where a single message can optionally be split across several data
frames. This can allow for sending of messages where initial data is available but the complete length of the
message is unknown (it sends one data frame after another until the end is reached and marked with the FIN
bit). With extensions to the protocol, this can also be used for multiplexing several streams simultaneously (for
instance to avoid monopolizing use of a socket for a single large payload).
It is important (from a security perspective) to validate the "Origin" header during the connection establishment
process on the serverside (against the expected origins) to avoid Cross-Site WebSocket Hijacking attacks, which
might be possible when the connection is authenticated with Cookies or HTTP authentication. It is better to use
tokens or similar protection mechanisms to authenticate the WebSocket connection when sensitive (private)
data is being transferred over the WebSocket.
8 Introduction to JSON
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and
write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming
Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language
independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C+
+, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange
language.
These are universal data structures. Virtually all modern programming languages support them in one form or
another. It makes sense that a data format that is interchangeable with programming languages also be based
on these structures.
An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right
brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket).
Values are separated by , (comma).
A value can be a string in double quotes, or a number, or true or false or null, or an object or an array.
These structures can be nested.
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A
character is represented as a single character string. A string is very much like a C or Java string.
A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.
Whitespace can be inserted between any pair of tokens. Excepting a few encoding details, that completely
describes the language.
9 References