mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
add transmit start for leo mock channels
This commit is contained in:
parent
aa4e5b5ef0
commit
20ad318cb9
8 changed files with 55 additions and 94 deletions
|
@ -52,37 +52,6 @@ IslMockChannel::~IslMockChannel()
|
|||
{
|
||||
}
|
||||
|
||||
bool IslMockChannel::Deliver (
|
||||
Ptr<const Packet> p,
|
||||
Ptr<MockNetDevice> src,
|
||||
Ptr<MockNetDevice> dst,
|
||||
Time txTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
|
||||
Time delay = GetDelay (src, dst, txTime);
|
||||
|
||||
/* Check if there is LOS between the source and destination */
|
||||
if (GetPropagationLoss ()->CalcRxPower(1, src->GetMobilityModel(), dst->GetMobilityModel()) > 0)
|
||||
{
|
||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||
delay,
|
||||
&MockNetDevice::Receive,
|
||||
dst,
|
||||
p->Copy (),
|
||||
src);
|
||||
|
||||
// Call the tx anim callback on the net device
|
||||
m_txrxMock (p, src, dst, txTime, delay);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_LOGIC (dst << " unreachable from " << src);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
IslMockChannel::TransmitStart (
|
||||
Ptr<const Packet> p,
|
||||
|
|
|
@ -59,8 +59,9 @@ public:
|
|||
bool TransmitStart (Ptr<const Packet> p, uint32_t devId, Address dst, Time txTime);
|
||||
|
||||
private:
|
||||
std::vector<Ptr<MockNetDevice> > m_link;
|
||||
|
||||
|
||||
bool Deliver (Ptr<const Packet> p, Ptr<MockNetDevice> src, Ptr<MockNetDevice> dst, Time txTime);
|
||||
}; // class MockChannel
|
||||
|
||||
} // namespace ns3
|
||||
|
|
|
@ -21,13 +21,6 @@ LeoMockChannel::GetTypeId (void)
|
|||
.SetParent<Channel> ()
|
||||
.SetGroupName ("Leo")
|
||||
.AddConstructor<LeoMockChannel> ()
|
||||
.AddAttribute ("ChannelType",
|
||||
"The type of the channel",
|
||||
EnumValue (),
|
||||
MakeEnumAccessor (&LeoMockChannel::m_channelType),
|
||||
MakeEnumChecker (
|
||||
ChannelType::GW, "ns3::LeoMockChannel::ChannelType::GW",
|
||||
ChannelType::UT, "ns3::LeoMockChannel::ChannelType::UT"))
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
@ -51,63 +44,24 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
|||
{
|
||||
// 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)
|
||||
if (!isBroadcast && dstDev == nullptr)
|
||||
{
|
||||
NS_LOG_ERROR ("Dropping packet: invalid destination device");
|
||||
NS_LOG_LOGIC (this << "Dropping packet: direct communication between ground stations and satellites not allowed using this channel");
|
||||
return false;
|
||||
}
|
||||
|
||||
LeoMockNetDevice::DeviceType srcType = srcDev->GetDeviceType ();
|
||||
for (uint32_t i = 0; i < GetNDevices (); i++)
|
||||
{
|
||||
if (srcDev->GetDeviceType () != dstDev->GetDeviceType ())
|
||||
{
|
||||
Deliver (p, srcDev, dstDev, txTime);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace ns3 {
|
|||
* \brief Mocked satellite-gateway, satellite-terminal channel types
|
||||
*
|
||||
*/
|
||||
// TODO make separate clases for ut and gw links
|
||||
// TODO make separate clases for ut and gw devices
|
||||
class LeoMockChannel : public MockChannel
|
||||
{
|
||||
public:
|
||||
|
@ -60,7 +62,6 @@ public:
|
|||
virtual bool TransmitStart (Ptr<const Packet> p, uint32_t devId, Address dst, Time txTime);
|
||||
|
||||
protected:
|
||||
|
||||
enum ChannelType
|
||||
{
|
||||
GW,
|
||||
|
@ -78,6 +79,10 @@ private:
|
|||
|
||||
bool IsChannel (Ptr<LeoMockNetDevice> dstType, Ptr<LeoMockNetDevice> srcType, bool isBroadcast);
|
||||
|
||||
typedef std::map<Address, Ptr<LeoMockNetDevice> > DeviceIndex;
|
||||
DeviceIndex m_gndDevs;
|
||||
DeviceIndex m_satDevs;
|
||||
|
||||
}; // class MockChannel
|
||||
|
||||
} // namespace ns3
|
||||
|
|
|
@ -23,10 +23,8 @@ LeoMockNetDevice::GetTypeId (void)
|
|||
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"))
|
||||
DeviceType::GND, "ns3::LeoMockNetDevice::NetDeviceType::GND",
|
||||
DeviceType::SAT, "ns3::LeoMockNetDevice::NetDeviceType::SAT"))
|
||||
;
|
||||
return tid;
|
||||
};
|
||||
|
|
|
@ -15,10 +15,8 @@ class LeoMockNetDevice : public MockNetDevice
|
|||
public:
|
||||
enum DeviceType
|
||||
{
|
||||
GW,
|
||||
UT,
|
||||
SAT_UT,
|
||||
SAT_GW
|
||||
GND,
|
||||
SAT
|
||||
};
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
|
|
|
@ -152,4 +152,37 @@ MockChannel::GetPropagationLoss () const
|
|||
return m_propagationLoss;
|
||||
}
|
||||
|
||||
bool
|
||||
MockChannel::Deliver (
|
||||
Ptr<const Packet> p,
|
||||
Ptr<MockNetDevice> src,
|
||||
Ptr<MockNetDevice> dst,
|
||||
Time txTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
|
||||
Time delay = GetDelay (src, dst, txTime);
|
||||
|
||||
/* Check if there is LOS between the source and destination */
|
||||
if (GetPropagationLoss ()->CalcRxPower(1, src->GetMobilityModel(), dst->GetMobilityModel()) > 0)
|
||||
{
|
||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||
delay,
|
||||
&MockNetDevice::Receive,
|
||||
dst,
|
||||
p->Copy (),
|
||||
src);
|
||||
|
||||
// Call the tx anim callback on the net device
|
||||
m_txrxMock (p, src, dst, txTime, delay);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_LOGIC (dst << " unreachable from " << src);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
|
|
@ -89,6 +89,9 @@ protected:
|
|||
Ptr<PropagationDelayModel> GetPropagationDelay () const;
|
||||
Ptr<PropagationLossModel> GetPropagationLoss () const;
|
||||
Ptr<MockNetDevice> GetDevice (Address &addr) const;
|
||||
|
||||
bool Deliver ( Ptr<const Packet> p, Ptr<MockNetDevice> src, Ptr<MockNetDevice> dst, Time txTime);
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Ptr<MockNetDevice> > m_link;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue