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

(-)a/src/helper/internet-stack-helper.cc (+30 lines)
 Lines 92-97   InternetStackHelper::Install (Ptr<Node> Link Here 
92
}
92
}
93
93
94
void
94
void
95
InternetStackHelper::EnableAscii (std::ostream &os, NodeContainer n)
96
{
97
  Packet::EnablePrinting ();
98
  std::ostringstream oss;
99
  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
100
    {
101
      Ptr<Node> node = *i;
102
      oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
103
      Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, &os));
104
      oss.str ("");
105
      oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
106
      Config::Connect (oss.str (), MakeBoundCallback (&InternetStackHelper::AsciiDropEvent, &os));
107
      oss.str ("");
108
    }
109
}
110
111
void
112
InternetStackHelper::EnableAsciiAll (std::ostream &os)
113
{
114
  EnableAscii (os, NodeContainer::GetGlobal ());
115
}
116
117
void
95
InternetStackHelper::EnablePcapAll (std::string filename)
118
InternetStackHelper::EnablePcapAll (std::string filename)
96
{
119
{
97
  Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
120
  Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
 Lines 157-160   InternetStackHelper::GetStream (uint32_t Link Here 
157
  return trace.writer;
180
  return trace.writer;
158
}
181
}
159
182
183
void
184
InternetStackHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
185
{
186
  *os << "d " << Simulator::Now ().GetSeconds () << " ";
187
  *os << path << " " << *packet << std::endl;
188
}
189
160
} // namespace ns3
190
} // namespace ns3
(-)a/src/helper/internet-stack-helper.h (+20 lines)
 Lines 70-75   public: Link Here 
70
  void SetNscStack(std::string soname);
70
  void SetNscStack(std::string soname);
71
71
72
  /**
72
  /**
73
   * \param os output stream
74
   * \param n node container
75
   *
76
   * Enable ascii output on these drop traces, for each node in the NodeContainer..
77
   * /NodeList/[i]/$ns3ArpL3Protocol/Drop 
78
   * /NodeList/[i]/$ns3Ipv4L3Protocol/Drop 
79
   */
80
  static void EnableAscii (std::ostream &os, NodeContainer n);
81
82
  /**
83
   * \param os output stream
84
   *
85
   * Enable ascii output on these drop traces, for all nodes.
86
   * /NodeList/[i]/$ns3ArpL3Protocol/Drop 
87
   * /NodeList/[i]/$ns3Ipv4L3Protocol/Drop 
88
   */
89
  static void EnableAsciiAll (std::ostream &os);
90
91
  /**
73
   * Enable pcap output on each protocol instance which is of the
92
   * Enable pcap output on each protocol instance which is of the
74
   * ns3::Ipv4L3Protocol type.  Both Tx and Rx events will be logged.
93
   * ns3::Ipv4L3Protocol type.  Both Tx and Rx events will be logged.
75
   *
94
   *
 Lines 95-100   private: Link Here 
95
    uint32_t interfaceId;
114
    uint32_t interfaceId;
96
    Ptr<PcapWriter> writer;
115
    Ptr<PcapWriter> writer;
97
  };
116
  };
117
  static void AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet);
98
  static std::string m_pcapBaseFilename;
118
  static std::string m_pcapBaseFilename;
99
  static uint32_t GetNodeIndex (std::string context);
119
  static uint32_t GetNodeIndex (std::string context);
100
  static std::vector<Trace> m_traces;
120
  static std::vector<Trace> m_traces;
(-)a/src/helper/ipv4-address-helper.cc (-3 lines)
 Lines 63-71   Ipv4AddressHelper::SetBase ( Link Here 
63
//
63
//
64
  NS_ASSERT_MSG((m_network & ~m_mask) == 0,
64
  NS_ASSERT_MSG((m_network & ~m_mask) == 0,
65
    "Ipv4AddressHelper::SetBase(): Inconsistent network and mask");
65
    "Ipv4AddressHelper::SetBase(): Inconsistent network and mask");
66
67
  NS_ASSERT_MSG((m_address & m_mask) == 0,
68
    "Ipv4AddressHelper::SetBase(): Inconsistent address and mask");
69
66
70
//
67
//
71
// Figure out how much to shift network numbers to get them aligned, and what
68
// Figure out how much to shift network numbers to get them aligned, and what
(-)a/src/node/ipv4-address.cc (+6 lines)
 Lines 125-130   Ipv4Mask::GetZero (void) Link Here 
125
{
125
{
126
  static Ipv4Mask zero = Ipv4Mask ("0.0.0.0");
126
  static Ipv4Mask zero = Ipv4Mask ("0.0.0.0");
127
  return zero;
127
  return zero;
128
}
129
Ipv4Mask
130
Ipv4Mask::GetOnes (void)
131
{
132
  static Ipv4Mask ones = Ipv4Mask ("255.255.255.255");
133
  return ones;
128
}
134
}
129
135
130
Ipv4Address::Ipv4Address ()
136
Ipv4Address::Ipv4Address ()
(-)a/src/node/ipv4-address.h (+1 lines)
 Lines 179-184   public: Link Here 
179
179
180
  static Ipv4Mask GetLoopback (void);
180
  static Ipv4Mask GetLoopback (void);
181
  static Ipv4Mask GetZero (void);
181
  static Ipv4Mask GetZero (void);
182
  static Ipv4Mask GetOnes (void);
182
183
183
private:
184
private:
184
  uint32_t m_mask;
185
  uint32_t m_mask;
(-)a/src/internet-stack/udp-socket-impl.cc (-9 / +28 lines)
 Lines 349-356   UdpSocketImpl::DoSendTo (Ptr<Packet> p, Link Here 
349
      }
349
      }
350
  }
350
  }
351
  //
351
  //
352
  // If dest is sent to the limited broadcast address (all ones),
352
  // If dest is set to the limited broadcast address (all ones),
353
  // convert it to send a copy of the packet out of every interface
353
  // convert it to send a copy of the packet out of every 
354
  // interface as a subnet-directed broadcast.
355
  // Exception:  if the interface has a /32 address, there is no
356
  // valid subnet-directed broadcast, so send it as limited broadcast
357
  // Note also that some systems will only send limited broadcast packets
358
  // out of the "default" interface; here we send it out all interfaces
354
  //
359
  //
355
  if (dest.IsBroadcast ())
360
  if (dest.IsBroadcast ())
356
    {
361
    {
 Lines 359-371   UdpSocketImpl::DoSendTo (Ptr<Packet> p, Link Here 
359
        {
364
        {
360
          Ipv4Address addri = ipv4->GetAddress (i);
365
          Ipv4Address addri = ipv4->GetAddress (i);
361
          Ipv4Mask maski = ipv4->GetNetworkMask (i);
366
          Ipv4Mask maski = ipv4->GetNetworkMask (i);
362
          Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski);
367
          if (maski == Ipv4Mask::GetOnes ())
363
          NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast
368
            {
364
                        << " (mask is " << maski << ")");
369
              // if the network mask is 255.255.255.255, do not convert dest
365
          m_udp->Send (p->Copy (), addri, bcast,
370
              NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << dest
366
                       m_endPoint->GetLocalPort (), port);
371
                            << " (mask is " << maski << ")");
367
          NotifyDataSent (p->GetSize ());
372
              m_udp->Send (p->Copy (), addri, dest,
368
          NotifySend (GetTxAvailable ());
373
                           m_endPoint->GetLocalPort (), port);
374
              NotifyDataSent (p->GetSize ());
375
              NotifySend (GetTxAvailable ());
376
            }
377
          else
378
            {
379
              // Convert to subnet-directed broadcast
380
              Ipv4Address bcast = addri.GetSubnetDirectedBroadcast (maski);
381
              NS_LOG_LOGIC ("Sending one copy from " << addri << " to " << bcast
382
                            << " (mask is " << maski << ")");
383
              m_udp->Send (p->Copy (), addri, bcast,
384
                           m_endPoint->GetLocalPort (), port);
385
              NotifyDataSent (p->GetSize ());
386
              NotifySend (GetTxAvailable ());
387
            }
369
        }
388
        }
370
      NS_LOG_LOGIC ("Limited broadcast end.");
389
      NS_LOG_LOGIC ("Limited broadcast end.");
371
      return p->GetSize();
390
      return p->GetSize();
(-)a/src/node/ipv4-address.cc (+10 lines)
 Lines 170-181   Ipv4Address Link Here 
170
Ipv4Address 
170
Ipv4Address 
171
Ipv4Address::GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const
171
Ipv4Address::GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const
172
{
172
{
173
  if (mask == Ipv4Mask::GetOnes ())
174
    {
175
      NS_ASSERT_MSG (false, "Trying to get subnet-directed broadcast address with an all-ones netmask");
176
    }
173
  return Ipv4Address (Get () | mask.GetInverse ());
177
  return Ipv4Address (Get () | mask.GetInverse ());
174
}
178
}
175
179
176
bool
180
bool
177
Ipv4Address::IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const
181
Ipv4Address::IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const
178
{
182
{
183
  if (mask == Ipv4Mask::GetOnes ())
184
    {
185
      // If the mask is 255.255.255.255, there is no subnet directed
186
      // broadcast for this address.
187
      return false;
188
    }
179
  return ( (Get () | mask.GetInverse ()) == Get () );
189
  return ( (Get () | mask.GetInverse ()) == Get () );
180
}
190
}
181
191
(-)a/src/node/ipv4-address.h (-1 / +3 lines)
 Lines 120-126   public: Link Here 
120
   * \brief Generate subnet-directed broadcast address corresponding to mask
120
   * \brief Generate subnet-directed broadcast address corresponding to mask
121
   *
121
   *
122
   * The subnet-directed broadcast address has the host bits set to all
122
   * The subnet-directed broadcast address has the host bits set to all
123
   * ones.
123
   * ones.  If this method is called with a mask of 255.255.255.255,
124
   * (i.e., the address is a /32 address), the program will assert, since
125
   * there is no subnet associated with a /32 address.
124
   *
126
   *
125
   * \param mask a network mask 
127
   * \param mask a network mask 
126
   */
128
   */
(-)a/src/internet-stack/ipv4-l3-protocol.cc (+1 lines)
 Lines 827-832   Ipv4L3Protocol::DoForward (uint32_t ifIn Link Here 
827
          Ptr<Icmpv4L4Protocol> icmp = GetIcmp ();
827
          Ptr<Icmpv4L4Protocol> icmp = GetIcmp ();
828
          icmp->SendTimeExceededTtl (ipHeader, packet);
828
          icmp->SendTimeExceededTtl (ipHeader, packet);
829
        }
829
        }
830
      NS_LOG_WARN ("TTL exceeded.  Drop.");
830
      m_dropTrace (packet);
831
      m_dropTrace (packet);
831
      return;
832
      return;
832
    }  
833
    }  

Return to bug 400