Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 2 | /* |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 4 | * |
| 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 Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 19 | */ |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 21 | #include "ns3/node.h" |
| 22 | #include "ns3/node-list.h" |
| 23 | #include "ns3/simulator.h" |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 24 | #include "ns3/ccnx-forwarding-strategy.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 25 | #include "ccnx-forwarding-helper.h" |
| 26 | |
| 27 | namespace ns3 { |
| 28 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 29 | CcnxForwardingHelper::CcnxForwardingHelper() |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 30 | { |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 31 | m_strategy = Ccnx::NDN_FLOODING; |
| 32 | } |
| 33 | |
| 34 | CcnxForwardingHelper::CcnxForwardingHelper(Ccnx::ForwardingStrategy strategy) |
| 35 | { |
| 36 | m_strategy = strategy; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 39 | CcnxForwardingHelper::~CcnxForwardingHelper () |
| 40 | { |
| 41 | |
| 42 | } |
| 43 | |
| 44 | void |
Ilya Moiseenko | 9181afd | 2011-10-28 13:06:14 -0700 | [diff] [blame] | 45 | CcnxForwardingHelper::SetForwarding(Ptr<Ccnx> ccnx, Ptr<CcnxPit> pit) const |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 46 | { |
| 47 | if(m_strategy == Ccnx::NDN_FLOODING) |
| 48 | { |
| 49 | Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> (); |
Ilya Moiseenko | 9181afd | 2011-10-28 13:06:14 -0700 | [diff] [blame] | 50 | //ccnxForwarding->SetCcnx(ccnx); |
| 51 | ccnxForwarding->SetPit(pit); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 52 | 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 Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 60 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 69 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 70 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 79 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 80 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 85 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 86 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 91 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 92 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 100 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 101 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 110 | |
| 111 | } // namespace ns3 |