blob: c840d7add677c621ed375ec07c87f36150c3c7b1 [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
45CcnxForwardingHelper::SetForwarding(Ptr<Ccnx> ccnx) const
46{
47 if(m_strategy == Ccnx::NDN_FLOODING)
48 {
49 Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> ();
50 ccnxForwarding->SetCcnx(ccnx);
51 ccnx->SetForwardingStrategy (ccnxForwarding);
52 }
53 else if(m_strategy == Ccnx::NDN_BESTROUTE)
54 {}
55 else if (m_strategy == Ccnx::NDN_RANKING)
56 {}
57}
58
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070059// void
60// CcnxForwardingHelper::PrintForwardingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
61// {
62// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
63// {
64// Ptr<Node> node = NodeList::GetNode (i);
65// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
66// }
67// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070068
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070069// void
70// CcnxForwardingHelper::PrintForwardingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
71// {
72// for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
73// {
74// Ptr<Node> node = NodeList::GetNode (i);
75// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
76// }
77// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070078
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070079// void
80// CcnxForwardingHelper::PrintForwardingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
81// {
82// Simulator::Schedule (printTime, &CcnxForwardingHelper::Print, this, node, stream);
83// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070084
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070085// void
86// CcnxForwardingHelper::PrintForwardingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
87// {
88// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
89// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070090
Alexander Afanasyevcf133f02011-09-06 12:13:48 -070091// void
92// CcnxForwardingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
93// {
94// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
95// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
96// NS_ASSERT (rp);
97// rp->PrintForwardingTable (stream);
98// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070099
Alexander Afanasyevcf133f02011-09-06 12:13:48 -0700100// void
101// CcnxForwardingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
102// {
103// Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
104// Ptr<CcnxForwardingStrategy> rp = ccnx->GetForwardingStrategy ();
105// NS_ASSERT (rp);
106// rp->PrintForwardingTable (stream);
107// Simulator::Schedule (printInterval, &CcnxForwardingHelper::PrintEvery, this, printInterval, node, stream);
108// }
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700109
110} // namespace ns3