229 lines
6.3 KiB
C
229 lines
6.3 KiB
C
|
|
#ifndef REAL_SWITCH_H
|
||
|
|
#define REAL_SWITCH_H
|
||
|
|
|
||
|
|
#include "ns3/object.h"
|
||
|
|
|
||
|
|
#include "ns3/tsn-node.h"
|
||
|
|
#include "ns3/tsn-net-device.h"
|
||
|
|
#include "ns3/stream-identification-function-null.h"
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
namespace ns3
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \ingroup real-device
|
||
|
|
*
|
||
|
|
* \brief A object to simulate real switch.
|
||
|
|
*/
|
||
|
|
class RealSwitch: public Object
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Get the TypeId
|
||
|
|
*
|
||
|
|
* \return The TypeId for this class
|
||
|
|
*/
|
||
|
|
static TypeId GetTypeId();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Create a RealSwitch
|
||
|
|
*/
|
||
|
|
RealSwitch();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Create a RealSwitch
|
||
|
|
*/
|
||
|
|
RealSwitch(std::string name);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Destroy a RealSwitch
|
||
|
|
*
|
||
|
|
* This is the destructor for the TsnNode.
|
||
|
|
*/
|
||
|
|
~RealSwitch();
|
||
|
|
|
||
|
|
// Delete copy constructor and assignment operator to avoid misuse
|
||
|
|
RealSwitch& operator=(const RealSwitch&) = delete;
|
||
|
|
RealSwitch(const RealSwitch&) = delete;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Set most of the hardware limits
|
||
|
|
*/
|
||
|
|
void SetHardwareLimits();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Get a TsnNetDevice from its port id
|
||
|
|
* \param id the port id
|
||
|
|
* \return The TsnNetDevice
|
||
|
|
*/
|
||
|
|
Ptr<TsnNetDevice> GetPort(int id);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a entry in the forwarding database
|
||
|
|
* \param dest the mac address destination
|
||
|
|
* \param vlan_id the vlan id
|
||
|
|
* \param output_port_ids a vector of output port id
|
||
|
|
*/
|
||
|
|
void AddForwardingTableEntry(
|
||
|
|
Mac48Address dest,
|
||
|
|
uint16_t vlan_id,
|
||
|
|
std::vector<uint32_t> output_port_ids);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Set the datarate of a port
|
||
|
|
* \param id the port id
|
||
|
|
* \param d the datarate
|
||
|
|
*/
|
||
|
|
void SetPortDatarate(int id, DataRate d);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a CBS instance to a port and queue
|
||
|
|
* \para the port id
|
||
|
|
* \param the queue id
|
||
|
|
* \param the iddle_slope
|
||
|
|
* \param the port_transmit_rate
|
||
|
|
*/
|
||
|
|
void AddCbs(uint32_t port_id, uint32_t queue_id, DataRate iddle_slope, DataRate port_transmit_rate);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a GCL entry to a port
|
||
|
|
* \para the port id
|
||
|
|
* \param the GCL entry duration
|
||
|
|
* \param the GCL entry state
|
||
|
|
*/
|
||
|
|
void AddGclEntry(uint32_t port_id, Time interval, uint8_t state);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Start TAS operation
|
||
|
|
*/
|
||
|
|
void StartTas();
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a null stream identification function
|
||
|
|
* \para streamHandle
|
||
|
|
* \param stream Identification Function
|
||
|
|
* \param out-facing input port ids
|
||
|
|
* \param in-facing input port ids
|
||
|
|
* \param in-facing output port ids
|
||
|
|
* \param out-facing output port ids
|
||
|
|
*/
|
||
|
|
void
|
||
|
|
AddNullStreamIdentificationFunction(
|
||
|
|
uint32_t streamHandle,
|
||
|
|
Ptr<NullStreamIdentificationFunction> streamIdentificationFunction,
|
||
|
|
std::vector<uint32_t> outFacInputPortIds,
|
||
|
|
std::vector<uint32_t> inFacInputPortIds,
|
||
|
|
std::vector<uint32_t> inFacOutputPortIds,
|
||
|
|
std::vector<uint32_t> outFacOutputPortIds);
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a stream filter to the node
|
||
|
|
* \param the stream filter instance
|
||
|
|
*/
|
||
|
|
void
|
||
|
|
AddStreamFilter(Ptr<StreamFilterInstance> streamFilterInstance);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add a flow meter to the node
|
||
|
|
* \param the flow meter instance
|
||
|
|
*/
|
||
|
|
uint16_t
|
||
|
|
AddFlowMeter(Ptr<FlowMeterInstance> flowMeterInstance);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add generation function to the node
|
||
|
|
* \param the genertation function
|
||
|
|
*/
|
||
|
|
void
|
||
|
|
AddSequenceGenerationFunction(Ptr<SequenceGenerationFunction> entry);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add recovery function to the node
|
||
|
|
* \param the recovery function
|
||
|
|
* \param the recovery algo (match or vector)
|
||
|
|
* \param the latent error detection function
|
||
|
|
* \param the port ids
|
||
|
|
*/
|
||
|
|
void
|
||
|
|
AddSequenceRecoveryFunction(Ptr<SequenceRecoveryFunction> rcvy, Ptr<BaseRecoveryFunction> algo, Ptr<LatentErrorDetectionFunction> lat, std::vector<uint32_t> port_ids);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* \brief Add encode/decode function to the node
|
||
|
|
* \param the encode/decode function
|
||
|
|
* \param the port id
|
||
|
|
*/
|
||
|
|
void
|
||
|
|
AddSequenceEncodeDecodeFunction(Ptr<SequenceEncodeDecodeFunction> entry, uint32_t port_id);
|
||
|
|
|
||
|
|
|
||
|
|
protected:
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Update the parent hardware characteristics with the child values
|
||
|
|
*/
|
||
|
|
virtual void UpdateParentHardwareCharacteristics();
|
||
|
|
|
||
|
|
|
||
|
|
Ptr<TsnNode> m_node;
|
||
|
|
std::vector<Ptr<TsnNetDevice>> m_net_devices;
|
||
|
|
Ptr<SwitchNetDevice> m_switch_net_device;
|
||
|
|
|
||
|
|
|
||
|
|
//Hardware limits
|
||
|
|
uint16_t m_portNumber = 0;
|
||
|
|
uint16_t m_queuesPerPort = 8;
|
||
|
|
uint16_t m_maxFdbEntryNumber = 0;
|
||
|
|
QueueSize m_fifoSize = QueueSize("0p");
|
||
|
|
Time m_minForwardingLatency = Seconds(0);
|
||
|
|
Time m_maxForwardingLatency = Seconds(0);
|
||
|
|
|
||
|
|
//CBS
|
||
|
|
DataRate m_maxIddleSlope = DataRate("0Gb/s");
|
||
|
|
Time m_minCBSLatencyOverhead = Seconds(0);
|
||
|
|
Time m_maxCBSLatencyOverhead = Seconds(0);
|
||
|
|
|
||
|
|
//Tas
|
||
|
|
uint32_t m_maxGclEntryNumber = 0;
|
||
|
|
Time m_maxGclCycleDuration = Seconds(0);
|
||
|
|
Time m_maxGclTimeInterval = Seconds(0);
|
||
|
|
Time m_minTASLatencyOverhead = Seconds(0);
|
||
|
|
Time m_maxTASLatencyOverhead = Seconds(0);
|
||
|
|
|
||
|
|
//Stream identification
|
||
|
|
uint32_t m_maxSidEntryNumber = 0;
|
||
|
|
Time m_minNullSIDLatencyOverhead = Seconds(0);
|
||
|
|
Time m_maxNullSIDLatencyOverhead = Seconds(0);
|
||
|
|
Time m_minSourceMacSIDLatencyOverhead = Seconds(0);
|
||
|
|
Time m_maxSourceMacSIDLatencyOverhead = Seconds(0);
|
||
|
|
|
||
|
|
//PSFP
|
||
|
|
uint32_t m_maxPsfpFilterEntryNumber = 0;
|
||
|
|
uint32_t m_maxPsfpStreamGateEntryNumber = 0;
|
||
|
|
uint32_t m_maxPsfpFlowMeterEntryNumber = 0;
|
||
|
|
|
||
|
|
//FRER
|
||
|
|
uint32_t m_maxFrerSeqGenEntryNumber = 0;
|
||
|
|
uint32_t m_maxFrerSeqRcvyEntryNumber = 0;
|
||
|
|
uint32_t m_maxFrerSeqEncEntryNumber = 0;
|
||
|
|
Time m_minFrerSeqRcvyResetDuration = Seconds(0);
|
||
|
|
Time m_maxFrerSeqRcvyResetDuration = Seconds(0);
|
||
|
|
Time m_minFrerLatErrorTestDuration = Seconds(0);
|
||
|
|
Time m_maxFrerLatErrorTestDuration = Seconds(0);
|
||
|
|
Time m_minFrerLatErrorResetDuration = Seconds(0);
|
||
|
|
Time m_maxFrerLatErrorResetDuration = Seconds(0);
|
||
|
|
Time m_minFrerRcvyLatencyOverhead = Seconds(0);
|
||
|
|
Time m_maxFrerRcvyLatencyOverhead = Seconds(0);
|
||
|
|
|
||
|
|
private:
|
||
|
|
};
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif /* REAL_SWITCH_H */
|