Files

76 lines
1.5 KiB
C
Raw Permalink Normal View History

2025-12-01 15:56:02 +01:00
#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<Packet> p, Time txTime) override;
void TransmitComplete(Ptr<Packet> p) override;
void UpdateTransmissionGate(bool IsOpen) override;
2025-12-02 11:43:04 +01:00
void Update() override;
2025-12-01 15:56:02 +01:00
TracedCallback<double> 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 */