diff --git a/src/lte/examples/lena-dual-stripe.cc b/src/lte/examples/lena-dual-stripe.cc index d365078b8..bb17a98d8 100644 --- a/src/lte/examples/lena-dual-stripe.cc +++ b/src/lte/examples/lena-dual-stripe.cc @@ -248,6 +248,7 @@ main (int argc, char *argv[]) bool epcUl = true; bool useUdp = true; bool generateRem = false; + std::string fadingFileTrace = ""; CommandLine cmd; cmd.AddValue ("nBlocks", "Number of femtocell blocks", nBlocks); @@ -287,6 +288,7 @@ main (int argc, char *argv[]) cmd.AddValue ("useUdp", "if true, the UdpClient application will be used. " "Otherwise, the BulkSend application will be used over a TCP connection. " "If EPC is not used, this parameter will be ignored.", useUdp); + cmd.AddValue ("fadingTrace", "The path of the fading trace (by default any fading trace is loadedm which implies that fading is not considered)", fadingFileTrace); cmd.Parse (argc, argv); @@ -356,6 +358,12 @@ main (int argc, char *argv[]) // use always LOS model lteHelper->SetPathlossModelAttribute ("Los2NlosThr", DoubleValue (1e6)); lteHelper->SetSpectrumChannelType ("ns3::MultiModelSpectrumChannel"); + + if (!fadingFileTrace.empty ()) + { + lteHelper->SetAttribute ("FadingModel", StringValue ("ns3::TraceFadingLossModel")); + lteHelper->SetFadingModelAttribute("TraceFilename", StringValue (fadingFileTrace)); + } Ptr epcHelper; if (epc) @@ -417,13 +425,18 @@ main (int argc, char *argv[]) NetDeviceContainer homeUeDevs = lteHelper->InstallUeDevice (homeUes); NetDeviceContainer::Iterator ueDevIt; - NetDeviceContainer::Iterator enbDevIt; + NetDeviceContainer::Iterator enbDevIt = homeEnbDevs.Begin (); // attach explicitly each home UE to its home eNB - for (ueDevIt = homeUeDevs.Begin (), - enbDevIt = homeEnbDevs.Begin (); - ueDevIt != homeUeDevs.End () && enbDevIt != homeEnbDevs.End (); + for (ueDevIt = homeUeDevs.Begin (); + ueDevIt != homeUeDevs.End (); ++ueDevIt, ++enbDevIt) { + // this because of the order in which SameRoomPositionAllocator + // will place the UEs + if (enbDevIt == homeEnbDevs.End ()) + { + enbDevIt = homeEnbDevs.Begin (); + } lteHelper->Attach (*ueDevIt, *enbDevIt); } diff --git a/src/lte/examples/lena-simple-epc.cc b/src/lte/examples/lena-simple-epc.cc index fbf196a5d..25649ad26 100644 --- a/src/lte/examples/lena-simple-epc.cc +++ b/src/lte/examples/lena-simple-epc.cc @@ -46,14 +46,14 @@ main (int argc, char *argv[]) uint16_t numberOfNodes = 2; double simTime = 5.0; double distance = 60.0; - // Inter packet interval in ms -// double interPacketInterval = 1; double interPacketInterval = 100; // Command line arguments CommandLine cmd; cmd.AddValue("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes); - cmd.AddValue("simTime", "Total duration of the simulation (in seconds)",simTime); + cmd.AddValue("simTime", "Total duration of the simulation [s])", simTime); + cmd.AddValue("distance", "Distance between eNBs [m]", distance); + cmd.AddValue("interPacketInterval", "Inter packet interval [ms])", interPacketInterval); cmd.Parse(argc, argv); Ptr lteHelper = CreateObject (); diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index de58a43a7..6bca4c595 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -101,10 +101,11 @@ LteHelper::DoStart (void) NS_ASSERT_MSG (ulPlm != 0, " " << m_uplinkPathlossModel << " is neither PropagationLossModel nor SpectrumPropagationLossModel"); m_uplinkChannel->AddPropagationLossModel (ulPlm); } - - if (m_fadingModelType.compare ( "ns3::TraceFadingLossModel") == 0) + if (!m_fadingModelType.empty ()) { - m_fadingModule = m_fadingModelFactory.Create (); + Ptr m_fadingModule; + m_fadingModule = m_fadingModelFactory.Create (); + m_fadingModule->Start (); m_downlinkChannel->AddSpectrumPropagationLossModel (m_fadingModule); m_uplinkChannel->AddSpectrumPropagationLossModel (m_fadingModule); } @@ -482,18 +483,7 @@ LteHelper::Attach (Ptr ueDevice, Ptr enbDevice) Ptr uePhy = ueDevice->GetObject ()->GetPhy (); enbPhy->AddUePhy (rnti, uePhy); - if (m_fadingModelType.compare ( "ns3::TraceFadingLossModel") == 0) - { - Ptr mm_enb_dl = enbPhy->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject (); - Ptr mm_ue_ul = uePhy->GetUplinkSpectrumPhy ()->GetMobility ()->GetObject (); - Ptr mm_enb_ul = enbPhy->GetUplinkSpectrumPhy ()->GetMobility ()->GetObject (); - Ptr mm_ue_dl = uePhy->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject (); - - m_fadingModule->CreateFadingChannelRealization (mm_enb_dl, mm_ue_dl); //downlink eNB -> UE - m_fadingModule->CreateFadingChannelRealization (mm_ue_ul, mm_enb_ul); //uplink UE -> eNB - - } - +// // WILD HACK - should be done through PHY SAP, probably passing by RRC uePhy->SetRnti (rnti); uePhy->DoSetBandwidth (enbDevice->GetObject ()->GetUlBandwidth (), diff --git a/src/lte/helper/lte-helper.h b/src/lte/helper/lte-helper.h index bb9a51612..00af60c78 100644 --- a/src/lte/helper/lte-helper.h +++ b/src/lte/helper/lte-helper.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace ns3 { @@ -340,8 +340,6 @@ private: std::string m_fadingModelType; ObjectFactory m_fadingModelFactory; - Ptr m_fadingModule; - Ptr m_macStats; Ptr m_rlcStats; Ptr m_pdcpStats; diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index 77e5cea54..03b32b4c3 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -579,8 +579,10 @@ LteEnbMac::DoReceivePhyPdu (Ptr p) // new RNTI UlInfoListElement_s ulinfonew; ulinfonew.m_rnti = tag.GetRnti (); - std::vector ::iterator it = ulinfonew.m_ulReception.begin (); - ulinfonew.m_ulReception.insert (it + (tag.GetLcid () - 1), p->GetSize ()); + // always allocate full size of ulReception vector, initializing all elements to 0 + ulinfonew.m_ulReception.assign (MAX_LC_LIST+1, 0); + // set the element for the current LCID + ulinfonew.m_ulReception.at (tag.GetLcid ()) = p->GetSize (); ulinfonew.m_receptionStatus = UlInfoListElement_s::Ok; ulinfonew.m_tpc = 0; // Tx power control not implemented at this stage m_ulInfoListElements.insert (std::pair (tag.GetRnti (), ulinfonew)); @@ -588,15 +590,11 @@ LteEnbMac::DoReceivePhyPdu (Ptr p) } else { - if ((*it).second.m_ulReception.size () < tag.GetLcid ()) - { - std::vector ::iterator itV = (*it).second.m_ulReception.begin (); - (*it).second.m_ulReception.insert (itV + (tag.GetLcid () - 1), p->GetSize ()); - } - else - { - (*it).second.m_ulReception.at (tag.GetLcid () - 1) += p->GetSize (); - } + // existing RNTI: we just set the value for the current + // LCID. Note that the corresponding element had already been + // allocated previously. + NS_ASSERT_MSG ((*it).second.m_ulReception.at (tag.GetLcid ()) == 0, "would overwrite previously written ulReception element"); + (*it).second.m_ulReception.at (tag.GetLcid ()) = p->GetSize (); (*it).second.m_receptionStatus = UlInfoListElement_s::Ok; } diff --git a/src/lte/model/lte-ue-mac.cc b/src/lte/model/lte-ue-mac.cc index 086ba2596..72a312d6f 100644 --- a/src/lte/model/lte-ue-mac.cc +++ b/src/lte/model/lte-ue-mac.cc @@ -292,16 +292,22 @@ LteUeMac::SendReportBufferStatus (void) MacCeListElement_s bsr; bsr.m_rnti = m_rnti; bsr.m_macCeType = MacCeListElement_s::BSR; - // BSR - std::map ::iterator it; - NS_ASSERT_MSG (m_ulBsrReceived.size () <=4, " Too many LCs (max is 4)"); - + + // BSR is reported for each LCG. As a simplification, we consider that all LCs belong to the first LCG. + std::map ::iterator it; + int queue = 0; for (it = m_ulBsrReceived.begin (); it != m_ulBsrReceived.end (); it++) { - int queue = (*it).second; - int index = BufferSizeLevelBsr::BufferSize2BsrId (queue); - bsr.m_macCeValue.m_bufferStatus.push_back (index); + queue += (*it).second; + } + int index = BufferSizeLevelBsr::BufferSize2BsrId (queue); + bsr.m_macCeValue.m_bufferStatus.push_back (index); + // FF API says that all 4 LCGs are always present + // we do so but reporting a 0 size for all other LCGs + bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (0)); + bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (0)); + bsr.m_macCeValue.m_bufferStatus.push_back (BufferSizeLevelBsr::BufferSize2BsrId (0)); // create the feedback to eNB Ptr msg = Create (); diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index b574d8214..84cbad53b 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -1025,6 +1025,8 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::S if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR ) { // buffer status report + // note that we only consider LCG 0, the other three LCGs are neglected + // this is consistent with the assumption in LteUeMac that the first LCG gathers all LCs uint16_t rnti = params.m_macCeList.at (i).m_rnti; it = m_ceBsrRxed.find (rnti); if (it == m_ceBsrRxed.end ()) @@ -1032,11 +1034,11 @@ PfFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::S // create the new entry uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0); int buffer = BufferSizeLevelBsr::BsrId2BufferSize (bsrId); - m_ceBsrRxed.insert ( std::pair (rnti, buffer)); // only 1 buffer status is working now + m_ceBsrRxed.insert ( std::pair (rnti, buffer)); } else { - // update the CQI value + // update the buffer size value (*it).second = BufferSizeLevelBsr::BsrId2BufferSize (params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0)); } } diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 53a6a7476..ce5f3d6b8 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -827,6 +827,8 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::S if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR ) { // buffer status report + // note that we only consider LCG 0, the other three LCGs are neglected + // this is consistent with the assumption in LteUeMac that the first LCG gathers all LCs uint16_t rnti = params.m_macCeList.at (i).m_rnti; it = m_ceBsrRxed.find (rnti); if (it == m_ceBsrRxed.end ()) @@ -834,13 +836,12 @@ RrFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::S // create the new entry uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0); int buffer = BufferSizeLevelBsr::BsrId2BufferSize (bsrId); - m_ceBsrRxed.insert ( std::pair (rnti, buffer)); // only 1 buffer status is working now + m_ceBsrRxed.insert ( std::pair (rnti, buffer)); } else { - // update the CQI value + // update the buffer size value (*it).second = BufferSizeLevelBsr::BsrId2BufferSize (params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0)); -// NS_LOG_DEBUG (this << " Update BSR with " << BufferSizeLevelBsr::BsrId2BufferSize (params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0)) << " at " << Simulator::Now ()); } } } diff --git a/src/lte/model/trace-fading-loss-model.cc b/src/lte/model/trace-fading-loss-model.cc index 13bd77646..658c64540 100644 --- a/src/lte/model/trace-fading-loss-model.cc +++ b/src/lte/model/trace-fading-loss-model.cc @@ -109,6 +109,13 @@ TraceFadingLossModel::SetTraceLength (Time t) m_traceLength = t; } +void +TraceFadingLossModel::DoStart () +{ + LoadTrace (); +} + + void TraceFadingLossModel::LoadTrace () { @@ -136,6 +143,7 @@ TraceFadingLossModel::LoadTrace () m_fadingTrace.push_back (rbTimeFadingTrace); } m_timeGranularity = m_traceLength.GetMilliSeconds () / m_samplesNum; + m_lastWindowUpdate = Simulator::Now (); } @@ -150,15 +158,26 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity ( std::map ::iterator itOff; ChannelRealizationId_t mobilityPair = std::make_pair (a,b); itOff = m_windowOffsetsMap.find (mobilityPair); - if (Simulator::Now ().GetSeconds () >= m_lastWindowUpdate.GetSeconds () + m_windowSize.GetSeconds ()) + if (itOff!=m_windowOffsetsMap.end ()) { - NS_LOG_INFO ("Fading Window Updated"); - std::map ::iterator itVar; + if (Simulator::Now ().GetSeconds () >= m_lastWindowUpdate.GetSeconds () + m_windowSize.GetSeconds ()) + { + NS_LOG_INFO ("Fading Window Updated"); + std::map ::iterator itVar; - itVar = m_startVariableMap.find (mobilityPair); - (*itOff).second = (*itVar).second->GetValue (); + itVar = m_startVariableMap.find (mobilityPair); + (*itOff).second = (*itVar).second->GetValue (); - m_lastWindowUpdate = Simulator::Now (); + m_lastWindowUpdate = Simulator::Now (); + } + } + else + { + NS_LOG_LOGIC (this << "insert new channel realization, m_windowOffsetMap.size () = " << m_windowOffsetsMap.size ()); + UniformVariable* startV = new UniformVariable (1, (m_traceLength.GetSeconds () - m_windowSize.GetSeconds ()) * 1000.0); + ChannelRealizationId_t mobilityPair = std::make_pair (a,b); + m_startVariableMap.insert (std::pair (mobilityPair, startV)); + m_windowOffsetsMap.insert (std::pair (mobilityPair, startV->GetValue ())); } @@ -171,7 +190,7 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity ( //double speed = sqrt (pow (aSpeedVector.x-bSpeedVector.x,2) + pow (aSpeedVector.y-bSpeedVector.y,2)); NS_LOG_LOGIC (this << *rxPsd); - + NS_ASSERT (!m_fadingTrace.empty ()); int now_ms = static_cast (Simulator::Now ().GetMilliSeconds () * m_timeGranularity); int lastUpdate_ms = static_cast (m_lastWindowUpdate.GetMilliSeconds () * m_timeGranularity); int index = (*itOff).second + now_ms - lastUpdate_ms; @@ -204,24 +223,5 @@ TraceFadingLossModel::DoCalcRxPowerSpectralDensity ( } -void -TraceFadingLossModel::CreateFadingChannelRealization (Ptr enbMobility, Ptr ueMobility) -{ - NS_LOG_FUNCTION (this << enbMobility << ueMobility); - - if (m_fadingTrace.empty ()) - { - TraceFadingLossModel::LoadTrace (); - m_lastWindowUpdate = Simulator::Now (); - } - - NS_LOG_LOGIC (this << "insert new channel realization, m_windowOffsetMap.size () = " << m_windowOffsetsMap.size ()); - UniformVariable* startV = new UniformVariable (1, (m_traceLength.GetSeconds () - m_windowSize.GetSeconds ()) * 1000.0); - ChannelRealizationId_t mobilityPair = std::make_pair (enbMobility,ueMobility); - m_startVariableMap.insert (std::pair (mobilityPair, startV)); - m_windowOffsetsMap.insert (std::pair (mobilityPair, startV->GetValue ())); - -} - } // namespace ns3 diff --git a/src/lte/model/trace-fading-loss-model.h b/src/lte/model/trace-fading-loss-model.h index 2debba6eb..9b6011520 100644 --- a/src/lte/model/trace-fading-loss-model.h +++ b/src/lte/model/trace-fading-loss-model.h @@ -48,19 +48,14 @@ public: virtual ~TraceFadingLossModel (); static TypeId GetTypeId (); + + virtual void DoStart (void); /** * \brief The couple of mobility mnode that form a fading channel realization */ typedef std::pair, Ptr > ChannelRealizationId_t; - - /** - * \brief Create a fading channel realization among two device - * \param enbMobility mobility object of the enb - * \param ueMobility mobility object of the ue - */ - void CreateFadingChannelRealization (Ptr enbMobility, Ptr ueMobility); private: /** diff --git a/src/lte/test/examples-to-run.py b/src/lte/test/examples-to-run.py index 021f388dd..7963abe2f 100644 --- a/src/lte/test/examples-to-run.py +++ b/src/lte/test/examples-to-run.py @@ -13,6 +13,8 @@ cpp_examples = [ ("lena-dual-stripe --simTime=0.01", "True", "True"), ("lena-dual-stripe --epc=1 --simTime=0.01", "True", "True"), ("lena-dual-stripe --epc=1 --useUdp=0 --simTime=0.01", "True", "True"), + ("lena-dual-stripe --epc=1 --fadingTrace=../../src/lte/model/fading-traces/fading_trace_EPA_3kmph.fad --simTime=0.01", "True", "True"), + ("lena-dual-stripe --nBlocks=1 --nMacroEnbSites=0 --macroUeDensity=0 --homeEnbDeploymentRatio=1 --homeEnbActivationRatio=1 --homeUesHomeEnbRatio=2 --macroEnbTxPowerDbm=0 --simTime=0.01", "True", "True"), ("lena-fading", "True", "True"), ("lena-gtpu-tunnel", "True", "True"), ("lena-intercell-interference", "True", "True"), diff --git a/src/network/model/net-device.h b/src/network/model/net-device.h index 1ada158b7..b259a1603 100644 --- a/src/network/model/net-device.h +++ b/src/network/model/net-device.h @@ -59,7 +59,7 @@ class Packet; * * If you want to write a new MAC layer, you need to subclass * this base class and implement your own version of the - * NetDevice::SendTo method. + * pure virtual methods in this class. * * This class was designed to hide as many MAC-level details as * possible from the perspective of layer 3 to allow a single layer 3