GNU Radio's SATELLITES Package
packet_csma.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2025 Daniel Estevez <daniel@destevez.net>.
4 *
5 * This file is part of gr-satellites
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 */
9
10#ifndef INCLUDED_SATELLITES_PACKET_CSMA_H
11#define INCLUDED_SATELLITES_PACKET_CSMA_H
12
13#include <gnuradio/block.h>
14#include <satellites/api.h>
15#include <string>
16
17namespace gr {
18namespace satellites {
19
20/*!
21 * \brief Passes packets to the output only when carrier sense is not triggering
22 * \ingroup satellites
23 *
24 * \details
25 *
26 * This block implements a CSMA system for a stream of packets delimited by
27 * packet_len tags. The block expects to receive messages from a carrier sense
28 * detector that indicate the current carrier sense state every time that the
29 * state changes. These messages should be a pair containing a bool in the cdr.
30 *
31 * Whenever a new packet arrives to this block, the current status of the
32 * carrier sense is checked, and the packet is only propagated to the output if
33 * the carrier sense is false. Otherwise the packet is retained until carrier
34 * sense becomes false.
35 *
36 * As an exception to this rule, if 'back_to_back_priority' is set to true and a
37 * packet arrives back-to-back (meaning that it begins in the same work() call
38 * as the end of the previous packet), then the packet is propagated to the
39 * output immediately regardless of the current state of the carrier sense. This
40 * is mainly intended as a workaround for systems in which the carrier sense
41 * might detect the packets transmitted by this system due to TX to RX leakage.
42 *
43 */
44class SATELLITES_API packet_csma : virtual public gr::block
45{
46public:
47 typedef std::shared_ptr<packet_csma> sptr;
48
49 /*!
50 * \brief Build the Level to Packet CSMA block.
51 *
52 * \param itemsize Size of the items in bytes.
53 * \param back_to_back_priority Transmit back-to-back packets ignoring the
54 * carrier sense.
55 * \param len_tag_key Packet length key of the tagged stream.
56 */
57 static sptr make(size_t itemsize,
58 bool back_to_back_priority,
59 const std::string& len_tag_key = "packet_len");
60};
61
62} // namespace satellites
63} // namespace gr
64
65#endif /* INCLUDED_SATELLITES_PACKET_CSMA_H */
#define SATELLITES_API
Definition: api.h:31
Passes packets to the output only when carrier sense is not triggering.
Definition: packet_csma.h:45
std::shared_ptr< packet_csma > sptr
Definition: packet_csma.h:47
static sptr make(size_t itemsize, bool back_to_back_priority, const std::string &len_tag_key="packet_len")
Build the Level to Packet CSMA block.
Definition: ax100_decode.h:17