blob: dfc7905678dd74cd1477960e730561ecce9e2aa5 [file] [log] [blame]
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07002/*
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -07003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070018 * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070019 */
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070020
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070021#include "ns3/node.h"
22#include "ns3/node-list.h"
23#include "ns3/simulator.h"
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070024#include "ns3/ccnx-forwarding-strategy.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070025#include "ccnx-forwarding-helper.h"
26
27namespace ns3 {
28
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070029CcnxForwardingHelper::CcnxForwardingHelper()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070030{
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070031 m_strategy = Ccnx::NDN_FLOODING;
32}
33
34CcnxForwardingHelper::CcnxForwardingHelper(Ccnx::ForwardingStrategy strategy)
35{
36 m_strategy = strategy;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070037}
38
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070039CcnxForwardingHelper::~CcnxForwardingHelper ()
40{
41
42}
43
44void
Ilya Moiseenko9181afd2011-10-28 13:06:14 -070045CcnxForwardingHelper::SetForwarding(Ptr<Ccnx> ccnx, Ptr<CcnxPit> pit) const
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070046{
47 if(m_strategy == Ccnx::NDN_FLOODING)
48 {
49 Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> ();
Ilya Moiseenko9181afd2011-10-28 13:06:14 -070050 //ccnxForwarding->SetCcnx(ccnx);
51 ccnxForwarding->SetPit(pit);
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070052 ccnx->SetForwardingStrategy (ccnxForwarding);
53 }
54 else if(m_strategy == Ccnx::NDN_BESTROUTE)
55 {}
56 else if (m_strategy == Ccnx::NDN_RANKING)
57 {}
58}
59
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070060// void
61// CcnxForwardingHelper::PrintForwardingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
62// {
63// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
64// {
65// Ptr<Node> node = NodeList::GetNode (i);
66// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
67// }
68// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070069
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070070// void
71// CcnxForwardingHelper::PrintForwardingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
72// {
73// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
74// {
75// Ptr<Node> node = NodeList::GetNode (i);
76// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
77// }
78// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070079
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070080// void
81// CcnxForwardingHelper::PrintForwardingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
82// {
83// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
84// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070085
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070086// void
87// CcnxForwardingHelper::PrintForwardingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
88// {
89// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
90// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070092// void
93// CcnxForwardingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
94// {
95// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
96// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
97// NS_ASSERT (rp);
98// rp->PrintForwardingTable (stream);
99// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700100
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700101// void
102// CcnxForwardingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
103// {
104// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
105// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
106// NS_ASSERT (rp);
107// rp->PrintForwardingTable (stream);
108// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
109// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700110
111} // namespace ns3