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

(-)a/ns-3.10/src/internet-stack/ipv4-l3-protocol.cc (-21 / +23 lines)
 Lines 739-768   Ipv4L3Protocol::IpMulticastForward (Ptr<Ipv4MulticastRoute> mrtentry, Ptr<const Link Here 
739
{
739
{
740
  NS_LOG_FUNCTION (this << mrtentry << p << header);
740
  NS_LOG_FUNCTION (this << mrtentry << p << header);
741
  NS_LOG_LOGIC ("Multicast forwarding logic for node: " << m_node->GetId ());
741
  NS_LOG_LOGIC ("Multicast forwarding logic for node: " << m_node->GetId ());
742
  // The output interfaces we could forward this onto are encoded
742
743
  // in the OutputTtl of the Ipv4MulticastRoute
743
  std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap();
744
  for (uint32_t i = 0; i < Ipv4MulticastRoute::MAX_INTERFACES; i++)
744
  std::map<uint32_t, uint32_t>::iterator mapIter;
745
746
  for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++)
745
    {
747
    {
746
      if (mrtentry->GetOutputTtl (i) < Ipv4MulticastRoute::MAX_TTL)
748
      uint32_t interfaceId = mapIter->first;
749
      //uint32_t outputTtl = mapIter->second;  // We never use this, do we?
750
751
      Ptr<Packet> packet = p->Copy ();
752
      Ipv4Header h = header;
753
      h.SetTtl (header.GetTtl () - 1);
754
      if (h.GetTtl () == 0)
747
        {
755
        {
748
          Ptr<Packet> packet = p->Copy ();
756
          NS_LOG_WARN ("TTL exceeded.  Drop.");
749
          Ipv4Header h = header;
757
          m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), interfaceId);
750
          h.SetTtl (header.GetTtl () - 1);
758
          return;
751
          if (h.GetTtl () == 0)
752
            {
753
              NS_LOG_WARN ("TTL exceeded.  Drop.");
754
              m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), i);
755
              return;
756
            }
757
          NS_LOG_LOGIC ("Forward multicast via interface " << i);
758
          Ptr<Ipv4Route> rtentry = Create<Ipv4Route> ();
759
          rtentry->SetSource (h.GetSource ());
760
          rtentry->SetDestination (h.GetDestination ());
761
          rtentry->SetGateway (Ipv4Address::GetAny ());
762
          rtentry->SetOutputDevice (GetNetDevice (i));
763
          SendRealOut (rtentry, packet, h);
764
          continue; 
765
        }
759
        }
760
      NS_LOG_LOGIC ("Forward multicast via interface " << interfaceId);
761
      Ptr<Ipv4Route> rtentry = Create<Ipv4Route> ();
762
      rtentry->SetSource (h.GetSource ());
763
      rtentry->SetDestination (h.GetDestination ());
764
      rtentry->SetGateway (Ipv4Address::GetAny ());
765
      rtentry->SetOutputDevice (GetNetDevice (interfaceId));
766
      SendRealOut (rtentry, packet, h);
767
      continue;
766
    }
768
    }
767
}
769
}
768
770
(-)a/ns-3.10/src/internet-stack/ipv6-l3-protocol.cc (-22 / +22 lines)
 Lines 910-940   void Ipv6L3Protocol::IpMulticastForward (Ptr<Ipv6MulticastRoute> mrtentry, Ptr<c Link Here 
910
  NS_LOG_FUNCTION (this << mrtentry << p << header);
910
  NS_LOG_FUNCTION (this << mrtentry << p << header);
911
  NS_LOG_LOGIC ("Multicast forwarding logic for node: " << m_node->GetId ());
911
  NS_LOG_LOGIC ("Multicast forwarding logic for node: " << m_node->GetId ());
912
912
913
  // The output interfaces we could forward this onto are encoded
913
  std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap();
914
  // in the OutputTtl of the Ipv6MulticastRoute
914
  std::map<uint32_t, uint32_t>::iterator mapIter;
915
  for (uint32_t i = 0 ; i < Ipv6MulticastRoute::MAX_INTERFACES ; i++)
915
916
  for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++)
916
    {
917
    {
917
      if (mrtentry->GetOutputTtl (i) < Ipv6MulticastRoute::MAX_TTL)
918
      uint32_t interfaceId = mapIter->first;
918
        {
919
      //uint32_t outputTtl = mapIter->second;  // We never use this, do we?
919
          Ptr<Packet> packet = p->Copy ();
920
          Ipv6Header h = header;
921
          h.SetHopLimit (header.GetHopLimit () - 1);
922
          if (h.GetHopLimit () == 0)
923
            {
924
              NS_LOG_WARN ("TTL exceeded.  Drop.");
925
              m_dropTrace (header, packet, DROP_TTL_EXPIRED, i);
926
              return;
927
            }
928
920
929
          NS_LOG_LOGIC ("Forward multicast via interface " << i);
921
      Ptr<Packet> packet = p->Copy ();
930
          Ptr<Ipv6Route> rtentry = Create<Ipv6Route> ();
922
      Ipv6Header h = header;
931
          rtentry->SetSource (h.GetSourceAddress ());
923
      h.SetHopLimit (header.GetHopLimit () - 1);
932
          rtentry->SetDestination (h.GetDestinationAddress ());
924
      if (h.GetHopLimit () == 0)
933
          rtentry->SetGateway (Ipv6Address::GetAny ());
925
        {
934
          rtentry->SetOutputDevice (GetNetDevice (i));
926
          NS_LOG_WARN ("TTL exceeded.  Drop.");
935
          SendRealOut (rtentry, packet, h);
927
          m_dropTrace (header, packet, DROP_TTL_EXPIRED, interfaceId);
936
          continue;
928
          return;
937
        }
929
        }
930
      NS_LOG_LOGIC ("Forward multicast via interface " << interfaceId);
931
      Ptr<Ipv6Route> rtentry = Create<Ipv6Route> ();
932
      rtentry->SetSource (h.GetSourceAddress ());
933
      rtentry->SetDestination (h.GetDestinationAddress ());
934
      rtentry->SetGateway (Ipv6Address::GetAny ());
935
      rtentry->SetOutputDevice (GetNetDevice (interfaceId));
936
      SendRealOut (rtentry, packet, h);
937
      continue;
938
    }
938
    }
939
}
939
}
940
940
(-)a/ns-3.10/src/node/ipv4-route.cc (-8 / +26 lines)
 Lines 82-93   std::ostream& operator<< (std::ostream& os, Ipv4Route const& route) Link Here 
82
82
83
Ipv4MulticastRoute::Ipv4MulticastRoute ()
83
Ipv4MulticastRoute::Ipv4MulticastRoute ()
84
{
84
{
85
  uint32_t initial_ttl = MAX_TTL;
85
  m_ttls.clear();
86
  // Initialize array to MAX_TTL, which means that all interfaces are "off"
87
  for (uint32_t i = 0; i < MAX_INTERFACES; i++)
88
    {
89
      m_ttls.push_back(initial_ttl);
90
    }
91
}
86
}
92
87
93
void 
88
void 
 Lines 129-141   Ipv4MulticastRoute::GetParent (void) const Link Here 
129
void 
124
void 
130
Ipv4MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
125
Ipv4MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
131
{
126
{
132
  m_ttls[oif] = ttl;
127
  if (ttl >= MAX_TTL)
128
  {
129
    // This TTL value effectively disables the interface
130
    std::map<uint32_t, uint32_t>::iterator iter;
131
    iter = m_ttls.find(oif);
132
    if (iter != m_ttls.end())
133
    {
134
      m_ttls.erase(iter);
135
    }
136
  }
137
  else
138
  {
139
    m_ttls[oif] = ttl;
140
  }
133
}
141
}
134
142
135
uint32_t
143
uint32_t
136
Ipv4MulticastRoute::GetOutputTtl (uint32_t oif) const
144
Ipv4MulticastRoute::GetOutputTtl (uint32_t oif) const
137
{
145
{
138
  return m_ttls[oif];
146
  // We keep this interface around for compatibility (for now?)
147
  std::map<uint32_t, uint32_t>::const_iterator iter = m_ttls.find(oif);
148
  if (iter == m_ttls.end())
149
    return((uint32_t)MAX_TTL);
150
  return(iter->second);
151
}
152
153
std::map<uint32_t, uint32_t>
154
Ipv4MulticastRoute::GetOutputTtlMap() const
155
{
156
    return(m_ttls);
139
}
157
}
140
158
141
}//namespace ns3
159
}//namespace ns3
(-)a/ns-3.10/src/node/ipv4-route.h (-2 / +7 lines)
 Lines 20-26    Link Here 
20
#define IPV4_ROUTE_H
20
#define IPV4_ROUTE_H
21
21
22
#include <list>
22
#include <list>
23
#include <vector>
23
#include <map>
24
#include <ostream>
24
#include <ostream>
25
25
26
#include "ns3/simple-ref-count.h"
26
#include "ns3/simple-ref-count.h"
 Lines 146-151   public: Link Here 
146
   * \return TTL for this route
146
   * \return TTL for this route
147
   */
147
   */
148
  uint32_t GetOutputTtl (uint32_t oif) const;
148
  uint32_t GetOutputTtl (uint32_t oif) const;
149
150
  /**
151
   * \return map of output interface Ids and TTLs for this route
152
   */
153
  std::map<uint32_t, uint32_t> GetOutputTtlMap() const;
149
  
154
  
150
  static const uint32_t MAX_INTERFACES = 16;  // Maximum number of multicast interfaces on a router
155
  static const uint32_t MAX_INTERFACES = 16;  // Maximum number of multicast interfaces on a router
151
  static const uint32_t MAX_TTL = 255;  // Maximum time-to-live (TTL)
156
  static const uint32_t MAX_TTL = 255;  // Maximum time-to-live (TTL)
 Lines 154-160   private: Link Here 
154
  Ipv4Address m_group;      // Group 
159
  Ipv4Address m_group;      // Group 
155
  Ipv4Address m_origin;     // Source of packet
160
  Ipv4Address m_origin;     // Source of packet
156
  uint32_t m_parent;        // Source interface
161
  uint32_t m_parent;        // Source interface
157
  std::vector<uint32_t> m_ttls;
162
  std::map<uint32_t, uint32_t> m_ttls;
158
};
163
};
159
164
160
}//namespace ns3
165
}//namespace ns3
(-)a/ns-3.10/src/node/ipv6-route.cc (-9 / +25 lines)
 Lines 82-94   std::ostream& operator<< (std::ostream& os, Ipv6Route const& route) Link Here 
82
82
83
Ipv6MulticastRoute::Ipv6MulticastRoute ()
83
Ipv6MulticastRoute::Ipv6MulticastRoute ()
84
{
84
{
85
  uint32_t initial_ttl = MAX_TTL;
85
  m_ttls.clear();
86
87
  /* Initialize array to MAX_TTL, which means that all interfaces are "off" */
88
  for (uint32_t i = 0; i < MAX_INTERFACES; i++)
89
    {
90
      m_ttls.push_back (initial_ttl);
91
    }
92
}
86
}
93
87
94
Ipv6MulticastRoute::~Ipv6MulticastRoute ()
88
Ipv6MulticastRoute::~Ipv6MulticastRoute ()
 Lines 127-138   uint32_t Ipv6MulticastRoute::GetParent () const Link Here 
127
121
128
void Ipv6MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
122
void Ipv6MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl)
129
{
123
{
130
  m_ttls[oif] = ttl;
124
  if (ttl >= MAX_TTL)
125
    {
126
      // This TTL value effectively disables the interface
127
      std::map<uint32_t, uint32_t>::iterator iter;
128
      iter = m_ttls.find(oif);
129
      if (iter != m_ttls.end())
130
        {
131
          m_ttls.erase(iter);
132
        }
133
    }
134
  else
135
    {
136
      m_ttls[oif] = ttl;
137
    }
131
}
138
}
132
139
133
uint32_t Ipv6MulticastRoute::GetOutputTtl (uint32_t oif) const
140
uint32_t Ipv6MulticastRoute::GetOutputTtl (uint32_t oif) const
134
{
141
{
135
  return m_ttls[oif];
142
  // We keep this interface around for compatibility (for now?)
143
  std::map<uint32_t, uint32_t>::const_iterator iter = m_ttls.find(oif);
144
  if (iter == m_ttls.end())
145
    return((uint32_t)MAX_TTL);
146
  return(iter->second);
147
}
148
149
std::map<uint32_t, uint32_t> Ipv6MulticastRoute::GetOutputTtlMap() const
150
{
151
    return(m_ttls);
136
}
152
}
137
153
138
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route)
154
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route)
(-)a/ns-3.10/src/node/ipv6-route.h (-2 / +7 lines)
 Lines 22-28    Link Here 
22
#define IPV6_ROUTE_H
22
#define IPV6_ROUTE_H
23
23
24
#include <list>
24
#include <list>
25
#include <vector>
25
#include <map>
26
#include <ostream>
26
#include <ostream>
27
27
28
#include "ns3/simple-ref-count.h"
28
#include "ns3/simple-ref-count.h"
 Lines 202-207   public: Link Here 
202
   */
202
   */
203
  uint32_t GetOutputTtl (uint32_t oif) const;
203
  uint32_t GetOutputTtl (uint32_t oif) const;
204
204
205
  /**
206
   * \return map of output interface Ids and TTLs for this route
207
   */
208
  std::map<uint32_t, uint32_t> GetOutputTtlMap() const;
209
205
private:
210
private:
206
  /**
211
  /**
207
   * \brief IPv6 group.
212
   * \brief IPv6 group.
 Lines 221-227   private: Link Here 
221
  /**
226
  /**
222
   * \brief TTLs.
227
   * \brief TTLs.
223
   */
228
   */
224
  std::vector<uint32_t> m_ttls;
229
  std::map<uint32_t, uint32_t> m_ttls;
225
};
230
};
226
231
227
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route);
232
std::ostream& operator<< (std::ostream& os, Ipv6MulticastRoute const& route);

Return to bug 1047