View | Details | Raw Unified | Return to bug 854
Collapse All | Expand All

(-)a/src/contrib/flow-monitor/ipv4-flow-probe.cc (-27 / +28 lines)
 Lines 27-33    Link Here 
27
#include "ns3/pointer.h"
27
#include "ns3/pointer.h"
28
#include "ns3/config.h"
28
#include "ns3/config.h"
29
#include "ns3/flow-id-tag.h"
29
#include "ns3/flow-id-tag.h"
30
#include <sstream>
31
30
32
namespace ns3 {
31
namespace ns3 {
33
32
 Lines 36-45    Link Here 
36
NS_LOG_COMPONENT_DEFINE ("Ipv4FlowProbe");
35
NS_LOG_COMPONENT_DEFINE ("Ipv4FlowProbe");
37
36
38
            //////////////////////////////////////
37
            //////////////////////////////////////
39
            // FlowProbeTag class implementation //
38
            // Ipv4FlowProbeTag class implementation //
40
            //////////////////////////////////////
39
            //////////////////////////////////////
41
40
42
class FlowProbeTag : public Tag
41
class Ipv4FlowProbeTag : public Tag
43
{
42
{
44
public:
43
public:
45
  static TypeId GetTypeId (void);
44
  static TypeId GetTypeId (void);
 Lines 48-55    Link Here 
48
  virtual void Serialize (TagBuffer buf) const;
47
  virtual void Serialize (TagBuffer buf) const;
49
  virtual void Deserialize (TagBuffer buf);
48
  virtual void Deserialize (TagBuffer buf);
50
  virtual void Print (std::ostream &os) const;
49
  virtual void Print (std::ostream &os) const;
51
  FlowProbeTag ();
50
  Ipv4FlowProbeTag ();
52
  FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize);
51
  Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize);
53
  void SetFlowId (uint32_t flowId);
52
  void SetFlowId (uint32_t flowId);
54
  void SetPacketId (uint32_t packetId);
53
  void SetPacketId (uint32_t packetId);
55
  void SetPacketSize (uint32_t packetSize);
54
  void SetPacketSize (uint32_t packetSize);
 Lines 64-143    Link Here 
64
};
63
};
65
64
66
TypeId 
65
TypeId 
67
FlowProbeTag::GetTypeId (void)
66
Ipv4FlowProbeTag::GetTypeId (void)
68
{
67
{
69
  static TypeId tid = TypeId ("ns3::FlowProbeTag")
68
  static TypeId tid = TypeId ("ns3::Ipv4FlowProbeTag")
70
    .SetParent<Tag> ()
69
    .SetParent<Tag> ()
71
    .AddConstructor<FlowProbeTag> ()
70
    .AddConstructor<Ipv4FlowProbeTag> ()
72
    ;
71
    ;
73
  return tid;
72
  return tid;
74
}
73
}
75
TypeId 
74
TypeId 
76
FlowProbeTag::GetInstanceTypeId (void) const
75
Ipv4FlowProbeTag::GetInstanceTypeId (void) const
77
{
76
{
78
  return GetTypeId ();
77
  return GetTypeId ();
79
}
78
}
80
uint32_t 
79
uint32_t 
81
FlowProbeTag::GetSerializedSize (void) const
80
Ipv4FlowProbeTag::GetSerializedSize (void) const
82
{
81
{
83
  return 4 + 4 + 4;
82
  return 4 + 4 + 4;
84
}
83
}
85
void 
84
void 
86
FlowProbeTag::Serialize (TagBuffer buf) const
85
Ipv4FlowProbeTag::Serialize (TagBuffer buf) const
87
{
86
{
88
  buf.WriteU32 (m_flowId);
87
  buf.WriteU32 (m_flowId);
89
  buf.WriteU32 (m_packetId);
88
  buf.WriteU32 (m_packetId);
90
  buf.WriteU32 (m_packetSize);
89
  buf.WriteU32 (m_packetSize);
91
}
90
}
92
void 
91
void 
93
FlowProbeTag::Deserialize (TagBuffer buf)
92
Ipv4FlowProbeTag::Deserialize (TagBuffer buf)
94
{
93
{
95
  m_flowId = buf.ReadU32 ();
94
  m_flowId = buf.ReadU32 ();
96
  m_packetId = buf.ReadU32 ();
95
  m_packetId = buf.ReadU32 ();
97
  m_packetSize = buf.ReadU32 ();
96
  m_packetSize = buf.ReadU32 ();
98
}
97
}
99
void 
98
void 
100
FlowProbeTag::Print (std::ostream &os) const
99
Ipv4FlowProbeTag::Print (std::ostream &os) const
101
{
100
{
102
  os << "FlowId=" << m_flowId;
101
  os << "FlowId=" << m_flowId;
103
  os << "PacketId=" << m_packetId;
102
  os << "PacketId=" << m_packetId;
104
  os << "PacketSize=" << m_packetSize;
103
  os << "PacketSize=" << m_packetSize;
105
}
104
}
106
FlowProbeTag::FlowProbeTag ()
105
Ipv4FlowProbeTag::Ipv4FlowProbeTag ()
107
  : Tag () 
106
  : Tag () 
108
{}
107
{}
109
108
110
FlowProbeTag::FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize)
109
Ipv4FlowProbeTag::Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize)
111
  : Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (packetSize)
110
  : Tag (), m_flowId (flowId), m_packetId (packetId), m_packetSize (packetSize)
112
{}
111
{}
113
112
114
void
113
void
115
FlowProbeTag::SetFlowId (uint32_t id)
114
Ipv4FlowProbeTag::SetFlowId (uint32_t id)
116
{
115
{
117
  m_flowId = id;
116
  m_flowId = id;
118
}
117
}
119
void
118
void
120
FlowProbeTag::SetPacketId (uint32_t id)
119
Ipv4FlowProbeTag::SetPacketId (uint32_t id)
121
{
120
{
122
  m_packetId = id;
121
  m_packetId = id;
123
}
122
}
124
void
123
void
125
FlowProbeTag::SetPacketSize (uint32_t size)
124
Ipv4FlowProbeTag::SetPacketSize (uint32_t size)
126
{
125
{
127
  m_packetSize = size;
126
  m_packetSize = size;
128
}
127
}
129
uint32_t
128
uint32_t
130
FlowProbeTag::GetFlowId (void) const
129
Ipv4FlowProbeTag::GetFlowId (void) const
131
{
130
{
132
  return m_flowId;
131
  return m_flowId;
133
}  
132
}  
134
uint32_t
133
uint32_t
135
FlowProbeTag::GetPacketId (void) const
134
Ipv4FlowProbeTag::GetPacketId (void) const
136
{
135
{
137
  return m_packetId;
136
  return m_packetId;
138
} 
137
} 
139
uint32_t
138
uint32_t
140
FlowProbeTag::GetPacketSize (void) const
139
Ipv4FlowProbeTag::GetPacketSize (void) const
141
{
140
{
142
  return m_packetSize;
141
  return m_packetSize;
143
} 
142
} 
 Lines 199-205    Link Here 
199
240
200
      // tag the packet with the flow id and packet id, so that the packet can be identified even
241
      // tag the packet with the flow id and packet id, so that the packet can be identified even
201
      // when Ipv4Header is not accessible at some non-IPv4 protocol layer
242
      // when Ipv4Header is not accessible at some non-IPv4 protocol layer
202
      FlowProbeTag fTag (flowId, packetId, size);
243
      Ipv4FlowProbeTag fTag (flowId, packetId, size);
244
      NS_ASSERT_MSG (!ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag), "There alrady exists a FlowProbeTag with the packet " << *ipPayload << " Uid=" << ipPayload->GetUid ());
203
      ipPayload->AddPacketTag (fTag);
245
      ipPayload->AddPacketTag (fTag);
204
    }
246
    }
205
}
247
}
 Lines 228-236    Link Here 
228
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
270
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
229
    {
271
    {
230
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
272
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
231
      FlowProbeTag fTag;
273
      Ipv4FlowProbeTag fTag;
232
      bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
274
      bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
233
      NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing");
275
      NS_ASSERT_MSG (tagFound, "Ipv4FlowProbeTag is missing");
234
276
235
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
277
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
236
      NS_LOG_DEBUG ("ReportLastRx ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<");");
278
      NS_LOG_DEBUG ("ReportLastRx ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<");");
 Lines 266-274    Link Here 
266
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
308
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
267
    {
309
    {
268
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
310
      // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
269
      FlowProbeTag fTag;
311
      Ipv4FlowProbeTag fTag;
270
      bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
312
      bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
271
      NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing");
313
      NS_ASSERT_MSG (tagFound, "Ipv4FlowProbeTag is missing");
272
314
273
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
315
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
274
      NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << reason 
316
      NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << reason 
 Lines 305-312    Link Here 
305
Ipv4FlowProbe::QueueDropLogger (Ptr<const Packet> ipPayload)
347
Ipv4FlowProbe::QueueDropLogger (Ptr<const Packet> ipPayload)
306
{
348
{
307
  // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
349
  // remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
308
  FlowProbeTag fTag;
350
  Ipv4FlowProbeTag fTag;
309
  bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
351
  bool tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
352
  NS_ASSERT_MSG (tagFound, "FlowProbeTag is missing");
310
  
353
  
311
  if (tagFound)
354
  if (tagFound)
312
  {
355
  {

Return to bug 854