20 #include "ns3/core-module.h"
21 #include "ns3/dsr-module.h"
22 #include "ns3/internet-module.h"
30 #include "ns3/lr-wpan-mac.h"
31 #include "ns3/lte-module.h"
34 #include "ns3/mesh-module.h"
35 #include "ns3/mobility-module.h"
36 #include "ns3/network-module.h"
37 #include "ns3/olsr-module.h"
38 #include "ns3/sixlowpan-module.h"
39 #include "ns3/spectrum-module.h"
40 #include "ns3/stats-module.h"
41 #include "ns3/uan-module.h"
42 #include "ns3/wifi-mac-header.h"
43 #include "ns3/wifi-phy-state-helper.h"
84 template <
typename... Ts>
87 void DoRun()
override;
106 std::set<std::string>
109 std::set<std::string> dupes;
111 dupes.insert(
"LteRlc::NotifyTxTracedCallback");
112 dupes.insert(
"LteRlc::ReceiveTracedCallback");
113 dupes.insert(
"LteUeRrc::ImsiCidRntiTracedCallback");
114 dupes.insert(
"LteUeRrc::MibSibHandoverTracedCallback");
115 dupes.insert(
"WifiPhyStateHelper::RxEndErrorTracedCallback");
136 template <
typename T>
148 #define TYPENAME(T) \
150 inline std::string TypeName<T>(int N) \
152 std::stringstream ss; \
153 ss << #T << "(" << N << ")"; \
237 std::cout <<
"with " << N <<
" args." << std::endl;
246 template <
typename... Ts>
256 const std::size_t n =
sizeof...(Ts);
274 template <
typename... Ts>
285 std::tuple<typename TypeTraits<Ts>::BaseType...>
m_items;
288 const std::size_t m_nItems =
sizeof...(Ts);
293 template <
typename U>
296 U
sink = TracedCbSink<Ts...>::Sink;
299 std::cout << TypeName<U>(m_nItems) <<
" invoked ";
300 m_cb.ConnectWithoutContext(cb);
301 std::apply(m_cb, m_items);
312 std::cout << std::endl;
315 "failed, m_nArgs: " << m_nArgs <<
" N: " << m_nItems);
321 :
TestCase(
"Check basic TracedCallback operation")
331 #define DUPE(U, T1) \
332 if (g_dupes.find(#U) == g_dupes.end()) \
334 NS_TEST_ASSERT_MSG_NE(0, 1, "expected to find " << #U << " in dupes."); \
336 if (TypeName<U>(0) == TypeName<T1>(0)) \
338 std::cout << #U << " matches " << #T1 << std::endl; \
342 NS_TEST_ASSERT_MSG_EQ(TypeName<U>(0), \
345 << #U << " used to match the typedef " << #T1 \
346 << " but no longer does. Please add a new CHECK call."); \
354 #define CHECK(U, ...) CreateObject<Checker<__VA_ARGS__>>()->Invoke<U>()
363 CHECK(Ipv4L3Protocol::DropTracedCallback,
374 CHECK(Ipv6L3Protocol::DropTracedCallback,
391 CHECK(LteEnbMac::DlSchedulingTracedCallback,
401 CHECK(LteEnbMac::UlSchedulingTracedCallback, uint32_t, uint32_t, uint16_t, uint8_t, uint16_t);
403 CHECK(LteEnbPhy::ReportUeSinrTracedCallback, uint16_t, uint16_t,
double, uint8_t);
407 CHECK(LteEnbRrc::ConnectionHandoverTracedCallback, uint64_t, uint16_t, uint16_t);
409 CHECK(LteEnbRrc::HandoverStartTracedCallback, uint64_t, uint16_t, uint16_t, uint16_t);
411 CHECK(LteEnbRrc::NewUeContextTracedCallback, uint16_t, uint16_t);
413 CHECK(LteEnbRrc::ReceiveReportTracedCallback,
419 CHECK(LtePdcp::PduRxTracedCallback, uint16_t, uint8_t, uint32_t, uint64_t);
421 CHECK(LtePdcp::PduTxTracedCallback, uint16_t, uint8_t, uint32_t);
423 DUPE(LteRlc::NotifyTxTracedCallback, LtePdcp::PduTxTracedCallback);
425 DUPE(LteRlc::ReceiveTracedCallback, LtePdcp::PduRxTracedCallback);
427 CHECK(LteUePhy::RsrpSinrTracedCallback, uint16_t, uint16_t,
double,
double, uint8_t);
431 CHECK(LteUeRrc::CellSelectionTracedCallback, uint64_t, uint16_t);
433 DUPE(LteUeRrc::ImsiCidRntiTracedCallback, LteEnbRrc::ConnectionHandoverTracedCallback);
435 DUPE(LteUeRrc::MibSibHandoverTracedCallback, LteEnbRrc::HandoverStartTracedCallback);
437 CHECK(LteUeRrc::StateTracedCallback,
448 CHECK(olsr::RoutingProtocol::PacketTxRxTracedCallback,
449 const olsr::PacketHeader&,
452 CHECK(olsr::RoutingProtocol::TableChangeTracedCallback, uint32_t);
460 CHECK(Packet::SizeTracedCallback, uint32_t, uint32_t);
472 CHECK(SixLowPanNetDevice::DropTracedCallback,
478 CHECK(SixLowPanNetDevice::RxTxTracedCallback,
483 CHECK(SpectrumChannel::LossTracedCallback,
490 CHECK(TimeSeriesAdaptor::OutputTracedCallback,
double,
double);
502 CHECK(UeManager::StateTracedCallback,
513 CHECK(WifiPhyStateHelper::RxOkTracedCallback,
523 CHECK(WifiRemoteStationManager::PowerChangeTracedCallback,
double,
double,
Mac48Address);
540 :
TestSuite(
"traced-callback-typedef", SYSTEM)
TracedCallback< Ts... > m_cb
TracedCallback to be called.
std::tuple< typename TypeTraits< Ts >::BaseType... > m_items
Arguments of the TracedCallback.
void Invoke()
Invoke a TracedCallback.
void Cleanup()
Cleanup the test.
TracedCallbackTypedefTestCase()
void DoRun() override
Implementation to actually run this TestCase.
static std::size_t m_nArgs
Number of arguments passed to callback.
~TracedCallbackTypedefTestCase() override
TracedCallback typedef TestSuite.
TracedCallbackTypedefTestSuite()
static void Sink(Ts...)
Sink function, called by a TracedCallback.
a polymophic address class
Class for representing data rates.
State
Definition of NAS states as per "LTE - From theory to practice", Section 3.2.3.2 "Connection Establis...
void(* StateTracedCallback)(const State oldState, const State newState)
TracedCallback signature for state change events.
DropReason
Reason why a packet has been dropped.
void(* DropTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet drop events.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet transmission or reception events.
void(* SentTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet send, forward, or local deliver events.
void(* SentTracedCallback)(const Ipv6Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet sent, forwarded or local-delivered events.
DropReason
Reason why a packet has been dropped.
void(* DropTracedCallback)(const Ipv6Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
TracedCallback signature for packet drop events.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
TracedCallback signature for packet transmission or reception events.
void(* StateTracedCallback)(LrWpanMacState oldState, LrWpanMacState newState)
TracedCallback signature for LrWpanMacState change events.
void(* SentTracedCallback)(Ptr< const Packet > packet, uint8_t retries, uint8_t backoffs)
TracedCallback signature for sent packets.
void(* StateTracedCallback)(Time time, LrWpanPhyEnumeration oldState, LrWpanPhyEnumeration newState)
TracedCallback signature for Trx state change events.
void(* DlSchedulingTracedCallback)(const uint32_t frame, const uint32_t subframe, const uint16_t rnti, const uint8_t mcs0, const uint16_t tbs0Size, const uint8_t mcs1, const uint16_t tbs1Size, const uint8_t ccId)
TracedCallback signature for DL scheduling events.
void(* UlSchedulingTracedCallback)(const uint32_t frame, const uint32_t subframe, const uint16_t rnti, const uint8_t mcs, const uint16_t tbsSize)
TracedCallback signature for UL scheduling events.
void(* ReportUeSinrTracedCallback)(uint16_t cellId, uint16_t rnti, double sinrLinear, uint8_t componentCarrierId)
TracedCallback signature for the linear average of SRS SINRs.
void(* ReportInterferenceTracedCallback)(uint16_t cellId, Ptr< SpectrumValue > spectrumValue)
TracedCallback signature for the linear average of SRS SINRs.
void(* ReceiveReportTracedCallback)(const uint64_t imsi, const uint16_t cellId, const uint16_t rnti, const LteRrcSap::MeasurementReport report)
TracedCallback signature for receive measurement report events.
void(* HandoverStartTracedCallback)(const uint64_t imsi, const uint16_t cellId, const uint16_t rnti, const uint16_t targetCid)
TracedCallback signature for handover start events.
void(* ConnectionHandoverTracedCallback)(const uint64_t imsi, const uint16_t cellId, const uint16_t rnti)
TracedCallback signature for connection and handover end events.
void(* NewUeContextTracedCallback)(const uint16_t cellId, const uint16_t rnti)
TracedCallback signature for new Ue Context events.
void(* PduRxTracedCallback)(const uint16_t rnti, const uint8_t lcid, const uint32_t size, const uint64_t delay)
TracedCallback signature for PDU receive event.
void(* PduTxTracedCallback)(uint16_t rnti, uint8_t lcid, uint32_t size)
TracedCallback for PDU transmission event.
void(* StateTracedCallback)(uint16_t cellId, uint16_t rnti, State oldState, State newState)
TracedCallback signature for state transition events.
State
The states of the UE PHY entity.
void(* RsrpSinrTracedCallback)(uint16_t cellId, uint16_t rnti, double rsrp, double sinr, uint8_t componentCarrierId)
TracedCallback signature for cell RSRP and SINR report.
State
The states of the UE RRC entity.
void(* CellSelectionTracedCallback)(uint64_t imsi, uint16_t cellId)
TracedCallback signature for imsi, cellId and rnti events.
void(* StateTracedCallback)(uint64_t imsi, uint16_t cellId, uint16_t rnti, State oldState, State newState)
TracedCallback signature for state transition events.
void(* TracedCallback)(Mac48Address value)
TracedCallback signature for Mac48Address.
A class used for addressing MAC8 MAC's.
void(* TracedCallback)(Ptr< const MobilityModel > model)
TracedCallback signature.
A base class which provides memory management and object aggregation.
void(* TracedCallback)(Ptr< const PacketBurst > burst)
TracedCallback signature for Ptr<PacketBurst>
void(* SizeTracedCallback)(uint32_t oldSize, uint32_t newSize)
TracedCallback signature for changes in packet size.
void(* Mac48AddressTracedCallback)(Ptr< const Packet > packet, Mac48Address mac)
TracedCallback signature for packet and Mac48Address.
void(* AddressTracedCallback)(Ptr< const Packet > packet, const Address &address)
TracedCallback signature for packet and Address.
void(* SinrTracedCallback)(Ptr< const Packet > packet, double sinr)
TracedCallback signature for packet and SINR.
void(* TracedCallback)(Ptr< const Packet > packet)
TracedCallback signature for Ptr<Packet>
void(* DropTracedCallback)(DropReason reason, Ptr< const Packet > packet, Ptr< SixLowPanNetDevice > sixNetDevice, uint32_t ifindex)
TracedCallback signature for packet drop events.
DropReason
Enumeration of the dropping reasons in SixLoWPAN.
void(* RxTxTracedCallback)(Ptr< const Packet > packet, Ptr< SixLowPanNetDevice > sixNetDevice, uint32_t ifindex)
TracedCallback signature for packet send/receive events.
void(* LossTracedCallback)(Ptr< const SpectrumPhy > txPhy, Ptr< const SpectrumPhy > rxPhy, double lossDb)
TracedCallback signature for path loss calculation events.
void(* TracedCallback)(Ptr< SpectrumValue > value)
TracedCallback signature for SpectrumValue.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
void(* OutputTracedCallback)(const double now, const double data)
TracedCallback signature for output trace.
Forward calls to a chain of Callback.
void(* QueueTracedCallback)(Ptr< const Packet > packet, uint16_t proto)
TracedCallback signature for enqueue/dequeue of a packet.
void(* PacketModeTracedCallback)(Ptr< const Packet > packet, UanTxMode mode)
TracedCallback signature for packet reception/enqueue/dequeue events.
void(* QueueTracedCallback)(Ptr< const Packet > packet, uint32_t proto)
TracedCallback signature for dequeue of a packet.
void(* RxTxTracedCallback)(Ptr< const Packet > packet, Mac8Address address)
TracedCallback signature for MAC send/receive events.
void(* TracedCallback)(Ptr< const Packet > pkt, double sinr, UanTxMode mode)
TracedCallback signature for UanPhy packet send/receive events.
Abstraction of packet modulation information.
State
The state of the UeManager at the eNB RRC.
void(* StateTracedCallback)(const uint64_t imsi, const uint16_t cellId, const uint16_t rnti, const State oldState, const State newState)
TracedCallback signature for state transition events.
represent a single transmission mode
void(* TxTracedCallback)(Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t power)
TracedCallback signature for transmit event.
void(* StateTracedCallback)(Time start, Time duration, WifiPhyState state)
TracedCallback signature for state changes.
void(* RxOkTracedCallback)(Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
TracedCallback signature for receive end OK event.
void(* PowerChangeTracedCallback)(double oldPower, double newPower, Mac48Address remoteAddress)
TracedCallback signature for power change events.
void(* RateChangeTracedCallback)(DataRate oldRate, DataRate newRate, Mac48Address remoteAddress)
TracedCallback signature for rate change events.
void(* LinkOpenCloseTracedCallback)(Mac48Address src, const Mac48Address dst)
TracedCallback signature for link open/close events.
void(* PacketTxRxTracedCallback)(const PacketHeader &header, const MessageList &messages)
TracedCallback signature for Packet transmit and receive events.
void(* TableChangeTracedCallback)(uint32_t size)
TracedCallback signature for routing table computation.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
LrWpanMacState
MAC states.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
#define CHECK(U,...)
Check the TracedCallback by calling its Invoke function.
#define DUPE(U, T1)
Check the TracedCallback duplicate by checking if it matches the TracedCallback it is supposed to be ...
void SinkIt(std::size_t N)
Log that a callback was invoked.
std::set< std::string > g_dupes
Container for duplicate types.
#define TYPENAME(T)
Returns a string representing the type of a class.
std::string TypeName(int N)
Stringify the known TracedCallback type names.
std::set< std::string > Duplicates()
Record typedefs which are identical to previously declared.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
std::vector< MessageHeader > MessageList
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
MeasurementReport structure.
PhyReceptionStatParameters structure.
void(* TracedCallback)(const PhyReceptionStatParameters params)
TracedCallback signature.
PhyTransmissionStatParameters structure.
void(* TracedCallback)(const PhyTransmissionStatParameters params)
TracedCallback signature.
static TracedCallbackTypedefTestSuite tracedCallbackTypedefTestSuite
Static variable for test initialization.
WifiPhyState
The state of the PHY layer.
Ptr< PacketSink > sink
Pointer to the packet sink application.