Update README and add contrib dir

This commit is contained in:
2025-12-01 15:56:02 +01:00
parent 1b80de2153
commit cd9ba93d58
150 changed files with 25563 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
#include "clock.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
namespace ns3
{
NS_LOG_COMPONENT_DEFINE("Clock");
NS_OBJECT_ENSURE_REGISTERED(Clock);
TypeId
Clock::GetTypeId()
{
static TypeId tid =
TypeId("ns3::Clock")
.SetParent<Object>()
.SetGroupName("tsn")
.AddConstructor<Clock>()
.AddAttribute("Granularity",
"Clock granularity in ns",
TimeValue(Time(NanoSeconds(1))),
MakeTimeAccessor(&Clock::m_granularity),
MakeTimeChecker());
return tid;
}
Clock::Clock()
{
NS_LOG_FUNCTION(this);
}
Clock::~Clock()
{
NS_LOG_FUNCTION(this);
}
Time
Clock::GetLocalTime()
{
NS_LOG_FUNCTION(this);
return GetUncorrectedLocalTime() + m_correctionOffset;
}
Time
Clock::GetUncorrectedLocalTime()
{
NS_LOG_FUNCTION(this);
return Simulator::Now();
}
Time
Clock::GetTimeAt(Time t)
{
NS_LOG_FUNCTION(this);
return t;
}
Time
Clock::GetDuration(Time d)
{
NS_LOG_FUNCTION(this);
return d;
}
void
Clock::UpdateTime(){
NS_LOG_FUNCTION(this);
}
void
Clock::SetOffsetTime(Time offset)
{
NS_LOG_FUNCTION(this);
m_correctionOffset = offset;
TriggerCorrectionCallback();
}
void
Clock::AddClockCorrectionCallback(Callback<void> cb)
{
NS_LOG_FUNCTION(this);
m_callbacks.insert(m_callbacks.end(), cb);
}
void
Clock::TriggerCorrectionCallback()
{
NS_LOG_FUNCTION(this);
for(int i = 0; i < (int)m_callbacks.size(); i++)
{
m_callbacks[i]();
}
}
}