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

(-)a/CHANGES.html (-1 / +2 lines)
 Lines 59-67    Link Here 
59
by the ns-3 logging system to report the execution context of each log line.
59
by the ns-3 logging system to report the execution context of each log line.
60
<li><b>Object::DoStart</b>: Users who need to complete their object setup at the start of a simulation
60
<li><b>Object::DoStart</b>: Users who need to complete their object setup at the start of a simulation
61
can override this virtual method, perform their adhoc setup, and then, must chain up to their parent.
61
can override this virtual method, perform their adhoc setup, and then, must chain up to their parent.
62
63
<li><b>Aod hoc On-Demand Distance Vector (AODV)</b> routing model, 
62
<li><b>Aod hoc On-Demand Distance Vector (AODV)</b> routing model, 
64
<a href=http://www.ietf.org/rfc/rfc3561.txt>RFC 3561</a> </li>
63
<a href=http://www.ietf.org/rfc/rfc3561.txt>RFC 3561</a> </li>
64
<li><b>Ipv4::IsDestinationAddress (Ipv4Address address, uint32_t iif)</b> Method added to support checks of whether a destination address should be accepted 
65
as one of the host's own addresses.  RFC 1122 Strong/Weak end system behavior can be changed with a new attribute (WeakEsModel) in class Ipv4.  </li>
65
66
66
</ul>
67
</ul>
67
68
(-)a/src/internet-stack/ipv4-l3-protocol.cc (+76 lines)
 Lines 355-360    Link Here 
355
  return -1;
355
  return -1;
356
}
356
}
357
357
358
bool
359
Ipv4L3Protocol::IsDestinationAddress (Ipv4Address address, uint32_t iif) const
360
{
361
  NS_LOG_FUNCTION (this << address << " " << iif);
362
363
  // First check the incoming interface for a unicast address match
364
  for (uint32_t i = 0; i < GetNAddresses (iif); i++)
365
    {
366
      Ipv4InterfaceAddress iaddr = GetAddress (iif, i);
367
      if (address == iaddr.GetLocal ())
368
        {
369
          NS_LOG_LOGIC ("For me (destination " << address << " match)");
370
          return true;
371
        }
372
      if (address == iaddr.GetBroadcast ())
373
        {
374
          NS_LOG_LOGIC ("For me (interface broadcast address)");
375
          return true;
376
        }
377
    }
378
379
  if (address.IsMulticast ())
380
    {
381
#ifdef NOTYET
382
      if (MulticastCheckGroup (iif, address ))
383
#endif
384
      if (true)
385
        {
386
          NS_LOG_LOGIC ("For me (Ipv4Addr multicast address");
387
          return true;
388
        }
389
    }
390
391
  if (address.IsBroadcast ())
392
    {
393
      NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
394
      return true;
395
    }
396
397
  if (GetWeakEsModel ())  // Check other interfaces
398
    { 
399
      for (uint32_t j = 0; j < GetNInterfaces (); j++)
400
        {
401
          if (j == uint32_t (iif)) continue;
402
          for (uint32_t i = 0; i < GetNAddresses (j); i++)
403
            {
404
              Ipv4InterfaceAddress iaddr = GetAddress (j, i);
405
              if (address == iaddr.GetLocal ())
406
                {
407
                  NS_LOG_LOGIC ("For me (destination " << address << " match) on another interface");
408
                  return true;
409
                }
410
              //  This is a small corner case:  match another interface's broadcast address
411
              if (address == iaddr.GetBroadcast ())
412
                {
413
                  NS_LOG_LOGIC ("For me (interface broadcast address on another interface)");
414
                  return true;
415
                }
416
            }
417
        }
418
    }
419
  return false;
420
}
421
358
void 
422
void 
359
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
423
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
360
                         const Address &to, NetDevice::PacketType packetType)
424
                         const Address &to, NetDevice::PacketType packetType)
 Lines 901-906    Link Here 
901
  return m_ipForward;
965
  return m_ipForward;
902
}
966
}
903
967
968
void 
969
Ipv4L3Protocol::SetWeakEsModel (bool model)
970
{
971
  m_weakEsModel = model;
972
}
973
974
bool 
975
Ipv4L3Protocol::GetWeakEsModel (void) const
976
{
977
  return m_weakEsModel;
978
}
979
904
void
980
void
905
Ipv4L3Protocol::RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeader, Socket::SocketErrno sockErrno)
981
Ipv4L3Protocol::RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeader, Socket::SocketErrno sockErrno)
906
{
982
{
(-)a/src/internet-stack/ipv4-l3-protocol.h (+5 lines)
 Lines 170-175    Link Here 
170
  int32_t GetInterfaceForAddress (Ipv4Address addr) const;
170
  int32_t GetInterfaceForAddress (Ipv4Address addr) const;
171
  int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const;
171
  int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const;
172
  int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
172
  int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
173
  bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const;
173
174
174
  bool AddAddress (uint32_t i, Ipv4InterfaceAddress address);
175
  bool AddAddress (uint32_t i, Ipv4InterfaceAddress address);
175
  Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
176
  Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
 Lines 200-207    Link Here 
200
  Ipv4L3Protocol(const Ipv4L3Protocol &);
201
  Ipv4L3Protocol(const Ipv4L3Protocol &);
201
  Ipv4L3Protocol &operator = (const Ipv4L3Protocol &);
202
  Ipv4L3Protocol &operator = (const Ipv4L3Protocol &);
202
203
204
  // class Ipv4 attributes
203
  virtual void SetIpForward (bool forward);
205
  virtual void SetIpForward (bool forward);
204
  virtual bool GetIpForward (void) const;
206
  virtual bool GetIpForward (void) const;
207
  virtual void SetWeakEsModel (bool model);
208
  virtual bool GetWeakEsModel (void) const;
205
209
206
  Ipv4Header BuildHeader (
210
  Ipv4Header BuildHeader (
207
            Ipv4Address source,
211
            Ipv4Address source,
 Lines 239-244    Link Here 
239
  typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
243
  typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
240
244
241
  bool m_ipForward;
245
  bool m_ipForward;
246
  bool m_weakEsModel;
242
  L4List_t m_protocols;
247
  L4List_t m_protocols;
243
  Ipv4InterfaceList m_interfaces;
248
  Ipv4InterfaceList m_interfaces;
244
  uint8_t m_defaultTtl;
249
  uint8_t m_defaultTtl;
(-)a/src/node/ipv4.cc (+6 lines)
 Lines 37-42    Link Here 
37
                   MakeBooleanAccessor (&Ipv4::SetIpForward,
37
                   MakeBooleanAccessor (&Ipv4::SetIpForward,
38
                                        &Ipv4::GetIpForward),
38
                                        &Ipv4::GetIpForward),
39
                   MakeBooleanChecker ())
39
                   MakeBooleanChecker ())
40
    .AddAttribute ("WeakEsModel", 
41
                   "RFC1122 term for whether host accepts datagram with a dest. address on another interface",
42
                   BooleanValue (true),
43
                   MakeBooleanAccessor (&Ipv4::SetWeakEsModel,
44
                                        &Ipv4::GetWeakEsModel),
45
                   MakeBooleanChecker ())
40
#if 0
46
#if 0
41
    .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
47
    .AddAttribute ("MtuDiscover", "If enabled, every outgoing ip packet will have the DF flag set.",
42
                   BooleanValue (false),
48
                   BooleanValue (false),
(-)a/src/node/ipv4.h (-1 / +25 lines)
 Lines 123-133    Link Here 
123
   * This method searches the list of interfaces for one that holds a
123
   * This method searches the list of interfaces for one that holds a
124
   * particular address.  This call takes an IP address as a parameter and
124
   * particular address.  This call takes an IP address as a parameter and
125
   * returns the interface number of the first interface that has been assigned
125
   * returns the interface number of the first interface that has been assigned
126
   * that address, or -1 if not found.  There must be an exact match.
126
   * that address, or -1 if not found.  There must be an exact match; this
127
   * method will not match broadcast or multicast addresses.
127
   */
128
   */
128
  virtual int32_t GetInterfaceForAddress (Ipv4Address address) const = 0;
129
  virtual int32_t GetInterfaceForAddress (Ipv4Address address) const = 0;
129
130
130
  /**
131
  /**
132
   * \brief Determine whether address and interface corresponding to
133
   *        received packet can be accepted for local delivery
134
   *
135
   * \param address The IP address being considered
136
   * \param iif The incoming Ipv4 interface index
137
   *
138
   * This method can be used to determine whether a received packet has
139
   * an acceptable address for local delivery on the host.  The address
140
   * may be a unicast, multicast, or broadcast address.  This method will
141
   * return true if address is an exact match of a unicast address on
142
   * one of the host's interfaces (see below), if address corresponds to 
143
   * a multicast group that the host has joined (and the incoming device
144
   * is acceptable), or if address corresponds to a broadcast address.
145
   *
146
   * If the Ipv4 attribute WeakEsModel is true, the unicast address may
147
   * match any of the Ipv4 addresses on any interface.  If the attribute is
148
   * false, the address must match one assigned to the incoming device.
149
   */
150
  virtual bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const = 0;
151
152
  /**
131
   * \brief Return the interface number of first interface found that 
153
   * \brief Return the interface number of first interface found that 
132
   *  has an Ipv4 address within the prefix specified by the input
154
   *  has an Ipv4 address within the prefix specified by the input
133
   *  address and mask parameters
155
   *  address and mask parameters
 Lines 257-262    Link Here 
257
  // Indirect the Ipv4 attributes through private pure virtual methods
279
  // Indirect the Ipv4 attributes through private pure virtual methods
258
  virtual void SetIpForward (bool forward) = 0;
280
  virtual void SetIpForward (bool forward) = 0;
259
  virtual bool GetIpForward (void) const = 0;
281
  virtual bool GetIpForward (void) const = 0;
282
  virtual void SetWeakEsModel (bool model) = 0;
283
  virtual bool GetWeakEsModel (void) const = 0;
260
};
284
};
261
285
262
} // namespace ns3 
286
} // namespace ns3 
(-)a/src/routing/list-routing/ipv4-list-routing.cc (-64 / +20 lines)
 Lines 121-195    Link Here 
121
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
121
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
122
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); 
122
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); 
123
123
124
  // Multicast recognition; handle local delivery here
124
  retVal = m_ipv4->IsDestinationAddress (header.GetDestination (), iif);
125
  //
125
  if (retVal == true)
126
  if (header.GetDestination().IsMulticast ())
127
    {
126
    {
128
#ifdef NOTYET
127
      NS_LOG_LOGIC ("Address "<< header.GetDestination () << " is a match for local delivery");
129
      if (m_ipv4->MulticastCheckGroup (iif, header.GetDestination ()))
128
      if (header.GetDestination ().IsMulticast ())
130
#endif
131
      if (true)
132
        {
129
        {
133
          NS_LOG_LOGIC ("Multicast packet for me-- local deliver");
134
          Ptr<Packet> packetCopy = p->Copy();
130
          Ptr<Packet> packetCopy = p->Copy();
135
          // Here may want to disable lcb callback in recursive RouteInput
136
          // call below
137
          lcb (packetCopy, header, iif);
131
          lcb (packetCopy, header, iif);
138
          // Fall through-- we may also need to forward this
139
          retVal = true;
132
          retVal = true;
133
          // Fall through
140
        }
134
        }
141
      for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
135
      else
142
         m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end ();
143
           rprotoIter++)
144
        {
136
        {
145
          NS_LOG_LOGIC ("Multicast packet for me-- trying to forward");
137
          lcb (p, header, iif);
146
          if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
138
          return true;
147
            {
148
              retVal = true;
149
            }
150
        }
151
      return retVal;
152
    }
153
154
  if (header.GetDestination ().IsBroadcast ())
155
    {
156
      NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
157
      // TODO:  Local Deliver for broadcast
158
      // TODO:  Forward broadcast
159
    }
160
161
 // TODO:  Configurable option to enable RFC 1222 Strong End System Model
162
 // Right now, we will be permissive and allow a source to send us
163
 // a packet to one of our other interface addresses; that is, the
164
 // destination unicast address does not match one of the iif addresses,
165
 // but we check our other interfaces.  This could be an option
166
 // (to remove the outer loop immediately below and just check iif).
167
  for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
168
    {
169
      for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
170
        {
171
          Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
172
          Ipv4Address addr = iaddr.GetLocal ();
173
          if (addr.IsEqual (header.GetDestination ()))
174
            {
175
              if (j == iif)
176
                {
177
                  NS_LOG_LOGIC ("For me (destination " << addr << " match)");
178
                }
179
              else
180
                {
181
                  NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ());
182
                }
183
              lcb (p, header, iif);
184
              return true;
185
            }
186
          if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
187
            {
188
              NS_LOG_LOGIC ("For me (interface broadcast address)");
189
              lcb (p, header, iif);
190
              return true;
191
            }
192
          NS_LOG_LOGIC ("Address "<< addr << " not a match");
193
        }
139
        }
194
    }
140
    }
195
  // Check if input device supports IP forwarding
141
  // Check if input device supports IP forwarding
 Lines 200-213    Link Here 
200
      return false;
146
      return false;
201
    }
147
    }
202
  // Next, try to find a route
148
  // Next, try to find a route
149
  // If we have already delivered a packet locally (e.g. multicast)
150
  // we suppress further downstream local delivery by nulling the callback
151
  LocalDeliverCallback downstreamLcb = lcb;
152
  if (retVal == true)
153
    {
154
      downstreamLcb = MakeNullCallback<void, Ptr<const Packet>, const Ipv4Header &, uint32_t > ();
155
    }
203
  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
156
  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
204
         m_routingProtocols.begin ();
157
         m_routingProtocols.begin ();
205
       rprotoIter != m_routingProtocols.end ();
158
       rprotoIter != m_routingProtocols.end ();
206
       rprotoIter++)
159
       rprotoIter++)
207
    {
160
    {
208
      if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
161
      if (retVal == false)
209
        {
162
        {
210
          return true;
163
          if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, downstreamLcb, ecb))
164
            {
165
              return true;
166
            }
211
        }
167
        }
212
    }
168
    }
213
  // No routing protocol has found a route.  
169
  // No routing protocol has found a route.  

Return to bug 735