#ifndef CBS_H #define CBS_H #include "ns3/tsn-transmission-selection-algo.h" #include "ns3/data-rate.h" #include "ns3/traced-callback.h" namespace ns3 { class Cbs: public TsnTransmissionSelectionAlgo { public: /** * \brief Get the TypeId * * \return The TypeId for this class */ static TypeId GetTypeId(); /** * \brief Create a Cbs */ Cbs(); /** * Destroy a Cbs * * This is the destructor for the Cbs. */ ~Cbs(); // Delete copy constructor and assignment operator to avoid misuse Cbs& operator=(const Cbs&) = delete; Cbs(const Cbs&) = delete; bool IsReadyToTransmit() override; void TransmitStart(Ptr p, Time txTime) override; void TransmitComplete(Ptr p) override; void UpdateTransmissionGate(bool IsOpen) override; TracedCallback m_creditTrace; protected: private: void UpdateCredit(bool trigger_cb); DataRate m_idleSlope; DataRate m_maxIdleSlope; DataRate m_portTransmitRate; double m_credit; Time m_lastUpdateCreditTime; EventId m_NextCreditUpdate; enum State { /** Idle with no pkt in the FIFO */ IDLE, /** Transmitting a packet */ TRANSMITTING, /** Waiting with at least one pkt in the FIFO */ WAITING, }; State m_state; }; } #endif /* CBS_H */