Files
eden-sim/contrib/tsn/model/tsn-multidrop-channel.h

175 lines
5.0 KiB
C
Raw Permalink Normal View History

2025-12-01 15:56:02 +01:00
#ifndef TSN_MULTIDROP_CHANNEL_H
#define TSN_MULTIDROP_CHANNEL_H
#include "ns3/channel.h"
#include "ns3/data-rate.h"
#include "ns3/nstime.h"
#include "ns3/ptr.h"
#include "ns3/traced-callback.h"
#include <list>
// Add a doxygen group for this module.
// If you have more than one file, this should be in only one of them.
/**
* \defgroup ethernet Description of the ethernet
*/
namespace ns3
{
class TsnNetDevice;
class TsnMultidropNetDevice;
class Packet;
/**
* \ingroup ethernet
* \brief Ethernet Multidrop Channel.
*
* This class represents a half duplex multidrop Ethernet channel, called
* 10BASE-T1S, where the collision are avoid using a mechanism called PLCA
* (Physical Layer Collision Avoidance), implemented in the netDevice.
* This physical layer is proposed in IEEE 802.3cg-2019.
*
*/
class TsnMultidropChannel : public Channel
{
public:
/**
* \brief Get the TypeId
*
* \return The TypeId for this class
*/
static TypeId GetTypeId();
/**
* \brief Create a TsnMultidropChannel
*
* By default, you get a channel that has a 25ns delay no matter
* the netdevice.
*/
TsnMultidropChannel();
/**
* \brief Attach a given netdevice to this channel
* \param device pointer to the netdevice to attach to the channel
*/
void Attach(Ptr<TsnMultidropNetDevice> device);
/**
* \brief Transmit a packet over this channel
* \param p Packet to transmit
* \param src Source TsnNetDevice
* \param txTime Transmit time to apply
* \returns true if successful (currently always true)
*/
virtual bool TransmitStart(Ptr<const Packet> p, Ptr<TsnNetDevice> src, Time txTime);
/**
* \brief Get number of devices on this channel
* \returns number of devices on this channel
*/
std::size_t GetNDevices() const override;
/**
* \brief Get TsnNetDevice corresponding to index i on this channel
* \param i Index number of the device requested
* \returns Ptr to TsnNetDevice requested
*/
Ptr<TsnNetDevice> GetEthernetDevice(std::size_t i) const;
/**
* \brief Get NetDevice corresponding to index i on this channel
* \param i Index number of the device requested
* \returns Ptr to NetDevice requested
*/
Ptr<NetDevice> GetDevice(std::size_t i) const override;
/**
*
*/
void StartBeaconTransmission();
/**
*
*/
void StopBeaconTransmission();
protected:
/**
* \brief Get the delay associated with this channel
* \returns Time delay
*/
Time GetDelay() const;
/**
* \brief Check to make sure the wire is initialized
* \returns true if initialized, asserts otherwise
*/
bool IsInitialized() const;
/**
* TracedCallback signature for packet transmission animation events.
*
* \param [in] packet The packet being transmitted.
* \param [in] txDevice the TransmitTing NetDevice.
* \param [in] rxDevice the Receiving NetDevice.
* \param [in] duration The amount of time to transmit the packet.
* \param [in] lastBitTime Last bit receive time (relative to now)
* \deprecated The non-const \c Ptr<NetDevice> argument is deprecated
* and will be changed to \c Ptr<const NetDevice> in a future release.
*/
typedef void (*TxRxAnimationCallback)(Ptr<const Packet> packet,
Ptr<NetDevice> txDevice,
Ptr<NetDevice> rxDevice,
Time duration,
Time lastBitTime);
private:
std::vector<Ptr<TsnMultidropNetDevice>> m_netDevices;
Time m_delay; //!< Propagation delay
/**
* The trace source for the packet transmission animation events that the
* device can fire.
* Arguments to the callback are the packet, transmitting
* net device, receiving net device, transmission time and
* packet receipt time.
*
* \see class CallBackTraceSource
* \deprecated The non-const \c Ptr<NetDevice> argument is deprecated
* and will be changed to \c Ptr<const NetDevice> in a future release.
*/
TracedCallback<Ptr<const Packet>, // Packet being transmitted
Ptr<NetDevice>, // Transmitting NetDevice
Ptr<NetDevice>, // Receiving NetDevice
Time, // Amount of time to transmit the pkt
Time // Last bit receive time (relative to now)
>
m_txrxEthernet;
/** \brief Wire states
*
*/
enum WireState
{
/** Initializing state */
INITIALIZING,
/** Idle state (no transmission from NetDevice) */
IDLE,
/** Transmitting state (data being transmitted from NetDevice. */
TRANSMITTING,
/** Propagating state (data is being propagated in the channel. */
PROPAGATING
};
WireState m_wireState = INITIALIZING;
};
}
#endif /* TSN_MULTIDROP_CHANNEL_H */