1.1 --- a/examples/virtual-net-device.cc Sat Jul 04 08:53:44 2009 +0200
1.2 +++ b/examples/virtual-net-device.cc Sat Jul 04 08:54:33 2009 +0200
1.3 @@ -80,6 +80,7 @@
1.4 bool
1.5 N0VirtualSend (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
1.6 {
1.7 + NS_LOG_DEBUG ("Send to " << m_n3Address << ": " << *packet);
1.8 m_n0Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667));
1.9 return true;
1.10 }
1.11 @@ -87,6 +88,7 @@
1.12 bool
1.13 N1VirtualSend (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
1.14 {
1.15 + NS_LOG_DEBUG ("Send to " << m_n3Address << ": " << *packet);
1.16 m_n1Socket->SendTo (packet, 0, InetSocketAddress (m_n3Address, 667));
1.17 return true;
1.18 }
1.19 @@ -96,10 +98,12 @@
1.20 {
1.21 if (m_rng.GetValue () < 0.25)
1.22 {
1.23 + NS_LOG_DEBUG ("Send to " << m_n0Address << ": " << *packet);
1.24 m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n0Address, 667));
1.25 }
1.26 else
1.27 {
1.28 + NS_LOG_DEBUG ("Send to " << m_n1Address << ": " << *packet);
1.29 m_n3Socket->SendTo (packet, 0, InetSocketAddress (m_n1Address, 667));
1.30 }
1.31 return true;
1.32 @@ -108,6 +112,7 @@
1.33 void N3SocketRecv (Ptr<Socket> socket)
1.34 {
1.35 Ptr<Packet> packet = socket->Recv (65535, 0);
1.36 + NS_LOG_DEBUG ("N3SocketRecv: " << *packet);
1.37 SocketAddressTag socketAddressTag;
1.38 packet->RemovePacketTag (socketAddressTag);
1.39 m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST);
1.40 @@ -116,6 +121,7 @@
1.41 void N0SocketRecv (Ptr<Socket> socket)
1.42 {
1.43 Ptr<Packet> packet = socket->Recv (65535, 0);
1.44 + NS_LOG_DEBUG ("N0SocketRecv: " << *packet);
1.45 SocketAddressTag socketAddressTag;
1.46 packet->RemovePacketTag (socketAddressTag);
1.47 m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST);
1.48 @@ -124,6 +130,7 @@
1.49 void N1SocketRecv (Ptr<Socket> socket)
1.50 {
1.51 Ptr<Packet> packet = socket->Recv (65535, 0);
1.52 + NS_LOG_DEBUG ("N1SocketRecv: " << *packet);
1.53 SocketAddressTag socketAddressTag;
1.54 packet->RemovePacketTag (socketAddressTag);
1.55 m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST);
1.56 @@ -192,6 +199,8 @@
1.57 #if 0
1.58 LogComponentEnable ("VirtualNetDeviceExample", LOG_LEVEL_INFO);
1.59 #endif
1.60 + Packet::EnablePrinting ();
1.61 +
1.62
1.63 // Set up some default values for the simulation. Use the
1.64 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
1.65 @@ -266,11 +275,11 @@
1.66 Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
1.67 apps = sink.Install (c.Get (3));
1.68 apps.Start (Seconds (1.0));
1.69 - apps.Stop (Seconds (10.0));
1.70 + //apps.Stop (Seconds (10.0));
1.71
1.72 // Create a similar flow from n3 to n1, starting at time 1.1 seconds
1.73 onoff.SetAttribute ("Remote",
1.74 - AddressValue (InetSocketAddress (Ipv4Address ("11.0.0.2"), port)));
1.75 + AddressValue (InetSocketAddress (Ipv4Address ("11.0.0.1"), port)));
1.76 apps = onoff.Install (c.Get (3));
1.77 apps.Start (Seconds (1.1));
1.78 apps.Stop (Seconds (10.0));
1.79 @@ -278,7 +287,7 @@
1.80 // Create a packet sink to receive these packets
1.81 apps = sink.Install (c.Get (1));
1.82 apps.Start (Seconds (1.1));
1.83 - apps.Stop (Seconds (10.0));
1.84 + //apps.Stop (Seconds (10.0));
1.85
1.86 std::ofstream ascii;
1.87 ascii.open ("virtual-net-device.tr");
2.1 --- a/src/core/global-value.cc Sat Jul 04 08:53:44 2009 +0200
2.2 +++ b/src/core/global-value.cc Sat Jul 04 08:54:33 2009 +0200
2.3 @@ -174,6 +174,30 @@
2.4 {
2.5 return GetVector ()->end ();
2.6 }
2.7 +
2.8 +bool
2.9 +GlobalValue::GetValueByNameFailSafe (std::string name, AttributeValue &value)
2.10 +{
2.11 + for (GlobalValue::Iterator gvit = GlobalValue::Begin (); gvit != GlobalValue::End (); ++gvit)
2.12 + {
2.13 + if ((*gvit)->GetName () == name)
2.14 + {
2.15 + (*gvit)->GetValue (value);
2.16 + return true;
2.17 + }
2.18 + }
2.19 + return false; // not found
2.20 +}
2.21 +
2.22 +void
2.23 +GlobalValue::GetValueByName (std::string name, AttributeValue &value)
2.24 +{
2.25 + if (! GetValueByNameFailSafe (name, value))
2.26 + {
2.27 + NS_FATAL_ERROR ("Could not find GlobalValue named \"" << name << "\"");
2.28 + }
2.29 +}
2.30 +
2.31 GlobalValue::Vector *
2.32 GlobalValue::GetVector (void)
2.33 {
3.1 --- a/src/core/global-value.h Sat Jul 04 08:53:44 2009 +0200
3.2 +++ b/src/core/global-value.h Sat Jul 04 08:54:33 2009 +0200
3.3 @@ -114,6 +114,30 @@
3.4 * \returns an iterator which represents a pointer to the last GlobalValue registered.
3.5 */
3.6 static Iterator End (void);
3.7 +
3.8 +
3.9 + /**
3.10 + * finds the GlobalValue with the given name and returns its value
3.11 + *
3.12 + * @param name the name of the GlobalValue to be found
3.13 + * @param value where to store the value of the found GlobalValue
3.14 + *
3.15 + * @return true if the GlobalValue was found, false otherwise
3.16 + */
3.17 + static bool GetValueByNameFailSafe (std::string name, AttributeValue &value);
3.18 +
3.19 + /**
3.20 + * finds the GlobalValue with the given name and returns its
3.21 + * value. This method cannot fail, i.e., it will trigger a
3.22 + * NS_FATAL_ERROR if the requested GlobalValue is not found.
3.23 + *
3.24 + * @param name the name of the GlobalValue to be found
3.25 + * @param value where to store the value of the found GlobalValue
3.26 + *
3.27 + */
3.28 + static void GetValueByName (std::string name, AttributeValue &value);
3.29 +
3.30 +
3.31 private:
3.32 friend class GlobalValueTests;
3.33 static Vector *GetVector (void);
4.1 --- a/src/internet-stack/ipv4-interface.cc Sat Jul 04 08:53:44 2009 +0200
4.2 +++ b/src/internet-stack/ipv4-interface.cc Sat Jul 04 08:54:33 2009 +0200
4.3 @@ -178,7 +178,7 @@
4.4 void
4.5 Ipv4Interface::Send (Ptr<Packet> p, Ipv4Address dest)
4.6 {
4.7 - NS_LOG_FUNCTION_NOARGS ();
4.8 + NS_LOG_FUNCTION (dest << *p);
4.9 if (!IsUp())
4.10 {
4.11 return;