FAST tools: Server and client code unification

FAST server and client code is organized in the same
way as for FIX server and client respectively. The
fact is that both client and server might operate
in several modes. At the moment FAST client and
server can operate in a 'script' mode only but this
functionality is to be extended in the future

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FIX server: code cleanups

Use a general structure to pass arguments to the
FIX server different mode functions

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FAST encoding bug: pmap bit increment

It does not matter whether pmap bit is actually set
or not. If operation requires pmap bit inside a PMAP
structure we should increment pmap bit. Otherwise,
PMAP will be corrupted if another field when being
encoded sets the wrong pmap bit.

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FAST tools: Ping-Pong mode introduced

The patch introduces a simple ping-pong mode:
A client sends (pings) a message to server.
A server receives a message from the client,
decodes it and sends (pongs) a message to the
client. Such a scenario allows to estimate
RTT (round-trip-time) of a particular message.
In other words, the time spent by the client
encoding a message, the server decoding it,
then encoding a message a sending it back to
the client and finally the client decoding
the received message.

$ ./tools/fast/fast_server -m pong -n 100 -p 9000 -t ./tools/fast/scripts/PingPong.xml
FAST server is listening to port 9000...

$ ./tools/fast/fast_client -m ping -n 100 -h localhost -p 9000 -t ./tools/fast/scripts/PingPong.xml
Messages sent: 100
Round-trip time: min/avg/max = 40.0/76.6/238.0 μs

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FAST: switch to sendmsg()

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FAST: Use non-blocking recv()

Switch to non-blocking recv() in FAST receive path

Running the FAST engine latency tests:

$ while true; do tools/fast/fast_server -m pong -n 100000 -p 9000 -t tools/fast/scripts/PingPong.xml; done

$ while true; do tools/fast/fast_client -m ping -n 100000 -h localhost -p 9000 -t tools/fast/scripts/PingPong.xml; done

Shows 85% reduction in round-trip times:

Before:
Messages sent: 100000
Round-trip time: min/avg/max = 22.0/71.9/3618.0 μs
Round-trip time: min/avg/max = 39.0/76.0/1492.0 μs
Round-trip time: min/avg/max = 38.0/86.8/1148.0 μs
Round-trip time: min/avg/max = 25.0/80.3/241.0 μs
Round-trip time: min/avg/max = 38.0/71.0/240.0 μs
Round-trip time: min/avg/max = 39.0/76.2/1062.0 μs
Round-trip time: min/avg/max = 22.0/62.6/250.0 μs
Round-trip time: min/avg/max = 37.0/90.1/1135.0 μs
Round-trip time: min/avg/max = 39.0/71.4/1138.0 μs
Round-trip time: min/avg/max = 38.0/88.8/1079.0 μs

After:
Messages sent: 100000
Round-trip time: min/avg/max = 10.0/11.2/177.0 μs
Round-trip time: min/avg/max = 10.0/11.1/153.0 μs
Round-trip time: min/avg/max = 10.0/11.1/150.0 μs
Round-trip time: min/avg/max = 10.0/11.0/975.0 μs
Round-trip time: min/avg/max = 10.0/11.2/238.0 μs
Round-trip time: min/avg/max = 10.0/11.0/179.0 μs
Round-trip time: min/avg/max = 10.0/11.2/312.0 μs
Round-trip time: min/avg/max = 10.0/11.1/174.0 μs
Round-trip time: min/avg/max = 10.0/11.0/142.0 μs
Round-trip time: min/avg/max = 10.0/11.1/970.0 μs

Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
Add FAST round-trip times to README

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Add ncurses-devel to prerequisite list

Reported-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
Use Python for fixdialectc script

Convert fixdialectc from Ruby to Python to avoid the otherwise unneeded
dependency to the former.

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Add python-yaml to Travis CI environment

Signed-off-by: Pekka Enberg <penberg@iki.fi>
FIX: Clean up matching and parsing

Rename parse_field() to match_field() and parse_field_promisc() to
parse_field() to use more typical parser terminology in the FIX code.

Saves me from looking up what parse_field_promisc() does every time I
read the code...

Signed-off-by: Pekka Enberg <penberg@iki.fi>
tools/fix: Fix SIGSEGV in fix_server.c

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Minor updates to README

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Update exchange and protocol coverage

Signed-off-by: Pekka Enberg <penberg@kernel.org>
IEX: Update to version 1.3

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Quick start guide

Signed-off-by: Pekka Enberg <penberg@iki.fi>
Switch to the 2-clause BSD license

The "no-endosement" clause is meaningless because libtrading is a
community project.

Acked-by: Jussi Virtanen <jussi.k.virtanen@gmail.com>
Acked-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FAST: send/recv functionality for non-socket descriptors

recv() and sendmsg() are intended for sockets only.  fast_orderbook and
fast_parser support various data streams. Library FAST engine should
support them also.

Reported-by: Pavel Kostikov
Signed-off-by: Marat Stanichenko <mstanichenko@gmail.com>
Signed-off-by: Pekka Enberg <penberg@iki.fi>
FIX tools: Fix SIGSEGV in fix_client.c

Signed-off-by: Pekka Enberg <penberg@iki.fi>
FIX: Request all messages on resend

When the FIX engine detects a incoming message sequence number that is
higher than expected, request all messages on resend by setting EndSeqNo
to zero which represents infinity.

I was not able to find anything conclusive in the FIX specifications but
QuickFIX/J works this way so this is more compatible with other FIX
engines.

Signed-off-by: Pekka Enberg <penberg@iki.fi>