mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
add mocked leo channel and device
This commit is contained in:
parent
45228b292e
commit
aa4e5b5ef0
5 changed files with 179 additions and 32 deletions
|
@ -4,6 +4,8 @@
|
|||
#include "ns3/ptr.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/enum.h"
|
||||
|
||||
#include "leo-mock-net-device.h"
|
||||
#include "leo-mock-channel.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
@ -24,24 +26,15 @@ LeoMockChannel::GetTypeId (void)
|
|||
EnumValue (),
|
||||
MakeEnumAccessor (&LeoMockChannel::m_channelType),
|
||||
MakeEnumChecker (
|
||||
ChannelType::GW_FORWARD, "ns3::LeoMockChannel::ChannelType::GW_FORWARD",
|
||||
ChannelType::GW_RETURN, "ns3::LeoMockChannel::ChannelType::GW_RETURN",
|
||||
ChannelType::UT_FORWARD, "ns3::LeoMockChannel::ChannelType::UT_FORWARD",
|
||||
ChannelType::UT_RETURN, "ns3::LeoMockChannel::ChannelType::UT_RETURN"))
|
||||
.AddTraceSource ("TxRxLeoMockChannel",
|
||||
"Trace source indicating transmission of packet "
|
||||
"from the LeoMockChannel, used by the Animation "
|
||||
"interface.",
|
||||
MakeTraceSourceAccessor (&LeoMockChannel::m_txrxMock),
|
||||
"ns3::LeoMockChannel::TxRxAnimationCallback")
|
||||
ChannelType::GW, "ns3::LeoMockChannel::ChannelType::GW",
|
||||
ChannelType::UT, "ns3::LeoMockChannel::ChannelType::UT"))
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
//
|
||||
// By default, you get a channel that
|
||||
// has an "infitely" fast transmission speed and zero processing delay.
|
||||
LeoMockChannel::LeoMockChannel() : MockChannel (), m_channelType (LeoMockChannel::ChannelType::UNKNOWN)
|
||||
LeoMockChannel::LeoMockChannel() :
|
||||
MockChannel (),
|
||||
m_channelType (LeoMockChannel::ChannelType::UNKNOWN)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
@ -51,10 +44,69 @@ LeoMockChannel::~LeoMockChannel()
|
|||
}
|
||||
|
||||
bool
|
||||
TransmitStart (Ptr<const Packet> p,
|
||||
uint32_t devId,
|
||||
Address dst, Time txTime)
|
||||
LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
||||
uint32_t devId,
|
||||
Address dst,
|
||||
Time txTime)
|
||||
{
|
||||
// Find devices joined to channel
|
||||
Ptr<LeoMockNetDevice> srcDev = DynamicCast<LeoMockNetDevice> (GetDevice (devId));
|
||||
|
||||
if (srcDev == nullptr)
|
||||
{
|
||||
NS_LOG_ERROR ("Dropping packet: invalid source device");
|
||||
return false;
|
||||
}
|
||||
|
||||
Ptr<LeoMockNetDevice> dstDev = DynamicCast<LeoMockNetDevice> (GetDevice (dst));
|
||||
bool isBroadcast = (srcDev->GetBroadcast () == dst);
|
||||
if (dstDev == nullptr && !isBroadcast)
|
||||
{
|
||||
NS_LOG_ERROR ("Dropping packet: invalid destination device");
|
||||
return false;
|
||||
}
|
||||
|
||||
LeoMockNetDevice::DeviceType srcType = srcDev->GetDeviceType ();
|
||||
|
||||
switch (m_channelType)
|
||||
{
|
||||
case LeoMockChannel::ChannelType::GW:
|
||||
if (srcType == LeoMockNetDevice::GW)
|
||||
{
|
||||
// Get device from SAT_GW set
|
||||
return true;
|
||||
}
|
||||
else if (srcType == LeoMockNetDevice::SAT_GW)
|
||||
{
|
||||
// Get device from GW set
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case LeoMockChannel::ChannelType::UT:
|
||||
if (srcType == LeoMockNetDevice::UT)
|
||||
{
|
||||
// Get device from SAT_UT set
|
||||
return true;
|
||||
}
|
||||
else if (srcType == LeoMockNetDevice::SAT_UT)
|
||||
{
|
||||
// Get device from UT set
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
// Other kinds of transmissions are not allowed
|
||||
default:
|
||||
NS_LOG_ERROR ("Dropping packet: invalid channel type");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apply propagation loss and schedule transmission
|
||||
|
||||
|
||||
// Get propagation delay
|
||||
Time delay = GetDelay (srcDev, dstDev, txTime);
|
||||
|
||||
// Make compiler happy
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue