Skip to content

Overview

andymalakov edited this page Dec 5, 2014 · 18 revisions

What is it?

LIBPCAP Latency Meter is a small tool that measures time difference between inbound and outbound TCP packets messages.

How does it work?

The tool intercepts inbound and outbound TCP packets containing your network messages. All captured packets carry time stamps. This tool matches outbound packets with corresponding inbound packets using some kind of correlation key (For example, value of specific FIX tags).

Signal latency

For example, this tool can be used measure latency of trading signals. FX market data feed usually contain a field QuoteEntryID(299), while FX orders may contain a field QuoteID(117). Tool can correlate inbound and outbound messages based on the value provided in these tags.

Tick-to-Quote packets correlation

Simple statistics (min/max/avg) are printed out during run time and latency log of each signal is recorded into CSV file.

This tool can monitor latency of live network traffic or process previously captured traffic in pcap format (for example produced by Wireshark).

This tool is based on jNetPcap library, which is in turn is a wrapper around libpcap.

Results

Tool prints brief stats during its run and records latency of every signal into binary file. Binary file can be later converted to CSV format.

Additional utility produces percentile histograms from collected latencies (using HdrHistogram):

Percentile chart

###How precise is it? Time stamps of each packet come from libpcap (WinPcap) library, which in turn gets them from the operating system kernel. WinPcap has microsecond precision, while libpcap (Unix origin) has nanosecond precision.

###How to use it?

See Quick Start wiki page.

Limitations

  • Current version does not handle TCP re-transmissions and duplicate packets. It is possible to implement protection against these exceptions using JNetPcap API, but currently this is out-of-scope.

  • Current version doesn't re-assemble messages split between several TCP packets. jNetPcap has examples of doing that.

  • Current version relies on strict order of inbound and outbound signals.

  • Any outbound signal must have corresponding inbound signal. Timestamps of inbound signals are stored in ring buffer. Outbound packet processor consumes ring buffer as it searches for matching signal.

###Disclaimer

This tool is provided "as is" without warranty of any kind and is to be used at your own risk.

License

This tool is distributed free of charge and royalties under LGPL license

Tool includes the following open source libraries:


This tool has been tested with jNetPcap 1.4.r1425 with:

  • Windows platform: Windows Server 2008 SR2, Windows 7 SP1 Pro (WinPcap 4.1.3)
  • Linux platform: Centos 7.0 (LIBPCAP 1.5.3) and Fedora 19 (LIBPCAP 1.4.0)
Clone this wiki locally