68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
|
|
#include "stream-identification-function.h"
|
||
|
|
|
||
|
|
#include "ns3/log.h"
|
||
|
|
#include "ns3/uinteger.h"
|
||
|
|
#include "ns3/random-variable-stream.h"
|
||
|
|
|
||
|
|
namespace ns3
|
||
|
|
{
|
||
|
|
|
||
|
|
NS_LOG_COMPONENT_DEFINE("StreamIdentificationFunction");
|
||
|
|
|
||
|
|
NS_OBJECT_ENSURE_REGISTERED(StreamIdentificationFunction);
|
||
|
|
|
||
|
|
TypeId
|
||
|
|
StreamIdentificationFunction::GetTypeId()
|
||
|
|
{
|
||
|
|
static TypeId tid =
|
||
|
|
TypeId("ns3::StreamIdentificationFunction")
|
||
|
|
.SetParent<Object>()
|
||
|
|
.SetGroupName("tsn")
|
||
|
|
.AddConstructor<StreamIdentificationFunction>()
|
||
|
|
.AddAttribute("MinLatencyOverhead",
|
||
|
|
"The minimum latency overhead cause by the identification function hardware implementation",
|
||
|
|
TimeValue(Seconds(0)),
|
||
|
|
MakeTimeAccessor(&StreamIdentificationFunction::m_minLatencyOverhead),
|
||
|
|
MakeTimeChecker())
|
||
|
|
.AddAttribute("MaxLatencyOverhead",
|
||
|
|
"The maximun latency overhead cause by the identification function hardware implementation",
|
||
|
|
TimeValue(Seconds(0)),
|
||
|
|
MakeTimeAccessor(&StreamIdentificationFunction::m_maxLatencyOverhead),
|
||
|
|
MakeTimeChecker());
|
||
|
|
return tid;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
StreamIdentificationFunction::StreamIdentificationFunction()
|
||
|
|
{
|
||
|
|
NS_LOG_FUNCTION(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
StreamIdentificationFunction::~StreamIdentificationFunction()
|
||
|
|
{
|
||
|
|
NS_LOG_FUNCTION(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool
|
||
|
|
StreamIdentificationFunction::Match(Ptr<Packet> p)
|
||
|
|
{
|
||
|
|
NS_LOG_FUNCTION(this);
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
void
|
||
|
|
StreamIdentificationFunction::GetActiveUpdate(Ptr<Packet> p)
|
||
|
|
{
|
||
|
|
NS_LOG_FUNCTION(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
Time
|
||
|
|
StreamIdentificationFunction::GetHardwareLatency()
|
||
|
|
{
|
||
|
|
NS_LOG_FUNCTION(this);
|
||
|
|
Ptr<UniformRandomVariable> randVar = CreateObject<UniformRandomVariable>();
|
||
|
|
return NanoSeconds(randVar->GetValue(m_minLatencyOverhead.GetNanoSeconds(), m_maxLatencyOverhead.GetNanoSeconds()));
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|