|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/ipv4-flow-probe.h"
22 #include "ns3/ipv4-flow-classifier.h"
24 #include "ns3/packet.h"
25 #include "ns3/flow-monitor.h"
27 #include "ns3/pointer.h"
28 #include "ns3/config.h"
29 #include "ns3/flow-id-tag.h"
60 virtual void Print (std::ostream &os)
const;
125 .SetGroupName (
"FlowMonitor")
138 return 4 + 4 + 4 + 8;
179 :
Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (
packetSize), m_src (src), m_dst (dst)
227 m_classifier (classifier)
233 if (!
m_ipv4->TraceConnectWithoutContext (
"SendOutgoing",
238 if (!
m_ipv4->TraceConnectWithoutContext (
"UnicastForward",
243 if (!
m_ipv4->TraceConnectWithoutContext (
"LocalDeliver",
249 if (!
m_ipv4->TraceConnectWithoutContext (
"Drop",
255 std::ostringstream qd;
256 qd <<
"/NodeList/" << node->
GetId () <<
"/$ns3::TrafficControlLayer/RootQueueDiscList/*/Drop";
260 std::ostringstream oss;
261 oss <<
"/NodeList/" << node->
GetId () <<
"/DeviceList/*/TxQueue/Drop";
275 .SetGroupName (
"FlowMonitor")
309 if (
m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
312 NS_LOG_DEBUG (
"ReportFirstTx ("<<
this<<
", "<<flowId<<
", "<<packetId<<
", "<<size<<
"); "
313 << ipHeader << *ipPayload);
346 NS_LOG_DEBUG (
"ReportForwarding ("<<
this<<
", "<<flowId<<
", "<<packetId<<
", "<<size<<
");");
347 m_flowMonitor->ReportForwarding (
this, flowId, packetId, size);
369 NS_LOG_DEBUG (
"ReportLastRx ("<<
this<<
", "<<flowId<<
", "<<packetId<<
", "<<size<<
"); "
370 << ipHeader << *ipPayload);
406 NS_LOG_DEBUG (
"Drop ("<<
this<<
", "<<flowId<<
", "<<packetId<<
", "<<size<<
", " << reason
408 <<
"HDR: " << ipHeader <<
" PKT: " << *ipPayload);
445 m_flowMonitor->ReportDrop (
this, flowId, packetId, size, myReason);
474 bool tagFound = item->GetPacket ()->FindFirstMatchingByteTag (fTag);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
DropReason
enumeration of possible reasons why a packet may be dropped
void SetFlowId(uint32_t flowId)
Set the flow identifier.
@ DROP_NO_ROUTE
No route to host.
void DropLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t ifIndex)
Log a packet being dropped.
Ptr< Ipv4FlowClassifier > m_classifier
the Ipv4FlowClassifier this probe is associated with
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t GetId(void) const
void SendOutgoingLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being sent.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
@ DROP_TTL_EXPIRE
Packet dropped due to TTL decremented to zero during IPv4 forwarding.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
@ DROP_TTL_EXPIRED
Packet TTL has expired.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual void Print(std::ostream &os) const
Ipv4 addresses are stored in host order in this class.
Ipv4Address m_src
IP source.
uint32_t GetFlowId(void) const
Set the flow identifier.
TAG_BUFFER_INLINE uint32_t ReadU32(void)
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
@ DROP_ROUTE_ERROR
Route error.
DropReason
Reason why a packet has been dropped.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint32_t GetPacketId(void) const
Set the packet identifier.
uint32_t GetPacketSize(void) const
Get the packet size.
uint32_t FlowPacketId
Abstract identifier of a packet within a flow.
virtual uint32_t GetSerializedSize(void) const
uint32_t FlowId
Abstract identifier of a packet flow.
static Ipv4Address Deserialize(const uint8_t buf[4])
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint32_t m_flowId
flow identifier
void Write(const uint8_t *buffer, uint32_t size)
uint32_t m_packetId
packet identifier
tag a set of bytes in a packet
virtual void Serialize(TagBuffer buf) const
void QueueDiscDropLogger(Ptr< const QueueDiscItem > item)
Log a packet being dropped by a queue disc.
@ DROP_BAD_CHECKSUM
Packet dropped due to invalid checksum in the IPv4 header.
@ DROP_INVALID_REASON
Fallback reason (no known reason)
@ DROP_NO_ROUTE
Packet dropped due to missing route to the destination.
virtual void DoDispose(void)
Destructor implementation.
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
This function will attempt to find all trace sources which match the input path and will then connect...
virtual void Deserialize(TagBuffer buf)
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
@ DROP_BAD_CHECKSUM
Bad checksum.
static TypeId GetTypeId(void)
Register this type.
Ipv4Address GetSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
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...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint32_t m_packetSize
packet size
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
@ DROP_ROUTE_ERROR
Route error.
Ptr< Ipv4L3Protocol > m_ipv4
the Ipv4L3Protocol this probe is bound to
virtual void DoDispose(void)
Destructor implementation.
@ DROP_QUEUE_DISC
Packet dropped by the queue disc.
static const uint32_t packetSize
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
void Read(uint8_t *buffer, uint32_t size)
@ DROP_QUEUE
Packet dropped due to queue overflow.
Tag used to allow a fast identification of the packet.
Ipv4Address m_dst
IP destination.
The FlowProbe class is responsible for listening for packet events in a specific point of the simulat...
void SetPacketSize(uint32_t packetSize)
Set the packet size.
Implement the IPv4 layer.
void Serialize(uint8_t buf[4]) const
Serialize this address to a 4-byte buffer.
void ForwardLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being forwarded.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
a class to represent an Ipv4 address mask
void ForwardUpLogger(const Ipv4Header &ipHeader, Ptr< const Packet > ipPayload, uint32_t interface)
Log a packet being received by the destination.
bool IsSrcDstValid(Ipv4Address src, Ipv4Address dst) const
Checks if the addresses stored in tag are matching the arguments.
static TypeId GetTypeId(void)
Get the type ID.
Ipv4FlowProbe(Ptr< FlowMonitor > monitor, Ptr< Ipv4FlowClassifier > classifier, Ptr< Node > node)
Constructor.
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
void QueueDropLogger(Ptr< const Packet > ipPayload)
Log a packet being dropped by a queue.
void SetPacketId(uint32_t packetId)
Set the packet identifier.