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

(-)a/src/flow-monitor/model/ipv4-flow-classifier.cc (-6 lines)
 Lines 103-114    Link Here 
103
Ipv4FlowClassifier::Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
103
Ipv4FlowClassifier::Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
104
                              uint32_t *out_flowId, uint32_t *out_packetId)
104
                              uint32_t *out_flowId, uint32_t *out_packetId)
105
{
105
{
106
  if (ipHeader.GetDestination () == Ipv4Address::GetBroadcast ())
107
    {
108
      // we are not prepared to handle broadcast yet
109
      return false;
110
    }
111
112
  if (ipHeader.GetFragmentOffset () > 0 )
106
  if (ipHeader.GetFragmentOffset () > 0 )
113
    {
107
    {
114
      // Ignore fragments: they don't carry a valid L4 header
108
      // Ignore fragments: they don't carry a valid L4 header
(-)a/src/flow-monitor/model/ipv4-flow-probe.cc (-9 / +17 lines)
 Lines 197-222    Link Here 
197
{
197
{
198
  NS_LOG_FUNCTION (this << node->GetId ());
198
  NS_LOG_FUNCTION (this << node->GetId ());
199
199
200
  Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
200
  m_ipv4 = node->GetObject<Ipv4L3Protocol> ();
201
201
202
  if (!ipv4->TraceConnectWithoutContext ("SendOutgoing",
202
  if (!m_ipv4->TraceConnectWithoutContext ("SendOutgoing",
203
                                         MakeCallback (&Ipv4FlowProbe::SendOutgoingLogger, Ptr<Ipv4FlowProbe> (this))))
203
                                           MakeCallback (&Ipv4FlowProbe::SendOutgoingLogger, Ptr<Ipv4FlowProbe> (this))))
204
    {
204
    {
205
      NS_FATAL_ERROR ("trace fail");
205
      NS_FATAL_ERROR ("trace fail");
206
    }
206
    }
207
  if (!ipv4->TraceConnectWithoutContext ("UnicastForward",
207
  if (!m_ipv4->TraceConnectWithoutContext ("UnicastForward",
208
                                         MakeCallback (&Ipv4FlowProbe::ForwardLogger, Ptr<Ipv4FlowProbe> (this))))
208
                                           MakeCallback (&Ipv4FlowProbe::ForwardLogger, Ptr<Ipv4FlowProbe> (this))))
209
    {
209
    {
210
      NS_FATAL_ERROR ("trace fail");
210
      NS_FATAL_ERROR ("trace fail");
211
    }
211
    }
212
  if (!ipv4->TraceConnectWithoutContext ("LocalDeliver",
212
  if (!m_ipv4->TraceConnectWithoutContext ("LocalDeliver",
213
                                         MakeCallback (&Ipv4FlowProbe::ForwardUpLogger, Ptr<Ipv4FlowProbe> (this))))
213
                                           MakeCallback (&Ipv4FlowProbe::ForwardUpLogger, Ptr<Ipv4FlowProbe> (this))))
214
    {
214
    {
215
      NS_FATAL_ERROR ("trace fail");
215
      NS_FATAL_ERROR ("trace fail");
216
    }
216
    }
217
217
218
  if (!ipv4->TraceConnectWithoutContext ("Drop",
218
  if (!m_ipv4->TraceConnectWithoutContext ("Drop",
219
                                         MakeCallback (&Ipv4FlowProbe::DropLogger, Ptr<Ipv4FlowProbe> (this))))
219
                                           MakeCallback (&Ipv4FlowProbe::DropLogger, Ptr<Ipv4FlowProbe> (this))))
220
    {
220
    {
221
      NS_FATAL_ERROR ("trace fail");
221
      NS_FATAL_ERROR ("trace fail");
222
    }
222
    }
 Lines 234-239    Link Here 
234
void
234
void
235
Ipv4FlowProbe::DoDispose ()
235
Ipv4FlowProbe::DoDispose ()
236
{
236
{
237
  m_ipv4 = 0;
238
  m_classifier = 0;
237
  FlowProbe::DoDispose ();
239
  FlowProbe::DoDispose ();
238
}
240
}
239
241
 Lines 243-248    Link Here 
243
  FlowId flowId;
245
  FlowId flowId;
244
  FlowPacketId packetId;
246
  FlowPacketId packetId;
245
247
248
  if (!m_ipv4->IsUnicast(ipHeader.GetDestination ()))
249
    {
250
      // we are not prepared to handle broadcast yet
251
      return;
252
    }
253
246
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
254
  if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
247
    {
255
    {
248
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
256
      uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
(-)a/src/flow-monitor/model/ipv4-flow-probe.h (+1 lines)
 Lines 106-111    Link Here 
106
  void QueueDropLogger (Ptr<const Packet> ipPayload);
106
  void QueueDropLogger (Ptr<const Packet> ipPayload);
107
107
108
  Ptr<Ipv4FlowClassifier> m_classifier; //!< the Ipv4FlowClassifier this probe is associated with
108
  Ptr<Ipv4FlowClassifier> m_classifier; //!< the Ipv4FlowClassifier this probe is associated with
109
  Ptr<Ipv4L3Protocol> m_ipv4; //!< the Ipv4L3Protocol this probe is bound to
109
};
110
};
110
111
111
112
(-)a/src/internet/model/ipv4-l3-protocol.cc (+29 lines)
 Lines 539-544    Link Here 
539
}
539
}
540
540
541
bool
541
bool
542
Ipv4L3Protocol::IsUnicast (Ipv4Address ad) const
543
{
544
  NS_LOG_FUNCTION (this << ad);
545
546
  if (ad.IsBroadcast () || ad.IsMulticast ())
547
    {
548
      return false;
549
    }
550
  else
551
    {
552
      // check for subnet-broadcast
553
      for (uint32_t ifaceIndex = 0; ifaceIndex < GetNInterfaces (); ifaceIndex++)
554
        {
555
          for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++)
556
            {
557
              Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j);
558
              NS_LOG_LOGIC ("Testing address " << ad << " with mask " << ifAddr.GetMask ());
559
              if (ad.IsSubnetDirectedBroadcast (ifAddr.GetMask ()) )
560
                {
561
                  return false;
562
                }
563
            }
564
        }
565
    }
566
567
  return true;
568
}
569
570
bool
542
Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const
571
Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const
543
{
572
{
544
  NS_LOG_FUNCTION (this << ad << interfaceMask);
573
  NS_LOG_FUNCTION (this << ad << interfaceMask);
(-)a/src/internet/model/ipv4-l3-protocol.h (+12 lines)
 Lines 225-230    Link Here 
225
225
226
  Ptr<NetDevice> GetNetDevice (uint32_t i);
226
  Ptr<NetDevice> GetNetDevice (uint32_t i);
227
227
228
  /**
229
   * \brief Check if an IPv4 address is unicast according to the node.
230
   *
231
   * This function checks all the node's interfaces and the respective subnet masks.
232
   * An address is considered unicast if it's not broadcast, subnet-broadcast or multicast.
233
   *
234
   * \param ad address
235
   *
236
   * \return true if the address is unicast
237
   */
238
  bool IsUnicast (Ipv4Address ad) const;
239
228
protected:
240
protected:
229
241
230
  virtual void DoDispose (void);
242
  virtual void DoDispose (void);

Return to bug 1845