26 #include "ns3/core-module.h"
27 #include "ns3/dsr-module.h"
28 #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-phy-state-helper.h"
43 #include "ns3/wifi-mac-header.h"
85 template <
typename... Ts>
88 virtual void DoRun (
void);
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");
137 template <
typename T>
149 #define TYPENAME(T) \
152 TypeName < T > (int N) \
154 std::stringstream ss; \
155 ss << # T << "(" << N << ")"; \
239 std::cout <<
"with " << N <<
" args." << std::endl;
248 template <
typename... Ts>
258 const std::size_t n =
sizeof...(Ts);
278 template <
typename... Ts>
288 std::tuple<typename TypeTraits<Ts>::BaseType...>
m_items;
291 const std::size_t m_nItems =
sizeof...(Ts);
296 template <
typename U>
299 U
sink = TracedCbSink<Ts...>::Sink;
302 std::cout << TypeName<U> (m_nItems) <<
" invoked ";
303 m_cb.ConnectWithoutContext (cb);
304 std::apply(m_cb, m_items);
315 std::cout << std::endl;
317 NS_ASSERT_MSG (m_nArgs && m_nArgs == m_nItems,
"failed, m_nArgs: " << m_nArgs <<
" N: " << m_nItems);
325 :
TestCase (
"Check basic TracedCallback operation")
335 #define DUPE(U, T1) \
336 if (g_dupes.find ( # U ) == g_dupes.end ()) { \
337 NS_TEST_ASSERT_MSG_NE (0, 1, \
338 "expected to find " << # U << " in dupes."); } \
339 if (TypeName<U> (0) == TypeName<T1> (0)) { \
340 std::cout << # U << " matches " << # T1 << std::endl; } \
342 NS_TEST_ASSERT_MSG_EQ \
343 (TypeName<U> (0), TypeName<T1> (0), \
344 "the typedef " << # U << \
345 " used to match the typedef " << # T1 << \
346 " but no longer does. Please add a new CHECK call.")
354 #define CHECK(U, ...) \
355 CreateObject< Checker< __VA_ARGS__ > > ()->Invoke<U> ()
362 CHECK (dsr::DsrOptionSRHeader::TracedCallback,
365 CHECK (EpcUeNas::StateTracedCallback,
368 CHECK (Ipv4L3Protocol::DropTracedCallback,
372 CHECK (Ipv4L3Protocol::SentTracedCallback,
375 CHECK (Ipv4L3Protocol::TxRxTracedCallback,
378 CHECK (Ipv6L3Protocol::DropTracedCallback,
382 CHECK (Ipv6L3Protocol::SentTracedCallback,
385 CHECK (Ipv6L3Protocol::TxRxTracedCallback,
388 CHECK (LrWpanMac::SentTracedCallback,
391 CHECK (LrWpanMac::StateTracedCallback,
394 CHECK (LrWpanPhy::StateTracedCallback,
397 CHECK (LteEnbMac::DlSchedulingTracedCallback,
398 uint32_t, uint32_t, uint16_t,
399 uint8_t, uint16_t, uint8_t, uint16_t, uint8_t);
401 CHECK (LteEnbMac::UlSchedulingTracedCallback,
402 uint32_t, uint32_t, uint16_t, uint8_t, uint16_t);
404 CHECK (LteEnbPhy::ReportUeSinrTracedCallback,
405 uint16_t, uint16_t,
double, uint8_t);
407 CHECK (LteEnbPhy::ReportInterferenceTracedCallback,
410 CHECK (LteEnbRrc::ConnectionHandoverTracedCallback,
411 uint64_t, uint16_t, uint16_t);
413 CHECK (LteEnbRrc::HandoverStartTracedCallback,
414 uint64_t, uint16_t, uint16_t, uint16_t);
416 CHECK (LteEnbRrc::NewUeContextTracedCallback,
419 CHECK (LteEnbRrc::ReceiveReportTracedCallback,
422 CHECK (LtePdcp::PduRxTracedCallback,
423 uint16_t, uint8_t, uint32_t, uint64_t);
425 CHECK (LtePdcp::PduTxTracedCallback,
426 uint16_t, uint8_t, uint32_t);
428 DUPE (LteRlc::NotifyTxTracedCallback, LtePdcp::PduTxTracedCallback);
430 DUPE (LteRlc::ReceiveTracedCallback, LtePdcp::PduRxTracedCallback);
432 CHECK (LteUePhy::RsrpSinrTracedCallback,
433 uint16_t, uint16_t,
double,
double, uint8_t);
435 CHECK (LteUePhy::StateTracedCallback,
438 CHECK (LteUeRrc::CellSelectionTracedCallback,
441 DUPE (LteUeRrc::ImsiCidRntiTracedCallback, LteEnbRrc::ConnectionHandoverTracedCallback);
443 DUPE (LteUeRrc::MibSibHandoverTracedCallback, LteEnbRrc::HandoverStartTracedCallback);
445 CHECK (LteUeRrc::StateTracedCallback,
448 CHECK (Mac48Address::TracedCallback,
451 CHECK (MobilityModel::TracedCallback,
454 CHECK (olsr::RoutingProtocol::PacketTxRxTracedCallback,
457 CHECK (olsr::RoutingProtocol::TableChangeTracedCallback,
460 CHECK (Packet::AddressTracedCallback,
463 CHECK (Packet::Mac48AddressTracedCallback,
466 CHECK (Packet::SinrTracedCallback,
469 CHECK (Packet::SizeTracedCallback,
472 CHECK (Packet::TracedCallback,
475 CHECK (PacketBurst::TracedCallback,
478 CHECK (dot11s::PeerManagementProtocol::LinkOpenCloseTracedCallback,
481 CHECK (PhyReceptionStatParameters::TracedCallback,
484 CHECK (PhyTransmissionStatParameters::TracedCallback,
487 CHECK (SixLowPanNetDevice::DropTracedCallback,
491 CHECK (SixLowPanNetDevice::RxTxTracedCallback,
494 CHECK (SpectrumChannel::LossTracedCallback,
497 CHECK (SpectrumValue::TracedCallback,
500 CHECK (TimeSeriesAdaptor::OutputTracedCallback,
503 CHECK (UanMac::PacketModeTracedCallback,
506 CHECK (UanMacCw::QueueTracedCallback,
509 CHECK (UanMacRc::QueueTracedCallback,
512 CHECK (UanNetDevice::RxTxTracedCallback,
515 CHECK (UanPhy::TracedCallback,
518 CHECK (UeManager::StateTracedCallback,
521 CHECK (WifiMacHeader::TracedCallback,
524 CHECK (WifiPhyStateHelper::RxEndErrorTracedCallback,
527 CHECK (WifiPhyStateHelper::RxOkTracedCallback,
530 CHECK (WifiPhyStateHelper::StateTracedCallback,
533 CHECK (WifiPhyStateHelper::TxTracedCallback,
536 CHECK (WifiRemoteStationManager::PowerChangeTracedCallback,
539 CHECK (WifiRemoteStationManager::RateChangeTracedCallback,
555 :
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 Cleanup()
Cleanup the test.
void Invoke(void)
Invoke a TracedCallback.
TracedCallbackTypedefTestCase()
virtual ~TracedCallbackTypedefTestCase()
static std::size_t m_nArgs
Number of arguments passed to callback.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 fo 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.
std::set< std::string > Duplicates(void)
Record typedefs which are identical to previously declared.
#define CHECK(U,...)
Check the TracedCallback by calling its Invoke function.
#define DUPE(U, T1)
Check the TracedCallback duplicate by checking if it maches the TracedCallback it is supposed to be e...
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 sting representing the type of a class.
std::string TypeName(int N)
Stringify the known TracedCallback type names.
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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), 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.