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" |
Ilya Moiseenko | 82b8eea | 2011-11-02 23:08:47 -0700 | [diff] [blame] | 25 | #include "ns3/ccnx-bestroute-strategy.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 26 | #include "ccnx-forwarding-helper.h" |
| 27 | |
| 28 | namespace ns3 { |
| 29 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 30 | CcnxForwardingHelper::CcnxForwardingHelper() |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 31 | { |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 32 | m_strategy = Ccnx::NDN_FLOODING; |
| 33 | } |
| 34 | |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame^] | 35 | CcnxForwardingHelper::CcnxForwardingHelper (Ccnx::ForwardingStrategy strategy) |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 36 | { |
| 37 | m_strategy = strategy; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 38 | } |
| 39 | |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 40 | void |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame^] | 41 | CcnxForwardingHelper::SetForwarding (Ptr<Ccnx> ccnx) const |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 42 | { |
| 43 | if(m_strategy == Ccnx::NDN_FLOODING) |
| 44 | { |
| 45 | Ptr<CcnxFloodingStrategy> ccnxForwarding = CreateObject<CcnxFloodingStrategy> (); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 46 | ccnx->SetForwardingStrategy (ccnxForwarding); |
| 47 | } |
| 48 | else if(m_strategy == Ccnx::NDN_BESTROUTE) |
Ilya Moiseenko | 82b8eea | 2011-11-02 23:08:47 -0700 | [diff] [blame] | 49 | { |
| 50 | Ptr<CcnxBestRouteStrategy> ccnxForwarding = CreateObject<CcnxBestRouteStrategy> (); |
Ilya Moiseenko | 82b8eea | 2011-11-02 23:08:47 -0700 | [diff] [blame] | 51 | ccnx->SetForwardingStrategy (ccnxForwarding); |
| 52 | } |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 53 | else if (m_strategy == Ccnx::NDN_RANKING) |
| 54 | {} |
| 55 | } |
Alexander Afanasyev | 19426ef | 2011-11-23 20:55:28 -0800 | [diff] [blame^] | 56 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 57 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 67 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 76 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 77 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 83 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 88 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 89 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 97 | |
Alexander Afanasyev | cf133f0 | 2011-09-06 12:13:48 -0700 | [diff] [blame] | 98 | // 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 Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 107 | |
| 108 | } // namespace ns3 |