Adding options to enable caching of unsolicited (e.g., overheard over broadcast media) data packets
diff --git a/examples/car2car-wifi.cc b/examples/car2car-wifi.cc
index 417ea2d..58db981 100644
--- a/examples/car2car-wifi.cc
+++ b/examples/car2car-wifi.cc
@@ -13,30 +13,47 @@
int
main (int argc, char *argv[])
{
+ // disable fragmentation
+ Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
+ Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
+
+ // vanet hacks to CcnxL3Protocol
+ Config::SetDefault ("ns3::CcnxL3Protocol::EnableNACKs", StringValue ("false"));
+ Config::SetDefault ("ns3::CcnxL3Protocol::CacheUnsolicitedData", StringValue ("true"));
+
CommandLine cmd;
cmd.Parse (argc,argv);
+
+ //////////////////////
+ //////////////////////
+ //////////////////////
+
+ WifiHelper wifi = WifiHelper::Default ();
+ // wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
+ wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
+ wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
+ "DataMode", StringValue ("OfdmRate54Mbps"));
+
+ YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
+
+ YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
+ wifiPhy.SetChannel (wifiChannel.Create ());
+
+ NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
+ wifiMac.SetType("ns3::AdhocWifiMac");
+
+ //////////////////////
+ //////////////////////
+ //////////////////////
+
+
NodeContainer producerNode;
producerNode.Create (1);
NodeContainer consumerNodes;
consumerNodes.Create(2);
- YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
- YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
- phy.SetChannel (channel.Create ());
- WifiHelper wifi = WifiHelper::Default ();
- wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
- NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
- /*Ssid ssid = Ssid ("ns-3-ssid");
- mac.SetType ("ns3::StaWifiMac",
- "Ssid", SsidValue (ssid),
- "ActiveProbing", BooleanValue (false));*/
- mac.SetType("ns3::AdhocWifiMac");
- NetDeviceContainer producerDevices;
- producerDevices = wifi.Install (phy, mac, producerNode);
- /*mac.SetType ("ns3::ApWifiMac",
- "Ssid", SsidValue (ssid));
- */
- NetDeviceContainer consumerDevices;
- consumerDevices = wifi.Install (phy, mac, consumerNodes);
+
+ wifi.Install (wifiPhy, wifiMac, producerNode);
+ wifi.Install (wifiPhy, wifiMac, consumerNodes);
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::HighwayPositionAllocator",
@@ -45,14 +62,13 @@
"Length", DoubleValue(1000.0));
mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
- "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0)));
+ "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
mobility.Install (producerNode);
mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
- "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0)));
+ "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
mobility.Install (consumerNodes);
-
// 2. Install CCNx stack
NS_LOG_INFO ("Installing CCNx stack");
@@ -66,7 +82,7 @@
CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
consumerHelper.SetPrefix ("/");
consumerHelper.SetAttribute ("Frequency", StringValue ("1"));
- ApplicationContainer consumers = consumerHelper.Install (consumerNodes);
+ ApplicationContainer consumers = consumerHelper.Install (consumerNodes.Get (0));
// consumers.Start (Seconds (0.0));
// consumers.Stop (finishTime);
diff --git a/model/ccnx-content-store.cc b/model/ccnx-content-store.cc
index b0c4858..881c881 100644
--- a/model/ccnx-content-store.cc
+++ b/model/ccnx-content-store.cc
@@ -153,7 +153,7 @@
boost::tuple<Ptr<Packet>, Ptr<const CcnxContentObjectHeader>, Ptr<const Packet> >
CcnxContentStore::Lookup (Ptr<const CcnxInterestHeader> interest)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this << interest->GetName ());
CcnxContentStoreContainer::type::iterator it = m_contentStore.get<i_prefix> ().find (interest->GetName ());
if (it != m_contentStore.end ())
{
@@ -170,7 +170,7 @@
void
CcnxContentStore::Add (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet)
{
- NS_LOG_FUNCTION_NOARGS ();
+ NS_LOG_FUNCTION (this << header->GetName ());
CcnxContentStoreContainer::type::iterator it = m_contentStore.get<i_prefix> ().find (header->GetName ());
if (it == m_contentStore.end ())
{ // add entry to the top
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index 87c0881..da7ad29 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -79,6 +79,10 @@
BooleanValue (true),
MakeBooleanAccessor (&CcnxL3Protocol::m_nacksEnabled),
MakeBooleanChecker ())
+ .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
+ BooleanValue (false),
+ MakeBooleanAccessor (&CcnxL3Protocol::m_cacheUnsolicitedData),
+ MakeBooleanChecker ())
;
return tid;
}
@@ -559,11 +563,18 @@
{
// Unsolicited data, but we're interested in it... should we get it?
// Potential hole for attacks
-
- NS_LOG_ERROR ("Node "<< m_node->GetId() <<
- ". PIT entry for "<< header->GetName ()<<" is valid, "
- "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
+ if (m_cacheUnsolicitedData)
+ {
+ // Optimistically add or update entry in the content store
+ m_contentStore->Add (header, payload);
+ }
+ else
+ {
+ NS_LOG_ERROR ("Node "<< m_node->GetId() <<
+ ". PIT entry for "<< header->GetName ()<<" is valid, "
+ "but outgoing entry for interface "<< boost::cref(*incomingFace) <<" doesn't exist\n");
+ }
// ignore unsolicited data
return;
}
@@ -598,11 +609,19 @@
}
catch (CcnxPitEntryNotFound)
{
- // 2. Drop data packet if PIT entry is not found
- // (unsolicited data packets should not "poison" content store)
+ if (m_cacheUnsolicitedData)
+ {
+ // Optimistically add or update entry in the content store
+ m_contentStore->Add (header, payload);
+ }
+ else
+ {
+ // Drop data packet if PIT entry is not found
+ // (unsolicited data packets should not "poison" content store)
- //drop dulicated or not requested data packet
- m_dropData (header, payload, UNSOLICITED, incomingFace);
+ //drop dulicated or not requested data packet
+ m_dropData (header, payload, UNSOLICITED, incomingFace);
+ }
return; // do not process unsoliced data packets
}
}
@@ -611,6 +630,7 @@
CcnxL3Protocol::GiveUpInterest (const CcnxPitEntry &pitEntry,
Ptr<CcnxInterestHeader> header)
{
+ NS_LOG_FUNCTION (this << &pitEntry);
if (m_nacksEnabled)
{
Ptr<Packet> packet = Create<Packet> ();
@@ -619,6 +639,7 @@
BOOST_FOREACH (const CcnxPitEntryIncomingFace &incoming, pitEntry.m_incoming)
{
+ NS_LOG_DEBUG ("Send NACK for " << boost::cref (header->GetName ()) << " to " << boost::cref (*incoming.m_face));
incoming.m_face->Send (packet->Copy ());
m_outNacks (header, incoming.m_face);
diff --git a/model/ccnx-l3-protocol.h b/model/ccnx-l3-protocol.h
index 1da29b7..ba4fcaa 100644
--- a/model/ccnx-l3-protocol.h
+++ b/model/ccnx-l3-protocol.h
@@ -209,6 +209,7 @@
Ptr<CcnxContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
bool m_nacksEnabled;
+ bool m_cacheUnsolicitedData;
// Time m_bucketLeakInterval;
// EventId m_bucketLeakEvent;