Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 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 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "ccnx-producer-helper.h" |
Alexander Afanasyev | 0782718 | 2011-12-13 01:07:32 -0800 | [diff] [blame] | 22 | #include "ns3/log.h" |
| 23 | #include "ns3/ccnx-name-components.h" |
| 24 | #include "ns3/uinteger.h" |
| 25 | #include "ns3/names.h" |
| 26 | #include "../apps/ccnx-producer.h" |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 27 | |
| 28 | NS_LOG_COMPONENT_DEFINE ("CcnxProducerHelper"); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ns3 |
| 31 | { |
| 32 | |
Ilya Moiseenko | fb2362f | 2011-10-28 13:08:05 -0700 | [diff] [blame] | 33 | CcnxProducerHelper::CcnxProducerHelper (const std::string &prefix, uint32_t virtualPayloadSize) |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 34 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 35 | m_factory.SetTypeId ("ns3::CcnxProducer"); |
Ilya Moiseenko | fb2362f | 2011-10-28 13:08:05 -0700 | [diff] [blame] | 36 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 37 | CcnxNameComponentsValue prefixValue; |
| 38 | prefixValue.DeserializeFromString (prefix, MakeCcnxNameComponentsChecker ()); |
| 39 | m_factory.Set ("Prefix", prefixValue); |
Ilya Moiseenko | fb2362f | 2011-10-28 13:08:05 -0700 | [diff] [blame] | 40 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 41 | m_factory.Set ("PayloadSize", UintegerValue (virtualPayloadSize)); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void |
| 45 | CcnxProducerHelper::SetAttribute (std::string name, const AttributeValue &value) |
| 46 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 47 | m_factory.Set (name, value); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | ApplicationContainer |
| 51 | CcnxProducerHelper::Install (Ptr<Node> node) |
| 52 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 53 | NS_LOG_FUNCTION(this); |
| 54 | return ApplicationContainer (InstallPriv (node)); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 55 | } |
Ilya Moiseenko | fb2362f | 2011-10-28 13:08:05 -0700 | [diff] [blame] | 56 | |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 57 | ApplicationContainer |
| 58 | CcnxProducerHelper::Install (std::string nodeName) |
| 59 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 60 | Ptr<Node> node = Names::Find<Node> (nodeName); |
| 61 | return ApplicationContainer (InstallPriv (node)); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | ApplicationContainer |
| 65 | CcnxProducerHelper::Install (NodeContainer c) |
| 66 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 67 | ApplicationContainer apps; |
| 68 | for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 69 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 70 | apps.Add (InstallPriv (*i)); |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 73 | return apps; |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 74 | } |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 75 | |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 76 | Ptr<Application> |
| 77 | CcnxProducerHelper::InstallPriv (Ptr<Node> node) |
| 78 | { |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 79 | NS_LOG_INFO ("InstallPriv started"); |
| 80 | Ptr<CcnxProducer> app = m_factory.Create<CcnxProducer> (); |
| 81 | node->AddApplication (app); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 82 | |
Ilya Moiseenko | 332add0 | 2011-12-24 17:21:25 -0800 | [diff] [blame] | 83 | return app; |
Ilya Moiseenko | a121411 | 2011-08-29 13:03:55 -0700 | [diff] [blame] | 84 | } |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 85 | } |