Finalizing interest limits. Now everything seem to work.
To work correctly, a lot of parameters have to be adjusted, including average
contentObject size, averageRTT, queues on nodes.
diff --git a/examples/ccnx-grid.cc b/examples/ccnx-grid.cc
index c183413..d0c2882 100644
--- a/examples/ccnx-grid.cc
+++ b/examples/ccnx-grid.cc
@@ -63,8 +63,9 @@
main (int argc, char *argv[])
{
Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("1ms"));
+ Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
Config::SetDefault ("ns3::CcnxConsumer::OffTime", StringValue ("1s"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
Packet::EnableChecking();
Packet::EnablePrinting();
@@ -88,8 +89,9 @@
// Install CCNx stack
NS_LOG_INFO ("Installing CCNx stack");
CcnxStackHelper ccnxHelper;
+ // ccnxHelper.SetForwardingStrategy ("ns3::CcnxBestRouteStrategy");
ccnxHelper.SetForwardingStrategy ("ns3::CcnxFloodingStrategy");
- ccnxHelper.EnableLimits (true);
+ ccnxHelper.EnableLimits (true, Seconds(0.1));
ccnxHelper.InstallAll ();
// Install IP stack (necessary to populate FIB)
@@ -118,7 +120,7 @@
// consumers.Start (Seconds (0.0));
// consumers.Stop (finishTime);
- CcnxProducerHelper producerHelper (prefix.str (),120);
+ CcnxProducerHelper producerHelper (prefix.str (),1024);
ApplicationContainer producers = producerHelper.Install (producer);
// producers.Start(Seconds(0.0));
diff --git a/examples/content-object-example.cc b/examples/content-object-example.cc
index fa9700e..8272e86 100644
--- a/examples/content-object-example.cc
+++ b/examples/content-object-example.cc
@@ -19,38 +19,38 @@
int
main (int argc, char *argv[])
{
- LogComponentEnable ("ContentObjectHeaderExample", LOG_ALL);
- LogComponentEnable ("Packet", LOG_ALL);
+ LogComponentEnable ("ContentObjectHeaderExample", LOG_ALL);
+ LogComponentEnable ("Packet", LOG_ALL);
- NS_LOG_INFO ("Test started");
+ NS_LOG_INFO ("Test started");
- Packet::EnablePrinting ();
- Packet::EnableChecking ();
- Packet packet (10);
+ Packet::EnablePrinting ();
+ Packet::EnableChecking ();
+ Packet packet (10);
- CcnxContentObjectHeader header;
- CcnxContentObjectTail trailer;
+ CcnxContentObjectHeader header;
+ CcnxContentObjectTail trailer;
- Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
- (*testname) ("1");
- header.SetName(testname);
+ Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
+ (*testname) ("1");
+ header.SetName(testname);
- NS_LOG_INFO ("Source: \n" << header << trailer);
+ NS_LOG_INFO ("Source: \n" << header << trailer);
- packet.AddHeader (header);
- packet.AddTrailer (trailer);
+ packet.AddHeader (header);
+ packet.AddTrailer (trailer);
- // NS_LOG_INFO ("Deserialized packet: \n" << packet);
+ // NS_LOG_INFO ("Deserialized packet: \n" << packet);
- NS_LOG_INFO ("Removing and deserializing individual headers");
+ NS_LOG_INFO ("Removing and deserializing individual headers");
- CcnxContentObjectHeader dst_header;
- CcnxContentObjectTail dst_trailer;
+ CcnxContentObjectHeader dst_header;
+ CcnxContentObjectTail dst_trailer;
- packet.RemoveHeader (dst_header);
- packet.RemoveTrailer (dst_trailer);
+ packet.RemoveHeader (dst_header);
+ packet.RemoveTrailer (dst_trailer);
- NS_LOG_INFO ("Target: \n" << dst_header << dst_trailer);
+ NS_LOG_INFO ("Target: \n" << dst_header << dst_trailer);
- return 0;
+ return 0;
}
diff --git a/examples/packet-sizes.cc b/examples/packet-sizes.cc
new file mode 100644
index 0000000..041cac6
--- /dev/null
+++ b/examples/packet-sizes.cc
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ns3/core-module.h"
+#include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-header-helper.h"
+#include "ns3/header.h"
+#include "ns3/ccnx-name-components.h"
+#include "ns3/nstime.h"
+#include "ns3/string.h"
+#include "ns3/buffer.h"
+#include "ns3/packet.h"
+#include "ns3/log.h"
+
+using namespace ns3;
+#include <fstream>
+
+NS_LOG_COMPONENT_DEFINE ("PacketSizes");
+
+int
+main (int argc, char *argv[])
+{
+ NS_LOG_INFO ("Test started");
+
+ uint32_t size = 1024;
+ std::string namePrefixStr = "/1";
+ uint32_t start=0, end=100;
+
+ CommandLine cmd;
+ cmd.AddValue ("size", "ContentObject payload size", size);
+ cmd.AddValue ("name", "Prefix", namePrefixStr);
+ cmd.AddValue ("start", "Range start", start);
+ cmd.AddValue ("end", "Range end", end);
+ cmd.Parse (argc, argv);
+
+ CcnxNameComponents namePrefixValue;
+ std::istringstream is (namePrefixStr);
+ is >> namePrefixValue;
+
+ Packet::EnablePrinting ();
+ Packet::EnableChecking ();
+
+ double interestSize = 0.0;
+ double nackSize = 0.0;
+ double contentObjectSize = 0.0;
+
+ double progress = start;
+ double step = (end-start)/100.0;
+
+ progress += step;
+
+ NS_LOG_INFO (progress << ", " << step);
+
+ for (uint32_t currentSize = start; currentSize < end; currentSize++)
+ {
+ Ptr<CcnxNameComponents> namePrefix = Create<CcnxNameComponents> (namePrefixValue);
+ namePrefix->Add (currentSize);
+
+ NS_LOG_LOGIC (boost::cref (*namePrefix));
+
+ // Interest Packet (doesn't have a payload)
+ CcnxInterestHeader interestHeader;
+
+ interestHeader.SetName (namePrefix);
+ interestHeader.SetInterestLifetime (Seconds (4.0));
+ interestHeader.SetNonce (10101010);
+
+ Ptr<Packet> interestPacket = Create<Packet> (0);
+ interestPacket->AddHeader (interestHeader);
+
+ interestSize = interestSize + (1.0*interestPacket->GetSize () - interestSize) / (currentSize - start + 1);
+
+
+
+ // NACK
+ interestHeader.SetNack (CcnxInterestHeader::NACK_GIVEUP_PIT);
+
+ Ptr<Packet> nackPacket = Create<Packet> (0);
+ nackPacket->AddHeader (interestHeader);
+
+ nackSize = nackSize + (1.0*nackPacket->GetSize () - nackSize) / (currentSize - start + 1);
+
+ // ContentObject
+ CcnxContentObjectHeader coHeader;
+ CcnxContentObjectTail coTrailer;
+
+ coHeader.SetName (namePrefix);
+
+ Ptr<Packet> contentObject = Create<Packet> (size);
+
+ contentObject->AddHeader (coHeader);
+ contentObject->AddTrailer (coTrailer);
+
+ contentObjectSize = contentObjectSize + (1.0*contentObject->GetSize () - contentObjectSize ) / (currentSize - start + 1);
+
+ NS_LOG_DEBUG (interestSize << ", " << nackSize << ", " << contentObjectSize);
+
+ if (currentSize >= progress)
+ {
+ NS_LOG_INFO ("Current: " << currentSize << "/" << end);
+ progress += step;
+ }
+ }
+
+ NS_LOG_INFO ("Avg interest: " << interestSize << ", avg nack: " << nackSize << ", avg contentObject: " << contentObjectSize);
+
+ return 0;
+}