--- a/004-click-netdevice-queue-state.patch Fri May 27 14:58:13 2011 +0200
+++ b/004-click-netdevice-queue-state.patch Sat May 28 01:34:42 2011 +0200
@@ -9,7 +9,7 @@
new file mode 100644
--- /dev/null
+++ b/src/click/examples/nsclick-udp-2nodes-queue.cc
-@@ -0,0 +1,213 @@
+@@ -0,0 +1,234 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
@@ -67,29 +67,35 @@
+}
+
+void
-+readQueue(Ptr<Node> node, Ptr<Ipv4ClickRouting> clickRouter, std::string element)
++readQueue (Ptr<Node> node, Ptr<Ipv4ClickRouting> clickRouter, std::string element)
+{
+ uint32_t id = node->GetId();
+
-+ NS_LOG_INFO(Simulator::Now () << " Click queue size of node "<< id << ": " << clickRouter->ReadHandler (element, "length"));
-+ NS_LOG_INFO(Simulator::Now () << " Click queue highwater of node "<< id << ": " << clickRouter->ReadHandler (element, "highwater_length"));
-+ NS_LOG_INFO(Simulator::Now () << " Click queue drops of node "<< id << ": " << clickRouter->ReadHandler (element, "drops"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue size of node "<< id << ": " << clickRouter->ReadHandler (element, "length"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue highwater of node "<< id << ": " << clickRouter->ReadHandler (element, "highwater_length"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue drops of node "<< id << ": " << clickRouter->ReadHandler (element, "drops"));
+
+ Simulator::Schedule (Seconds (0.1), &readQueue,node,clickRouter,element);
+}
+
+void
-+initReadQueue(Ptr<Node> node, std::string element)
++initReadQueue (Ptr<Node> node, std::string element)
+{
+ uint32_t id = node->GetId();
+ Ptr<Ipv4ClickRouting> clickRouter = node->GetObject<Ipv4ClickRouting>();
+
-+ NS_LOG_INFO(Simulator::Now () << " Click queue size of node "<< id << ": " << clickRouter->ReadHandler (element, "length"));
-+ NS_LOG_INFO(Simulator::Now () << " Click queue highwater of node "<< id << ": " << clickRouter->ReadHandler (element, "highwater_length"));
-+ NS_LOG_INFO(Simulator::Now () << " Click queue drops of node "<< id << ": " << clickRouter->ReadHandler (element, "drops"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue size of node "<< id << ": " << clickRouter->ReadHandler (element, "length"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue highwater of node "<< id << ": " << clickRouter->ReadHandler (element, "highwater_length"));
++ NS_LOG_INFO (Simulator::Now () << " Click queue drops of node "<< id << ": " << clickRouter->ReadHandler (element, "drops"));
+
+ Simulator::Schedule (Seconds (0.1), &readQueue,node,clickRouter,element);
+}
++
++void
++printQueueSize (Ptr<WifiMacQueue> queue)
++{
++ NS_LOG_INFO (Simulator::Now () << " Wifi queue size: " << queue->GetSize ());
++}
+#endif
+
+int
@@ -204,6 +210,21 @@
+ Config::Set("/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::WifiNetDevice/Mac/$ns3::AdhocWifiMac/DcaTxop/$ns3::DcaTxop/Queue/$ns3::WifiMacQueue/MaxPacketNumber",
+ UintegerValue (5));
+
++ // Show how to print the Wifi MAC queue size at a particular time
++ Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (n.Get (0)->GetDevice (0));
++ NS_ASSERT (dev != NULL);
++ PointerValue ptr;
++ dev->GetAttribute ("Mac",ptr);
++ Ptr<AdhocWifiMac> mac = ptr.Get<AdhocWifiMac> ();
++ NS_ASSERT (mac != NULL);
++ mac->GetAttribute ("DcaTxop",ptr);
++ Ptr<DcaTxop> dca = ptr.Get<DcaTxop> ();
++ NS_ASSERT (dca != NULL);
++ Ptr<WifiMacQueue> queue = dca->GetQueue ();
++ NS_ASSERT (queue != NULL);
++ NS_LOG_INFO ("Queue size: " << queue->GetSize ());
++ Simulator::Schedule (Seconds (2.5), &printQueueSize, queue);
++
+ // Traces changes to the Wifi MAC queue
+ Config::ConnectWithoutContext ("/$ns3::NodeListPriv/NodeList/0/$ns3::Node/DeviceList/0/$ns3::WifiNetDevice/Mac/$ns3::AdhocWifiMac/DcaTxop/$ns3::DcaTxop/Queue/$ns3::WifiMacQueue/WifiMacQueueSizeTrace",
+ MakeCallback (&QueueSizeTracer));