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/ptr.h"
|
||||||
#include "ns3/log.h"
|
#include "ns3/log.h"
|
||||||
#include "ns3/enum.h"
|
#include "ns3/enum.h"
|
||||||
|
|
||||||
|
#include "leo-mock-net-device.h"
|
||||||
#include "leo-mock-channel.h"
|
#include "leo-mock-channel.h"
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
@ -24,24 +26,15 @@ LeoMockChannel::GetTypeId (void)
|
||||||
EnumValue (),
|
EnumValue (),
|
||||||
MakeEnumAccessor (&LeoMockChannel::m_channelType),
|
MakeEnumAccessor (&LeoMockChannel::m_channelType),
|
||||||
MakeEnumChecker (
|
MakeEnumChecker (
|
||||||
ChannelType::GW_FORWARD, "ns3::LeoMockChannel::ChannelType::GW_FORWARD",
|
ChannelType::GW, "ns3::LeoMockChannel::ChannelType::GW",
|
||||||
ChannelType::GW_RETURN, "ns3::LeoMockChannel::ChannelType::GW_RETURN",
|
ChannelType::UT, "ns3::LeoMockChannel::ChannelType::UT"))
|
||||||
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")
|
|
||||||
;
|
;
|
||||||
return tid;
|
return tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
LeoMockChannel::LeoMockChannel() :
|
||||||
// By default, you get a channel that
|
MockChannel (),
|
||||||
// has an "infitely" fast transmission speed and zero processing delay.
|
m_channelType (LeoMockChannel::ChannelType::UNKNOWN)
|
||||||
LeoMockChannel::LeoMockChannel() : MockChannel (), m_channelType (LeoMockChannel::ChannelType::UNKNOWN)
|
|
||||||
{
|
{
|
||||||
NS_LOG_FUNCTION_NOARGS ();
|
NS_LOG_FUNCTION_NOARGS ();
|
||||||
}
|
}
|
||||||
|
@ -51,10 +44,69 @@ LeoMockChannel::~LeoMockChannel()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TransmitStart (Ptr<const Packet> p,
|
LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
||||||
uint32_t devId,
|
uint32_t devId,
|
||||||
Address dst, Time txTime)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "ns3/mobility-module.h"
|
#include "ns3/mobility-module.h"
|
||||||
#include "ns3/propagation-delay-model.h"
|
#include "ns3/propagation-delay-model.h"
|
||||||
#include "ns3/propagation-loss-model.h"
|
#include "ns3/propagation-loss-model.h"
|
||||||
#include "mock-net-device.h"
|
#include "leo-mock-net-device.h"
|
||||||
#include "mock-channel.h"
|
#include "mock-channel.h"
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
@ -63,10 +63,8 @@ protected:
|
||||||
|
|
||||||
enum ChannelType
|
enum ChannelType
|
||||||
{
|
{
|
||||||
GW_FORWARD,
|
GW,
|
||||||
GW_RETURN,
|
UT,
|
||||||
UT_FORWARD,
|
|
||||||
UT_RETURN,
|
|
||||||
UNKNOWN
|
UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,6 +76,8 @@ private:
|
||||||
*/
|
*/
|
||||||
ChannelType m_channelType;
|
ChannelType m_channelType;
|
||||||
|
|
||||||
|
bool IsChannel (Ptr<LeoMockNetDevice> dstType, Ptr<LeoMockNetDevice> srcType, bool isBroadcast);
|
||||||
|
|
||||||
}; // class MockChannel
|
}; // class MockChannel
|
||||||
|
|
||||||
} // namespace ns3
|
} // namespace ns3
|
||||||
|
|
50
model/leo-mock-net-device.cc
Normal file
50
model/leo-mock-net-device.cc
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#include "ns3/log.h"
|
||||||
|
#include "ns3/enum.h"
|
||||||
|
|
||||||
|
#include "leo-mock-net-device.h"
|
||||||
|
|
||||||
|
namespace ns3
|
||||||
|
{
|
||||||
|
|
||||||
|
NS_LOG_COMPONENT_DEFINE ("LeoMockNetDevice");
|
||||||
|
|
||||||
|
NS_OBJECT_ENSURE_REGISTERED (LeoMockNetDevice);
|
||||||
|
|
||||||
|
TypeId
|
||||||
|
LeoMockNetDevice::GetTypeId (void)
|
||||||
|
{
|
||||||
|
static TypeId tid = TypeId ("ns3::LeoMockNetDevice")
|
||||||
|
.SetParent<MockNetDevice> ()
|
||||||
|
.SetGroupName ("Leo")
|
||||||
|
.AddConstructor<LeoMockNetDevice> ()
|
||||||
|
.AddAttribute ("DeviceType", "The type of the mocked device",
|
||||||
|
EnumValue (),
|
||||||
|
MakeEnumAccessor (&LeoMockNetDevice::m_deviceType),
|
||||||
|
MakeEnumChecker (
|
||||||
|
DeviceType::GW, "ns3::LeoMockNetDevice::NetDeviceType::GW_FORWARD",
|
||||||
|
DeviceType::UT, "ns3::LeoMockNetDevice::NetDeviceType::GW_RETURN",
|
||||||
|
DeviceType::SAT_GW, "ns3::LeoMockNetDevice::NetDeviceType::UT_FORWARD",
|
||||||
|
DeviceType::SAT_UT, "ns3::LeoMockNetDevice::NetDeviceType::UT_RETURN"))
|
||||||
|
;
|
||||||
|
return tid;
|
||||||
|
};
|
||||||
|
|
||||||
|
LeoMockNetDevice::LeoMockNetDevice ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LeoMockNetDevice::DeviceType
|
||||||
|
LeoMockNetDevice::GetDeviceType () const
|
||||||
|
{
|
||||||
|
return m_deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LeoMockNetDevice::SetDeviceType (LeoMockNetDevice::DeviceType deviceType)
|
||||||
|
{
|
||||||
|
m_deviceType = deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; /* namspace ns3 */
|
41
model/leo-mock-net-device.h
Normal file
41
model/leo-mock-net-device.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#ifndef LEO_MOCK_NET_DEVICE_H_
|
||||||
|
#define LEO_MOCK_NET_DEVICE_H_
|
||||||
|
|
||||||
|
#include "mock-net-device.h"
|
||||||
|
|
||||||
|
namespace ns3
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* \brief A mocked satellite-ground link communication device with a type
|
||||||
|
*/
|
||||||
|
class LeoMockNetDevice : public MockNetDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum DeviceType
|
||||||
|
{
|
||||||
|
GW,
|
||||||
|
UT,
|
||||||
|
SAT_UT,
|
||||||
|
SAT_GW
|
||||||
|
};
|
||||||
|
|
||||||
|
static TypeId GetTypeId (void);
|
||||||
|
|
||||||
|
LeoMockNetDevice ();
|
||||||
|
|
||||||
|
virtual ~LeoMockNetDevice ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceType GetDeviceType () const;
|
||||||
|
void SetDeviceType (DeviceType deviceType);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DeviceType m_deviceType;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* LEO_MOCK_NET_DEVICE_H_ */
|
24
wscript
24
wscript
|
@ -9,14 +9,16 @@
|
||||||
def build(bld):
|
def build(bld):
|
||||||
module = bld.create_ns3_module('leo', ['core','internet', 'propagation', 'stats', 'traffic', 'flow-monitor', 'applications'])
|
module = bld.create_ns3_module('leo', ['core','internet', 'propagation', 'stats', 'traffic', 'flow-monitor', 'applications'])
|
||||||
module.source = [
|
module.source = [
|
||||||
'model/leo.cc',
|
|
||||||
'model/mock-net-device.cc',
|
|
||||||
'model/mock-channel.cc',
|
|
||||||
'model/isl-mock-channel.cc',
|
'model/isl-mock-channel.cc',
|
||||||
'model/isl-propagation-loss-model.cc',
|
'model/isl-propagation-loss-model.cc',
|
||||||
'model/leo-mobility-model.cc',
|
|
||||||
'helper/leo-helper.cc',
|
|
||||||
'helper/isl-helper.cc',
|
'helper/isl-helper.cc',
|
||||||
|
'model/leo.cc',
|
||||||
|
'model/leo-mobility-model.cc',
|
||||||
|
'model/leo-mock-channel.cc',
|
||||||
|
'model/leo-mock-net-device.cc',
|
||||||
|
'helper/leo-helper.cc',
|
||||||
|
'model/mock-net-device.cc',
|
||||||
|
'model/mock-channel.cc',
|
||||||
]
|
]
|
||||||
|
|
||||||
module_test = bld.create_ns3_module_test_library('leo')
|
module_test = bld.create_ns3_module_test_library('leo')
|
||||||
|
@ -27,14 +29,16 @@ def build(bld):
|
||||||
headers = bld(features='ns3header')
|
headers = bld(features='ns3header')
|
||||||
headers.module = 'leo'
|
headers.module = 'leo'
|
||||||
headers.source = [
|
headers.source = [
|
||||||
'model/leo.h',
|
|
||||||
'model/mock-net-device.h',
|
|
||||||
'model/mock-channel.h',
|
|
||||||
'model/isl-mock-channel.h',
|
'model/isl-mock-channel.h',
|
||||||
'model/isl-propagation-loss-model.h',
|
'model/isl-propagation-loss-model.h',
|
||||||
'model/leo-mobility-model.h',
|
|
||||||
'helper/leo-helper.h',
|
|
||||||
'helper/isl-helper.h',
|
'helper/isl-helper.h',
|
||||||
|
'model/leo.h',
|
||||||
|
'model/leo-mobility-model.h',
|
||||||
|
'model/leo-mock-channel.h',
|
||||||
|
'model/leo-mock-net-device.h',
|
||||||
|
'helper/leo-helper.h',
|
||||||
|
'model/mock-net-device.h',
|
||||||
|
'model/mock-channel.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
if bld.env.ENABLE_EXAMPLES:
|
if bld.env.ENABLE_EXAMPLES:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue