blob: 6a8d3fb28bab7dfb045deb640d05d9eac02f44dd [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"
Ilya Moiseenko82b8eea2011-11-02 23:08:47 -070025#include "ns3/ccnx-bestroute-strategy.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070026#include "ccnx-forwarding-helper.h"
27
28namespace ns3 {
29
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070030CcnxForwardingHelper::CcnxForwardingHelper()
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070031{
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070032 m_strategy = Ccnx::NDN_FLOODING;
33}
34
35CcnxForwardingHelper::CcnxForwardingHelper(Ccnx::ForwardingStrategy strategy)
36{
37 m_strategy = strategy;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070038}
39
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070040CcnxForwardingHelper::~CcnxForwardingHelper ()
41{
42
43}
44
45void
Ilya Moiseenko9181afd2011-10-28 13:06:14 -070046CcnxForwardingHelper::SetForwarding(Ptr<Ccnx> ccnx, Ptr<CcnxPit> pit) const
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070047{
48 if(m_strategy == Ccnx::NDN_FLOODING)
49 {
50 Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> ();
Ilya Moiseenko9181afd2011-10-28 13:06:14 -070051 //ccnxForwarding->SetCcnx(ccnx);
52 ccnxForwarding->SetPit(pit);
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070053 ccnx->SetForwardingStrategy (ccnxForwarding);
54 }
55 else if(m_strategy == Ccnx::NDN_BESTROUTE)
Ilya Moiseenko82b8eea2011-11-02 23:08:47 -070056 {
57 Ptr<CcnxBestRouteStrategy> ccnxForwarding = CreateObject<CcnxBestRouteStrategy> ();
58 //ccnxForwarding->SetCcnx(ccnx);
59 ccnxForwarding->SetPit(pit);
60 ccnx->SetForwardingStrategy (ccnxForwarding);
61 }
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070062 else if (m_strategy == Ccnx::NDN_RANKING)
63 {}
64}
65
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070066// void
67// CcnxForwardingHelper::PrintForwardingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
68// {
69// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
70// {
71// Ptr<Node> node = NodeList::GetNode (i);
72// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
73// }
74// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070075
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070076// void
77// CcnxForwardingHelper::PrintForwardingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
78// {
79// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
80// {
81// Ptr<Node> node = NodeList::GetNode (i);
82// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
83// }
84// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070085
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070086// void
87// CcnxForwardingHelper::PrintForwardingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
88// {
89// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
90// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070091
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070092// void
93// CcnxForwardingHelper::PrintForwardingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
94// {
95// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
96// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070098// void
99// CcnxForwardingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
100// {
101// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
102// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
103// NS_ASSERT (rp);
104// rp->PrintForwardingTable (stream);
105// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700107// void
108// CcnxForwardingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
109// {
110// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
111// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
112// NS_ASSERT (rp);
113// rp->PrintForwardingTable (stream);
114// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
115// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700116
117} // namespace ns3