mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
refactor stuff
This commit is contained in:
parent
57b04d6424
commit
97de8c9d24
15 changed files with 135 additions and 88 deletions
|
@ -74,6 +74,7 @@ IslMockChannel::TransmitStart (
|
|||
{
|
||||
if (i == srcId) continue;
|
||||
dst = DynamicCast<MockNetDevice> (GetDevice (i));
|
||||
// TODO check LOS using mobility model
|
||||
Deliver (p, src, dst, txTime);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -41,6 +41,8 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
|||
Address dst,
|
||||
Time txTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << devId << dst << txTime);
|
||||
|
||||
// Find devices joined to channel
|
||||
Ptr<MockNetDevice> srcDev = DynamicCast<MockNetDevice> (GetDevice (devId));
|
||||
if (srcDev == 0)
|
||||
|
@ -50,36 +52,29 @@ LeoMockChannel::TransmitStart (Ptr<const Packet> p,
|
|||
}
|
||||
|
||||
bool fromGround = m_groundDevices.find (srcDev->GetAddress ()) != m_groundDevices.end ();
|
||||
bool fromSpace = m_satelliteDevices.find (srcDev->GetAddress ()) != m_satelliteDevices.end ();
|
||||
|
||||
NS_ASSERT_MSG (!(fromGround && fromSpace), "Source device can not be both on ground and in space");
|
||||
|
||||
DeviceIndex *dests;
|
||||
if (fromGround)
|
||||
{
|
||||
// Satellites can always directly be addresses
|
||||
// Assume beams are narrow enough to not also receive the signal at other
|
||||
// satellites for performance reasons.
|
||||
DeviceIndex::iterator it = m_satelliteDevices.find (dst);
|
||||
if (it == m_satelliteDevices.end ())
|
||||
{
|
||||
NS_LOG_ERROR ("unable to find satellite with address " << dst);
|
||||
return false;
|
||||
}
|
||||
return Deliver (p, srcDev, it->second, txTime);
|
||||
dests = &m_satelliteDevices;
|
||||
}
|
||||
else if (srcDev->IsBroadcast () || srcDev->IsMulticast ())
|
||||
// space to ground delivers to everything within the beam
|
||||
else if (fromSpace)
|
||||
{
|
||||
DeviceIndex::iterator it = m_groundDevices.find (dst);
|
||||
if (it == m_groundDevices.end ())
|
||||
{
|
||||
NS_LOG_ERROR ("unable to find satellite with address " << dst);
|
||||
return false;
|
||||
}
|
||||
for (DeviceIndex::iterator it = m_groundDevices.begin ();
|
||||
it != m_groundDevices.end ();
|
||||
it++)
|
||||
{
|
||||
// TODO deliver only to devices in the same beam
|
||||
Deliver (p, srcDev, it->second, txTime);
|
||||
}
|
||||
dests = &m_groundDevices;
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_ERROR ("unable to find satellite with address " << dst);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (DeviceIndex::iterator it = dests->begin (); it != dests->end (); it ++)
|
||||
{
|
||||
// TODO deliver only to devices in the same beam
|
||||
Deliver (p, srcDev, it->second, txTime);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -115,7 +115,7 @@ MockChannel::GetDevice (std::size_t i) const
|
|||
Time
|
||||
MockChannel::GetDelay (Ptr<const MockNetDevice> src, Ptr<const MockNetDevice> dst, Time txTime) const
|
||||
{
|
||||
NS_LOG_DEBUG ("Get delay from " << src << " to " << dst);
|
||||
NS_LOG_FUNCTION (this << src << dst << txTime);
|
||||
|
||||
Ptr<MobilityModel> modSrc = src->GetNode ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> modDst = dst->GetNode ()->GetObject<MobilityModel> ();
|
||||
|
@ -160,29 +160,19 @@ MockChannel::Deliver (
|
|||
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->GetNode ()->GetObject<MobilityModel> (), dst->GetNode ()->GetObject<MobilityModel> ()) > 0)
|
||||
{
|
||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||
delay,
|
||||
&MockNetDevice::Receive,
|
||||
dst,
|
||||
p->Copy (),
|
||||
src);
|
||||
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;
|
||||
}
|
||||
// Call the tx anim callback on the net device
|
||||
m_txrxMock (p, src, dst, txTime, delay);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue