blob: 31ffecb18377f213cb9f9f23ceaa3bbd895d991b [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
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080035CcnxForwardingHelper::CcnxForwardingHelper (Ccnx::ForwardingStrategy strategy)
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070036{
37 m_strategy = strategy;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070038}
39
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070040void
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080041CcnxForwardingHelper::SetForwarding (Ptr<Ccnx> ccnx) const
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070042{
43 if(m_strategy == Ccnx::NDN_FLOODING)
44 {
45 Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> ();
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070046 ccnx->SetForwardingStrategy (ccnxForwarding);
47 }
48 else if(m_strategy == Ccnx::NDN_BESTROUTE)
Ilya Moiseenko82b8eea2011-11-02 23:08:47 -070049 {
50 Ptr<CcnxBestRouteStrategy> ccnxForwarding = CreateObject<CcnxBestRouteStrategy> ();
Ilya Moiseenko82b8eea2011-11-02 23:08:47 -070051 ccnx->SetForwardingStrategy (ccnxForwarding);
52 }
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070053 else if (m_strategy == Ccnx::NDN_RANKING)
54 {}
55}
Alexander Afanasyev19426ef2011-11-23 20:55:28 -080056
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070057// void
58// CcnxForwardingHelper::PrintForwardingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
59// {
60// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
61// {
62// Ptr<Node> node = NodeList::GetNode (i);
63// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
64// }
65// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070066
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070067// void
68// CcnxForwardingHelper::PrintForwardingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
69// {
70// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
71// {
72// Ptr<Node> node = NodeList::GetNode (i);
73// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
74// }
75// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070077// void
78// CcnxForwardingHelper::PrintForwardingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
79// {
80// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
81// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070082
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070083// void
84// CcnxForwardingHelper::PrintForwardingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
85// {
86// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
87// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070088
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070089// void
90// CcnxForwardingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
91// {
92// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
93// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
94// NS_ASSERT (rp);
95// rp->PrintForwardingTable (stream);
96// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070097
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070098// void
99// CcnxForwardingHelper::PrintEvery (Time printInterval, 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// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
106// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700107
108} // namespace ns3