20#include "ns3/ipv4-flow-probe.h"
22#include "ns3/config.h"
23#include "ns3/flow-id-tag.h"
24#include "ns3/flow-monitor.h"
25#include "ns3/ipv4-flow-classifier.h"
28#include "ns3/packet.h"
29#include "ns3/pointer.h"
61 void Print(std::ostream& os)
const override;
131 .SetGroupName(
"FlowMonitor")
145 return 4 + 4 + 4 + 8;
196 m_packetId(packetId),
253 m_classifier(classifier)
259 if (!
m_ipv4->TraceConnectWithoutContext(
265 if (!
m_ipv4->TraceConnectWithoutContext(
271 if (!
m_ipv4->TraceConnectWithoutContext(
278 if (!
m_ipv4->TraceConnectWithoutContext(
285 std::ostringstream qd;
286 qd <<
"/NodeList/" << node->GetId() <<
"/$ns3::TrafficControlLayer/RootQueueDiscList/*/Drop";
292 std::ostringstream oss;
293 oss <<
"/NodeList/" << node->GetId() <<
"/DeviceList/*/TxQueue/Drop";
338 bool found = ipPayload->FindFirstMatchingByteTag(fTag);
344 if (
m_classifier->Classify(ipHeader, ipPayload, &flowId, &packetId))
347 NS_LOG_DEBUG(
"ReportFirstTx (" <<
this <<
", " << flowId <<
", " << packetId <<
", " << size
348 <<
"); " << ipHeader << *ipPayload);
358 ipPayload->AddByteTag(fTag);
368 bool found = ipPayload->FindFirstMatchingByteTag(fTag);
387 NS_LOG_DEBUG(
"ReportForwarding (" <<
this <<
", " << flowId <<
", " << packetId <<
", "
389 m_flowMonitor->ReportForwarding(
this, flowId, packetId, size);
399 bool found = ipPayload->FindFirstMatchingByteTag(fTag);
413 NS_LOG_DEBUG(
"ReportLastRx (" <<
this <<
", " << flowId <<
", " << packetId <<
", " << size
414 <<
"); " << ipHeader << *ipPayload);
445 bool found = ipPayload->FindFirstMatchingByteTag(fTag);
453 NS_LOG_DEBUG(
"Drop (" <<
this <<
", " << flowId <<
", " << packetId <<
", " << size <<
", "
455 <<
"HDR: " << ipHeader <<
" PKT: " << *ipPayload);
491 m_flowMonitor->ReportDrop(
this, flowId, packetId, size, myReason);
499 bool tagFound = ipPayload->FindFirstMatchingByteTag(fTag);
510 NS_LOG_DEBUG(
"Drop (" <<
this <<
", " << flowId <<
", " << packetId <<
", " << size <<
", "
520 bool tagFound = item->GetPacket()->FindFirstMatchingByteTag(fTag);
531 NS_LOG_DEBUG(
"Drop (" <<
this <<
", " << flowId <<
", " << packetId <<
", " << size <<
", "
The FlowProbe class is responsible for listening for packet events in a specific point of the simulat...
void DoDispose() override
Destructor implementation.
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
Ipv4 addresses are stored in host order in this class.
Ipv4Address GetSubnetDirectedBroadcast(const Ipv4Mask &mask) const
Generate subnet-directed broadcast address corresponding to mask.
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
static Ipv4Address Deserialize(const uint8_t buf[4])
DropReason
enumeration of possible reasons why a packet may be dropped
@ DROP_ROUTE_ERROR
Route error.
@ DROP_BAD_CHECKSUM
Packet dropped due to invalid checksum in the IPv4 header.
@ DROP_TTL_EXPIRE
Packet dropped due to TTL decremented to zero during IPv4 forwarding.
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
@ DROP_NO_ROUTE
Packet dropped due to missing route to the destination.
@ DROP_INVALID_REASON
Fallback reason (no known reason)
@ DROP_QUEUE_DISC
Packet dropped by the queue disc.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
@ DROP_QUEUE
Packet dropped due to queue overflow.
void SendOutgoingLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being sent.
void DropLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t ifIndex)
Log a packet being dropped.
void QueueDropLogger(Ptr< const Packet > ipPayload)
Log a packet being dropped by a queue.
void ForwardUpLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being received by the destination.
Ptr< Ipv4L3Protocol > m_ipv4
the Ipv4L3Protocol this probe is bound to
static TypeId GetTypeId()
Register this type.
void DoDispose() override
Destructor implementation.
Ipv4FlowProbe(Ptr< FlowMonitor > monitor, Ptr< Ipv4FlowClassifier > classifier, Ptr< Node > node)
Constructor.
void QueueDiscDropLogger(Ptr< const QueueDiscItem > item)
Log a packet being dropped by a queue disc.
void ForwardLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being forwarded.
Ptr< Ipv4FlowClassifier > m_classifier
the Ipv4FlowClassifier this probe is associated with
~Ipv4FlowProbe() override
Tag used to allow a fast identification of the packet.
uint32_t GetPacketId() const
Set the packet identifier.
void Deserialize(TagBuffer buf) override
uint32_t m_packetSize
packet size
void Print(std::ostream &os) const override
uint32_t GetPacketSize() const
Get the packet size.
bool IsSrcDstValid(Ipv4Address src, Ipv4Address dst) const
Checks if the addresses stored in tag are matching the arguments.
Ipv4Address m_dst
IP destination.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void SetPacketSize(uint32_t packetSize)
Set the packet size.
uint32_t m_packetId
packet identifier
uint32_t GetSerializedSize() const override
void Serialize(TagBuffer buf) const override
void SetFlowId(uint32_t flowId)
Set the flow identifier.
uint32_t m_flowId
flow identifier
uint32_t GetFlowId() const
Set the flow identifier.
void SetPacketId(uint32_t packetId)
Set the packet identifier.
Ipv4Address m_src
IP source.
Implement the IPv4 layer.
DropReason
Reason why a packet has been dropped.
@ DROP_BAD_CHECKSUM
Bad checksum.
@ DROP_NO_ROUTE
No route to host.
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
@ DROP_TTL_EXPIRED
Packet TTL has expired.
@ DROP_ROUTE_ERROR
Route error.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
a class to represent an Ipv4 address mask
Smart pointer class similar to boost::intrusive_ptr.
TAG_BUFFER_INLINE uint32_t ReadU32()
void Read(uint8_t *buffer, uint32_t size)
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
void Write(const uint8_t *buffer, uint32_t size)
tag a set of bytes in a packet
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
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...
static const uint32_t packetSize
Packet size generated at the AP.