diff -r 01d2fe958492 src/contrib/flow-monitor/ipv4-flow-probe.cc --- a/src/contrib/flow-monitor/ipv4-flow-probe.cc Mon Apr 26 15:11:39 2010 +0800 +++ b/src/contrib/flow-monitor/ipv4-flow-probe.cc Mon Apr 26 15:14:40 2010 +0800 @@ -27,7 +27,6 @@ #include "ns3/pointer.h" #include "ns3/config.h" #include "ns3/flow-id-tag.h" -#include namespace ns3 { @@ -36,10 +35,10 @@ NS_LOG_COMPONENT_DEFINE ("Ipv4FlowProbe"); ////////////////////////////////////// - // FlowProbeTag class implementation // + // Ipv4FlowProbeTag class implementation // ////////////////////////////////////// -class FlowProbeTag : public Tag +class Ipv4FlowProbeTag : public Tag { public: static TypeId GetTypeId (void); @@ -48,8 +47,8 @@ virtual void Serialize (TagBuffer buf) const; virtual void Deserialize (TagBuffer buf); virtual void Print (std::ostream &os) const; - FlowProbeTag (); - FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize); + Ipv4FlowProbeTag (); + Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize); void SetFlowId (uint32_t flowId); void SetPacketId (uint32_t packetId); void SetPacketSize (uint32_t packetSize); @@ -64,80 +63,80 @@ }; TypeId -FlowProbeTag::GetTypeId (void) +Ipv4FlowProbeTag::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::FlowProbeTag") + static TypeId tid = TypeId ("ns3::Ipv4FlowProbeTag") .SetParent () - .AddConstructor () + .AddConstructor () ; return tid; } TypeId -FlowProbeTag::GetInstanceTypeId (void) const +Ipv4FlowProbeTag::GetInstanceTypeId (void) const { return GetTypeId (); } uint32_t -FlowProbeTag::GetSerializedSize (void) const +Ipv4FlowProbeTag::GetSerializedSize (void) const { return 4 + 4 + 4; } void -FlowProbeTag::Serialize (TagBuffer buf) const +Ipv4FlowProbeTag::Serialize (TagBuffer buf) const { buf.WriteU32 (m_flowId); buf.WriteU32 (m_packetId); buf.WriteU32 (m_packetSize); } void -FlowProbeTag::Deserialize (TagBuffer buf) +Ipv4FlowProbeTag::Deserialize (TagBuffer buf) { m_flowId = buf.ReadU32 (); m_packetId = buf.ReadU32 (); m_packetSize = buf.ReadU32 (); } void -FlowProbeTag::Print (std::ostream &os) const +Ipv4FlowProbeTag::Print (std::ostream &os) const { os << "FlowId=" << m_flowId; os << "PacketId=" << m_packetId; os << "PacketSize=" << m_packetSize; } -FlowProbeTag::FlowProbeTag () +Ipv4FlowProbeTag::Ipv4FlowProbeTag () : Tag () {} -FlowProbeTag::FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize) +Ipv4FlowProbeTag::Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize) : Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (packetSize) {} void -FlowProbeTag::SetFlowId (uint32_t id) +Ipv4FlowProbeTag::SetFlowId (uint32_t id) { m_flowId = id; } void -FlowProbeTag::SetPacketId (uint32_t id) +Ipv4FlowProbeTag::SetPacketId (uint32_t id) { m_packetId = id; } void -FlowProbeTag::SetPacketSize (uint32_t size) +Ipv4FlowProbeTag::SetPacketSize (uint32_t size) { m_packetSize = size; } uint32_t -FlowProbeTag::GetFlowId (void) const +Ipv4FlowProbeTag::GetFlowId (void) const { return m_flowId; } uint32_t -FlowProbeTag::GetPacketId (void) const +Ipv4FlowProbeTag::GetPacketId (void) const { return m_packetId; } uint32_t -FlowProbeTag::GetPacketSize (void) const +Ipv4FlowProbeTag::GetPacketSize (void) const { return m_packetSize; } @@ -199,7 +240,8 @@ // tag the packet with the flow id and packet id, so that the packet can be identified even // when Ipv4Header is not accessible at some non-IPv4 protocol layer - FlowProbeTag fTag (flowId, packetId, size); + Ipv4FlowProbeTag fTag (flowId, packetId, size); + NS_ASSERT_MSG (!ConstCast (ipPayload)->RemovePacketTag (fTag), "There alrady exists a FlowProbeTag with the packet " << *ipPayload << " Uid=" << ipPayload->GetUid ()); ipPayload->AddPacketTag (fTag); } } @@ -228,9 +270,9 @@ if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId)) { // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger () - FlowProbeTag fTag; + Ipv4FlowProbeTag fTag; bool tagFound = ConstCast (ipPayload)->RemovePacketTag (fTag); - NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing"); + NS_ASSERT_MSG (tagFound, "Ipv4FlowProbeTag is missing"); uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ()); NS_LOG_DEBUG ("ReportLastRx ("<Classify (ipHeader, ipPayload, &flowId, &packetId)) { // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger () - FlowProbeTag fTag; + Ipv4FlowProbeTag fTag; bool tagFound = ConstCast (ipPayload)->RemovePacketTag (fTag); - NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing"); + NS_ASSERT_MSG (tagFound, "Ipv4FlowProbeTag is missing"); uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ()); NS_LOG_DEBUG ("Drop ("< ipPayload) { // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger () - FlowProbeTag fTag; + Ipv4FlowProbeTag fTag; bool tagFound = ConstCast (ipPayload)->RemovePacketTag (fTag); + NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing"); if (tagFound) {