Psyllid  v1.12.4
Project 8 Data Acquisisition Software
packet_receiver_fpa.hh
Go to the documentation of this file.
1 /*
2  * packet_receiver_fpa.hh
3  *
4  * Created on: Nov 2, 2016
5  * Author: nsoblath
6  */
7 
8 #ifndef PSYLLID_PACKET_RECEIVER_FPA_HH_
9 #define PSYLLID_PACKET_RECEIVER_FPA_HH_
10 
11 #include "memory_block.hh"
12 #include "node_builder.hh"
13 
14 #include "producer.hh"
15 #include "shared_cancel.hh"
16 
17 #include <linux/if_packet.h>
18 #include <memory>
19 #include <sys/uio.h>
20 
21 namespace scarab
22 {
23  class param_node;
24 }
25 
26 namespace psyllid
27 {
28  struct block_desc
29  {
30  uint32_t f_version;
31  uint32_t f_offset_to_priv;
32  tpacket_hdr_v1 f_packet_hdr;
33  };
34 
35  struct receive_ring
36  {
37  iovec* f_rd;
38  uint8_t* f_map;
39  tpacket_req3 f_req;
40  receive_ring() : f_rd( nullptr ), f_map( nullptr ), f_req()
41  {}
42  };
43 
44 
114  class packet_receiver_fpa : public midge::_producer< midge::type_list< memory_block > >
115  {
116  public:
118  virtual ~packet_receiver_fpa();
119 
120  public:
121  mv_accessible( uint64_t, length );
122  mv_accessible( uint32_t, max_packet_size );
123  mv_accessible( uint32_t, port );
124  mv_referrable( std::string, interface );
125  mv_accessible( unsigned, timeout_sec );
126  mv_accessible( unsigned, n_blocks );
127  mv_accessible( unsigned, block_size );
128  mv_accessible( unsigned, frame_size );
129 
130  public:
131  virtual void initialize();
132  virtual void execute( midge::diptera* a_midge = nullptr );
133  virtual void finalize();
134 
135  private:
136  bool process_packet( tpacket3_hdr* a_packet );
137  void cleanup_fpa();
138 
140 
141  int f_socket;
142 
144 
145  uint64_t f_packets_total;
146  uint64_t f_bytes_total;
147  };
148 
149  class packet_receiver_fpa_binding : public _node_binding< packet_receiver_fpa, packet_receiver_fpa_binding >
150  {
151  public:
153  virtual ~packet_receiver_fpa_binding();
154 
155  private:
156  virtual void do_apply_config( packet_receiver_fpa* a_node, const scarab::param_node& a_config ) const;
157  virtual void do_dump_config( const packet_receiver_fpa* a_node, scarab::param_node& a_config ) const;
158  };
159 
160 } /* namespace psyllid */
161 
162 #endif /* PSYLLID_PACKET_RECEIVER_FPA_HH_ */
A producer to receive UDP packets via the fast-packet-acquisition interface and write them as raw blo...
tpacket_hdr_v1 f_packet_hdr