Light At The End Of The Tunnel

systems administration meanderings

Data capture with ExaNIC’s

Capturing the data

My scenario is that I wish capture some multicast data and analyse it later.  I’d like this process to be automated, start at a specific time, stop at a specific time, and then process the captured data file.

I’ll be using CentOS 7 which is based on systemd.

Fortunately, the ExaNIC cards come with a great utility called exanic-capture,  this tool is one of the features of the ExaNIC card outlined in this post on the Exablaze site.  The  exanic-capture utility can produce a pcap file that has nanosecond timestamp resolution (6.2 nanoseconds).

We will also sync the ExaNIC‘s  internal timer to the host’s clock.  The host in this case is running NTP to discipline the system clock.

systemd has the capability to create services and associated timers, in this case I wanted to capture mulitcast data between the hours of 0830 and 1700.  I first created a mulitcast listener service that registers the host to listen for the data, and then a bit later I start a service to capture the raw data.  Note I did not filter the data as I also wanted the data to be passed up to the kernel. If you add a filter to the exanic-capture utility it keeps the data to itself.

Multicast listener

For the services on CentOS 7  I will define them under

Description=Multicast Data listener

ExecStart=/usr/bin/socat UDP4-RECVFROM:30011,ip-add-membership=,fork -

Description=Start registering for multicast data

OnCalendar=Mon-Fri *-*-* 08:00:00

Multicast data capture service

I called this service datacapture.service

Description=Multicast Data collector

ExecStart=/bin/sh -c "export D=\"`date +\"%Y%%m%%d\"`\"; /usr/bin/exanic-capture -i exanic0:0  -w /data/logging/$(hostname -s)/\"$D\".pcap "
ExecStop=/bin/sh -c "export D=\"`date +\"%Y%%m%%d\"`\"; cd /data/logging/$(hostname -s)/;/usr/local/bin/ \"$D\".pcap \"$D\""

Multicast data capture timer

I have this setup to start 5 minutes after the listener

Description=Start listening to market data

OnCalendar=Mon-Fri *-*-* 08:05:00


Clock sync service

This service is going to run all the time, and requires that NTP service is running

Description=ExaNIC Clock Sync to host

ExecStart=/usr/bin/exanic-clock-sync exanic0:host


Next Steps

systemctl daemon-reload
systemctl status mdlisten
systemctl status mdlisten.timer

You will see that both services are disabled by default, we will need to enable each of new services

systemctl enable mdlisten
systemctl enable mdlisten.timer
systemctl enable market
systemctl enable datacapture.timer
systemctl enable datacapture

Then ensure that the status is correct for each service and that the timers fire their respective services at the correct times.