Psyllid  v1.12.4
Project 8 Data Acquisisition Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
packet_receiver_fpa Class Reference

A producer to receive UDP packets via the fast-packet-acquisition interface and write them as raw blocks of memory. More...

#include <packet_receiver_fpa.hh>

Inheritance diagram for packet_receiver_fpa:
Inheritance graph

Public Member Functions

 packet_receiver_fpa ()
 
virtual ~packet_receiver_fpa ()
 
 mv_accessible (uint64_t, length)
 
 mv_accessible (uint32_t, max_packet_size)
 
 mv_accessible (uint32_t, port)
 
 mv_referrable (std::string, interface)
 
 mv_accessible (unsigned, timeout_sec)
 
 mv_accessible (unsigned, n_blocks)
 Timeout in seconds for waiting on the network interface. More...
 
 mv_accessible (unsigned, block_size)
 Number of blocks in the mmap ring buffer. More...
 
 mv_accessible (unsigned, frame_size)
 Number of packets per block in the mmap ring buffer. More...
 
virtual void initialize ()
 Number of blocks per frame in the mmap ring buffer. More...
 
virtual void execute (midge::diptera *a_midge=nullptr)
 
virtual void finalize ()
 

Private Member Functions

bool process_packet (tpacket3_hdr *a_packet)
 
void cleanup_fpa ()
 

Private Attributes

int f_net_interface_index
 
int f_socket
 
receive_ring f_ring
 
uint64_t f_packets_total
 
uint64_t f_bytes_total
 

Detailed Description

A producer to receive UDP packets via the fast-packet-acquisition interface and write them as raw blocks of memory.

Author
N. S. Oblath
 Parameter setting is not thread-safe.  Executing is thread-safe.

 Works in Linux only.

 Input: mmap ring buffer


 Following documentation of using mmap ring buffers in networking here:
     https://www.kernel.org/doc/Documentation/networking/packet_mmap.txt

 Understanding of tpacket3_hdr that I've pieced together:

 Defined in if_packet.h (my comments denoted with ///)

    struct tpacket_hdr_variant1 {
        __u32   tp_rxhash;           ///
        __u32   tp_vlan_tci;         ///
    };

    struct tpacket3_hdr {
        __u32       tp_next_offset;  /// Memory offset from the packet location to the next packet
        __u32       tp_sec;          ///
        __u32       tp_nsec;         ///
        __u32       tp_snaplen;      /// Size of this packet in bytes
        __u32       tp_len;          ///
        __u32       tp_status;       /// Packet status (see values below)
        __u16       tp_mac;          /// Memory offset from the packet location to the ethhdr object
        __u16       tp_net;          ///

pkt_hdr variants union { struct tpacket_hdr_variant1 hv1; }; };

Available values for tp_status from if_packet.h:

Rx ring - header status #define TP_STATUS_KERNEL 0x0 /// Returned to the kernel? #define TP_STATUS_USER 0x1 /// Available to the user? #define TP_STATUS_COPY 0x2 #define TP_STATUS_LOSING 0x4 #define TP_STATUS_CSUMNOTREADY 0x8 #define TP_STATUS_VLAN_VALID 0x10 // auxdata has valid tp_vlan_tci #define TP_STATUS_BLK_TMO 0x20

 Node type: "packet-receiver-fpa"

 Available configuration values:
 - "length": uint -- The size of the output buffer
 - "max-packet-size": uint -- Maximum number of bytes to be read for each packet; larger packets will be truncated
 - "port": uint -- UDP port to listen on for packets
 - "interface": string -- Name of the network interface to listen on for packets
 - "timeout-sec": uint -- Timeout (in seconds) while listening for incoming packets; listening for packets repeats after timeout
 - "n-blocks": uint -- Number of blocks in the mmap ring buffer
 - "block-size": uint -- Number of packets per block in the mmap ring buffer
 - "frame-size": uint -- Number of blocks per frame in the mmap ring buffer

 Output Streams:
 - 0: memory_block

Definition at line 114 of file packet_receiver_fpa.hh.

Constructor & Destructor Documentation

◆ packet_receiver_fpa()

Definition at line 44 of file packet_receiver_fpa.cc.

◆ ~packet_receiver_fpa()

~packet_receiver_fpa ( )
virtual

Definition at line 61 of file packet_receiver_fpa.cc.

Member Function Documentation

◆ cleanup_fpa()

void cleanup_fpa ( )
private

Definition at line 408 of file packet_receiver_fpa.cc.

◆ execute()

void execute ( midge::diptera *  a_midge = nullptr)
virtual

Definition at line 181 of file packet_receiver_fpa.cc.

◆ finalize()

void finalize ( )
virtual

Definition at line 398 of file packet_receiver_fpa.cc.

◆ initialize()

void initialize ( )
virtual

Number of blocks per frame in the mmap ring buffer.

Definition at line 66 of file packet_receiver_fpa.cc.

◆ mv_accessible() [1/7]

mv_accessible ( uint64_t  ,
length   
)

◆ mv_accessible() [2/7]

mv_accessible ( uint32_t  ,
max_packet_size   
)

◆ mv_accessible() [3/7]

mv_accessible ( uint32_t  ,
port   
)

◆ mv_accessible() [4/7]

mv_accessible ( unsigned  ,
timeout_sec   
)

◆ mv_accessible() [5/7]

mv_accessible ( unsigned  ,
n_blocks   
)

Timeout in seconds for waiting on the network interface.

◆ mv_accessible() [6/7]

mv_accessible ( unsigned  ,
block_size   
)

Number of blocks in the mmap ring buffer.

◆ mv_accessible() [7/7]

mv_accessible ( unsigned  ,
frame_size   
)

Number of packets per block in the mmap ring buffer.

◆ mv_referrable()

mv_referrable ( std::string  ,
interface   
)

◆ process_packet()

bool process_packet ( tpacket3_hdr *  a_packet)
private

Definition at line 287 of file packet_receiver_fpa.cc.

Member Data Documentation

◆ f_bytes_total

uint64_t f_bytes_total
private

Definition at line 146 of file packet_receiver_fpa.hh.

◆ f_net_interface_index

int f_net_interface_index
private

Definition at line 139 of file packet_receiver_fpa.hh.

◆ f_packets_total

uint64_t f_packets_total
private

Definition at line 145 of file packet_receiver_fpa.hh.

◆ f_ring

receive_ring f_ring
private

Definition at line 143 of file packet_receiver_fpa.hh.

◆ f_socket

int f_socket
private

Definition at line 141 of file packet_receiver_fpa.hh.


The documentation for this class was generated from the following files: