--- a/src/lte/model/lte-phy-tag.cc Mon Mar 14 13:23:01 2011 +0100
+++ b/src/lte/model/lte-phy-tag.cc Tue Mar 15 11:22:36 2011 +0100
@@ -20,7 +20,7 @@
*/
-#include "lte-mac-tag.h"
+#include "lte-phy-tag.h"
#include "ns3/tag.h"
#include "ns3/uinteger.h"
@@ -44,55 +44,47 @@
return GetTypeId ();
}
-LtePhyTag::LtePhyTag (Ptr<LtePhy> enbPhy)
- : m_enbPhy (enbPhy.PeekPointer ())
+LtePhyTag::LtePhyTag ()
+{
+}
+
+LtePhyTag::LtePhyTag (uint16_t cellId)
+ : m_cellId (cellId)
+{
+}
+
+LtePhyTag::~LtePhyTag ()
{
}
uint32_t
LtePhyTag::GetSerializedSize (void) const
{
- return sizeof (void*);
+ return 2;
}
void
LtePhyTag::Serialize (TagBuffer i) const
{
- switch (sizeof (void*))
- {
- case 4:
- i.WriteU32 ((uint32_t) m_enbPhy);
- break;
- case 8:
- i.WriteU64 ((uint64_t) m_enbPhy);
- break;
- default:
- NS_FATAL ("unknown pointer size");
- break;
- }
+ i.WriteU16 (m_cellId);
}
void
LtePhyTag::Deserialize (TagBuffer i)
{
- switch (sizeof (void*))
- {
- case 4:
- m_enbPhy = (LtePhy*) i.ReadU32 ();
- break;
- case 8:
- m_enbPhy = (LtePhy*) i.ReadU64 ();
- break;
- default:
- NS_FATAL ("unknown pointer size");
- break;
- }
+ m_cellId = i.ReadU16 ();
}
void
LtePhyTag::Print (std::ostream &os) const
{
- os << "0x" << std::hex << m_enbPhy << std::dec;
+ os << m_cellId;
+}
+
+uint16_t
+LtePhyTag::GetCellId () const
+{
+ return m_cellId;
}
} // namespace ns3
--- a/src/lte/model/lte-phy-tag.h Mon Mar 14 13:23:01 2011 +0100
+++ b/src/lte/model/lte-phy-tag.h Tue Mar 15 11:22:36 2011 +0100
@@ -42,18 +42,21 @@
/**
* Create a LtePhyTag with the given RNTI and LC id
*/
- LtePhyTag (Ptr<LtePhy> enbPhy);
+ LtePhyTag (uint16_t cellId);
+
+
+ virtual ~LtePhyTag ();
virtual void Serialize (TagBuffer i) const;
virtual void Deserialize (TagBuffer i);
virtual uint32_t GetSerializedSize () const;
virtual void Print (std::ostream &os) const;
- bool IsEnbPhyEqual () const;
+ uint16_t GetCellId () const;
private:
- LtePhy* m_enbPhy;
+ uint16_t m_cellId;
};
--- a/src/lte/model/lte-spectrum-phy.cc Mon Mar 14 13:23:01 2011 +0100
+++ b/src/lte/model/lte-spectrum-phy.cc Tue Mar 15 11:22:36 2011 +0100
@@ -29,6 +29,7 @@
#include "lte-net-device.h"
#include "lte-mac-tag.h"
#include "lte-sinr-chunk-processor.h"
+#include "lte-phy-tag.h"
NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy");
@@ -166,7 +167,7 @@
LteSpectrumPhy::GetSpectrumType ()
{
NS_LOG_FUNCTION (this);
- static SpectrumType st = SpectrumTypeFactory::Create ("IdealOfdm");
+ static SpectrumType st = SpectrumTypeFactory::Create ("Lte");
return st;
}
@@ -239,44 +240,54 @@
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
- != pb->End (); ++iter)
+ != pb->End (); ++iter)
{
Ptr<Packet> packet = (*iter)->Copy ();
m_phyTxStartTrace (packet);
}
-
- if (m_state == LteSpectrumPhy::RX)
+ switch (m_state)
{
- /*
- * NS FATAL ERROR: according to FDD channel acces,
- * the physical layer for transmission cannot be used for reception.
- */
- NS_FATAL_ERROR ("FDD ERROR: R State while sending packet");
- }
-
- if (m_state == LteSpectrumPhy::IDLE)
- {
+ case RX:
+ NS_FATAL_ERROR ("cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception");
+ break;
- /*
- m_txPsd must be setted by the device, according to
- (i) the available subchannel for transmission
- (ii) the power transmission
- */
- NS_ASSERT (m_txPsd);
-
- m_txPacketBurst = pb;
- ChangeState (TX);
- NS_ASSERT (m_channel);
- double tti = 0.001;
- m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (tti), GetObject<SpectrumPhy> ());
- Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this);
- return false;
- }
- else
- {
- // The device have already started the transmission.
+ case TX:
+ NS_FATAL_ERROR ("cannot TX while already TX: the MAC should avoid this");
+ break;
+
+ case IDLE:
+ {
+ /*
+ m_txPsd must be setted by the device, according to
+ (i) the available subchannel for transmission
+ (ii) the power transmission
+ */
+ NS_ASSERT (m_txPsd);
+ m_txPacketBurst = pb;
+
+ // we need to convey some PHY meta information to the receiver
+ // to be used for simulation purposes (e.g., the CellId). This
+ // is done by adding an LtePhyTag to the first packet in the
+ // burst.
+ NS_ASSERT (pb->Begin () != pb->End ());
+ LtePhyTag tag (m_cellId);
+ Ptr<Packet> firstPacketInBurst = *(pb->Begin ());
+ firstPacketInBurst->AddPacketTag (tag);
+
+ ChangeState (TX);
+ NS_ASSERT (m_channel);
+ double tti = 0.001;
+ m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (tti), GetObject<SpectrumPhy> ());
+ Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this);
+ }
return true;
+ break;
+
+ default:
+ NS_FATAL_ERROR ("uknown state");
+ return true;
+ break;
}
}
@@ -319,7 +330,8 @@
m_interference.AddSignal (rxPsd, duration);
- // the device might start RX only if the signal is of a type understood by this device
+ // the device might start RX only if the signal is of a type
+ // understood by this device - in this case, an LTE signal.
if (st == GetSpectrumType ())
{
switch (m_state)
@@ -337,38 +349,42 @@
break;
case IDLE:
- // preamble detection and synchronization is supposed to be always successful.
- NS_LOG_LOGIC (this << " receiving new packet");
-
- m_interference.StartRx (rxPsd);
-
-
- for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
- != pb->End (); ++iter)
- {
- Ptr<Packet> packet = (*iter)->Copy ();
- m_phyRxStartTrace (packet);
- }
-
- m_rxPacketBurst = pb;
- m_rxPsd = rxPsd;
-
- ChangeState (RX);
-
-
- NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration);
- m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this);
+ // To check if we're synchronized to this signal, we check
+ // for the CellId which is reported in the LtePhyTag
+ NS_ASSERT (pb->Begin () != pb->End ());
+ LtePhyTag tag;
+ Ptr<Packet> firstPacketInBurst = *(pb->Begin ());
+ firstPacketInBurst->RemovePacketTag (tag);
+ if (tag.GetCellId () == m_cellId)
+ {
+ // we're synchronized with this signal
+ ChangeState (RX);
+
+ m_interference.StartRx (rxPsd);
+
+ for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
+ != pb->End (); ++iter)
+ {
+ Ptr<Packet> packet = (*iter)->Copy ();
+ m_phyRxStartTrace (packet);
+ }
+
+ m_rxPacketBurst = pb;
+ m_rxPsd = rxPsd;
+
+ NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration);
+ m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this);
- break;
+ break;
+ }
}
+
+ NS_LOG_LOGIC (this << "state: " << m_state);
}
-
- NS_LOG_LOGIC (this << "state: " << m_state);
}
-
void
LteSpectrumPhy::AbortRx ()
{
--- a/src/lte/wscript Mon Mar 14 13:23:01 2011 +0100
+++ b/src/lte/wscript Tue Mar 15 11:22:36 2011 +0100
@@ -34,6 +34,7 @@
'model/lte-enb-mac.cc',
'model/lte-ue-mac.cc',
'model/lte-mac-tag.cc',
+ 'model/lte-phy-tag.cc',
'model/lte-enb-phy-sap.cc',
'model/lte-ue-phy-sap.cc',
'model/lte-interference.cc',
@@ -76,6 +77,7 @@
'model/lte-enb-mac.h',
'model/lte-ue-mac.h',
'model/lte-mac-tag.h',
+ 'model/lte-phy-tag.h',
'model/lte-enb-phy-sap.h',
'model/lte-ue-phy-sap.h',
'model/lte-interference.h',