libcyberradio  22.01.24
TransmitPacketizer.h
1 /***************************************************************************
2  * \file TransmitPacketizer.h
3  *
4  * \brief NDR651 transmit packetizer class.
5  *
6  * \author NH/DA
7  * \copyright Copyright (c) 2015-2021 CyberRadio Solutions, Inc.
8  *
9  */
10 
11 #ifndef INCLUDED_LIBCYBERRADIO_NDR651_TRANSMITPACKETIZER_H
12 #define INCLUDED_LIBCYBERRADIO_NDR651_TRANSMITPACKETIZER_H
13 
14 #include "LibCyberRadio/Common/Debuggable.h"
15 #include "LibCyberRadio/NDR651/FlowControlClient.h"
16 #include "LibCyberRadio/NDR651/PacketTypes.h"
17 #include "LibCyberRadio/NDR651/TransmitSocket.h"
18 #include "LibCyberRadio/NDR651/UdpStatusReceiver.h"
19 
20 bool setCpuAffinity(int cpu);
21 
25 namespace LibCyberRadio
26 {
31  namespace NDR651
32  {
33 
38  {
39  public:
58  TransmitPacketizer(const std::string& radioHostName = "",
59  int radioTcpPort = 8617,
60  unsigned int ducChannel = 1,
61  const std::string& ifname = "eth0",
62  unsigned int tenGigIndex = 1,
63  int dipIndex = -1,
64  unsigned int ducRate = 0,
65  unsigned int ducTxChannels = 0,
66  float ducFreq = 900e6,
67  float ducAtten = 0,
68  double txFreq = 900,
69  float txAtten = 0,
70  unsigned int streamId = 40001,
71  bool config_tx = false,
72  bool debug = false);
76  virtual ~TransmitPacketizer();
82  bool setRadioHostName(const std::string& radioHostName);
88  bool setRadioTcpPort(int radioTcpPort);
94  bool setDucChannel(unsigned int ducChannel);
101  bool setDucInterface(const std::string& ifname,
102  unsigned int tenGigIndex);
108  bool setDucRate(unsigned int ducRate);
114  bool setDucTxChannels(unsigned int ducTxChannels);
120  bool setDucFreq(float ducFreq);
126  bool setDucTxinvMode(unsigned int txinvMode);
132  bool setDucAtten(float ducAtten);
138  bool setTxFreq(double txFreq);
144  bool setTxAtten(float txAtten);
150  bool setStreamId(unsigned int streamId);
156  bool setDebug(bool debug);
163  bool setRadioParameters(
164  const std::string& radioHostName,
165  int radioTcpPort);
178  bool setDucParameters(unsigned int tenGigIndex,
179  unsigned int ducRate,
180  unsigned int ducTxChannels,
181  float ducFreq,
182  float ducAtten,
183  double txFreq,
184  float txAtten,
185  unsigned int streamId);
189  void start();
193  void stop();
200  unsigned int sendFrame(short * samples);
205  bool isConnected(void);
210  bool isReadyToReceive(void);
211 
212  void setDuchsParameters(unsigned int duchsPfThresh, unsigned int duchsPeThresh, unsigned int duchsPeriod, bool updatePE);
213  unsigned int getDuchsPfThresh(void) { return _duchsPfThresh; };
214  unsigned int getDuchsPeThresh(void) { return _duchsPeThresh; };
215  unsigned int getDuchsPeriod(void) { return _duchsPeriod; };
216  bool getUpdatePE(void) { return _updatePE; };
217 
218  private:
219  unsigned int _waitLoop(void);
220  void _incrementVitaHeader(void);
221  bool setEthernetHeader(const std::string& sourceMac,
222  const std::string& destMac);
223  bool setIpHeader(const std::string& sourceIp,
224  const std::string& destIp);
225  bool setUdpHeader(unsigned short sourcePort,
226  unsigned short destPort);
227  bool setVitaHeader(unsigned int streamId);
228 
229  private:
230  unsigned int _frameCount, _pauseCount;
231  /* Radio parameters */
232  std::string _radioHostName;
233  int _radioTcpPort;
234  /* DUC parameters */
235  unsigned int _ducChannel;
236  std::string _ifname;
237  unsigned int _tenGigIndex;
238  int _dipIndex;
239  unsigned int _ducRate;
240  unsigned int _ducTxChannels;
241  float _ducFreq;
242  float _ducAtten;
243  double _txFreq;
244  float _txAtten;
245  unsigned int _streamId;
246  bool _config_tx;
247  bool _firstFrame;
248  /* Control objects */
249  TransmitSocket * _txSock;
250  std::vector<TransmitSocket *> _txSockVec;
251  unsigned int _numSock, _currentSockIndex;
252  FlowControlClient * _fcClient;
253  UdpStatusReceiver * _statusRx;
254  struct TxFrame _frame;
255  unsigned char * _frameStart;
256  unsigned int _frameLength;
257  /* State data */
258  unsigned int _samplesSent;
259  std::string _sMac;
260  std::string _dMac;
261  std::string _sIp;
262  std::string _dIp;
263  unsigned short _sPort;
264  unsigned short _dPort;
265  bool _configuring;
266  bool _constructing;
267  bool _running;
268  struct timespec _delayTime;
269  unsigned int _samplesPerFrame;
270  unsigned int _duchsPeriod, _duchsPfThresh, _duchsPeThresh;
271  bool _updatePE;
272  unsigned int _txinvMode;
273 
274  };
275 
276  } /* namespace NDR651 */
277 }
278 
279 #endif /* INCLUDED_LIBCYBERRADIO_NDR651_TRANSMITPACKETIZER_H */
virtual ~TransmitPacketizer()
Destroys a TransmitPacketizer object.
bool setDucChannel(unsigned int ducChannel)
Sets the DUC channel number.
bool setRadioHostName(const std::string &radioHostName)
Sets the radio host name.
VITA 49 transmit-over-UDP frame information.
Definition: PacketTypes.h:87
bool setDucTxChannels(unsigned int ducTxChannels)
Sets the DUC transmit channel bitmap.
bool isConnected(void)
Gets whether or not the packetizer is connected.
bool setDucTxinvMode(unsigned int txinvMode)
Sets the DUC TX Inversion Mode.
bool setRadioParameters(const std::string &radioHostName, int radioTcpPort)
Sets the radio parameters.
Class that supports debug output.
Definition: Debuggable.h:38
bool setDucRate(unsigned int ducRate)
Sets the DUC rate index.
bool setDucInterface(const std::string &ifname, unsigned int tenGigIndex)
Sets the DUC interface parameters.
virtual int debug(const char *format,...)
Outputs debug information.
Definition: Debuggable.cpp:95
bool setTxFreq(double txFreq)
Sets the transmitter frequency.
bool setDebug(bool debug)
Sets whether or not to produce debug output.
bool isReadyToReceive(void)
Gets whether or not the packetizer is ready to receive data.
Defines functionality for LibCyberRadio applications.
Definition: App.h:23
bool setDucFreq(float ducFreq)
Sets the DUC frequency.
TransmitPacketizer(const std::string &radioHostName="", int radioTcpPort=8617, unsigned int ducChannel=1, const std::string &ifname="eth0", unsigned int tenGigIndex=1, int dipIndex=-1, unsigned int ducRate=0, unsigned int ducTxChannels=0, float ducFreq=900e6, float ducAtten=0, double txFreq=900, float txAtten=0, unsigned int streamId=40001, bool config_tx=false, bool debug=false)
Constructs a TransmitPacketizer object.
bool setDucParameters(unsigned int tenGigIndex, unsigned int ducRate, unsigned int ducTxChannels, float ducFreq, float ducAtten, double txFreq, float txAtten, unsigned int streamId)
Sets the DUC parameters.
bool setTxAtten(float txAtten)
Sets the transmitter attenuation.
bool setRadioTcpPort(int radioTcpPort)
Sets the radio TCP port.
bool setDucAtten(float ducAtten)
Sets the DUC attenuation.
bool setStreamId(unsigned int streamId)
Sets the stream ID.
unsigned int sendFrame(short *samples)
Sends a number of samples as a VITA 49 frame.