Update README and add contrib dir
This commit is contained in:
78
contrib/tsn/model/frer-match-recovery-function.cc
Normal file
78
contrib/tsn/model/frer-match-recovery-function.cc
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "frer-match-recovery-function.h"
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE("MatchRecoveryFunction");
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED(MatchRecoveryFunction);
|
||||
|
||||
TypeId
|
||||
MatchRecoveryFunction::GetTypeId()
|
||||
{
|
||||
static TypeId tid =
|
||||
TypeId("ns3::MatchRecoveryFunction")
|
||||
.SetParent<BaseRecoveryFunction>()
|
||||
.SetGroupName("tsn")
|
||||
.AddConstructor<MatchRecoveryFunction>();
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
MatchRecoveryFunction::MatchRecoveryFunction()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
}
|
||||
|
||||
MatchRecoveryFunction::~MatchRecoveryFunction()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
}
|
||||
|
||||
bool
|
||||
MatchRecoveryFunction::DoRecovery(uint16_t seqNumber)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
NS_ASSERT_MSG(m_frerSeqRcvyResetMSec <= m_frerMaxSeqRcvyResetMSec, "Trying to use a longer recovery reset timer than " << m_frerMaxSeqRcvyResetMSec << ".");
|
||||
if(m_takeAny)
|
||||
{
|
||||
m_takeAny = false;
|
||||
m_frerCpsSeqRcvyPassedPackets += 1;
|
||||
m_recovSeqNum = seqNumber;
|
||||
Simulator::Cancel(m_resetEvent);
|
||||
m_resetEvent = Simulator::Schedule(m_frerSeqRcvyResetMSec, &BaseRecoveryFunction::resetRecoveryFunction, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t delta = (seqNumber - m_recovSeqNum)%m_recovSeqSpace;
|
||||
if (delta == 0)
|
||||
{
|
||||
//Pkt has been seen ... drop it
|
||||
m_frerCpsSeqRcvyDiscardedPackets += 1;
|
||||
if(m_frerSeqRcvyIndividualRecovery)
|
||||
{
|
||||
Simulator::Cancel(m_resetEvent);
|
||||
m_resetEvent = Simulator::Schedule(m_frerSeqRcvyResetMSec, &BaseRecoveryFunction::resetRecoveryFunction, this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Pkt hasn't been seen ... accept it
|
||||
if (delta != 1)
|
||||
{
|
||||
//Pkt is out of order
|
||||
m_frerCpsSeqRcvyOutOfOrderPackets += 1;
|
||||
}
|
||||
m_frerCpsSeqRcvyPassedPackets += 1;
|
||||
m_recovSeqNum = seqNumber;
|
||||
Simulator::Cancel(m_resetEvent);
|
||||
m_resetEvent = Simulator::Schedule(m_frerSeqRcvyResetMSec, &BaseRecoveryFunction::resetRecoveryFunction, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user