FMADIO LXC system high level architecture is shown below.
This provides a full lossless filtered version of data directly into the LXC container for processing.
Backpressure is provided thru the LXC Ring structure, allowing the application to consume data as fast or slow as possible without dropping anything.
Sending Data to LXC Offline
During development its typically easiest to send data into the LXC container in a one time replay operation. This allows sending the same data repeatedly to the application allow the engineers to debug and test the code.
In this example we will use the application "fmadio2pcap" which converts the LXC ring into a standard PCAP formatted stream of data.
Its recommended to start the data consumer aka LXC application first, then start the replay.
Consumer - fmadio2pcap tcpdump
Run the following on the LXC container to generate TCPDUMP output thru the lxc ring named "general"
It will look similar to the following on startup, it stops because no packets have been sent to the ring.
root@fmadio40v3-440-centos7:/opt/fmadio/platform/fmadio2pcap# ./fmadio2pcap -i /opt/fmadio/queue/lxc_ring_general | tcpdump -r - -nn
fmadio2pcap
FMAD Ring [/opt/fmadio/queue/lxc_ring_general]
Ring size : 12595200 12595200 16777216
Ring Version: 100 100
Ring Depth : 400 400
Ring Mask : 3ff 3ff
RING: Put:1612f 12f
RING: Get:1612f 12f
Producer - stream_cat sending to LXC ring
On the FMADIO Host system find a capture you want to replay. In this example we are using capture named "inetsample_20230615_1513" filename can be found using "stream_dump"
Core loop snippet, this converts from LXC Ring into standard PCAP Packet format
while (!s_Exit){ u64 TS;PCAPPacket_t* Pkt = (PCAPPacket_t*)PktBuffer;// fetch packet from ring without blockingint ret =FMADPacket_RecvV1(s_RING,false,&TS,&Pkt->LengthWire,&Pkt->LengthCapture,NULL, Pkt +1);// if it has valid dataif (ret >0) {// convert 64b epoch into sec/subsec for pcapPkt->Sec = TS / (u64)1e9;Pkt->NSec = TS % (u64)1e9;// write PCAP header and payload fwrite(PktBuffer,1,sizeof(PCAPPacket_t) +Pkt->LengthCapture, FPCAP); // general stats TotalPkt +=1; TotalByte += ret; } // end of streamif (ret <0) break;}