Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013 University of California, Los Angeles |
| 4 | * Alexander Afanasyev |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation; |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | * |
| 19 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 20 | */ |
| 21 | |
| 22 | #ifndef NDN_IP_FACES_HELPER_H |
| 23 | #define NDN_IP_FACES_HELPER_H |
| 24 | |
Spyridon Mastorakis | 53e922f | 2014-10-17 17:29:26 -0700 | [diff] [blame^] | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" |
| 26 | |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 27 | #include "ns3/ptr.h" |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 28 | #include "ns3/nstime.h" |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 29 | #include "ns3/ipv4-address.h" |
| 30 | |
| 31 | namespace ns3 { |
| 32 | |
| 33 | class Node; |
| 34 | class NodeContainer; |
| 35 | class Channel; |
| 36 | |
| 37 | namespace ndn { |
| 38 | |
| 39 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 40 | * @ingroup ndn-helpers |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 41 | * @brief Helper for NDN IP-based face creation |
| 42 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 43 | class IpFacesHelper { |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 44 | public: |
| 45 | /** |
| 46 | * @brief Install IpFaceStack interface on a node |
| 47 | * @param node Node to install IpFaceStack interface |
| 48 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 49 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 50 | Install(Ptr<Node> node); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @brief Install IpFaceStack interface on nodes |
| 54 | * @param nodes NodeContainer to install IpFaceStack interface |
| 55 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 56 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 57 | Install(const NodeContainer& nodes); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * @brief Install IpFaceStack interface on all nodes |
| 61 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 62 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 63 | InstallAll(); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * @brief Create TCP face |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 67 | * @param when Time when to create face (use `Seconds (0)' if face should be created right |
| 68 | *away) |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 69 | * @param node Node to add TCP face (will initiate connection) |
| 70 | * @param address IP address to connect (using standard 9695 port) |
| 71 | * @param prefix Prefix to associate with the face |
| 72 | * @param metric Metric that will be assigned to the face |
| 73 | * |
| 74 | * This call schedules connection initiation and after successful connection it will add new face |
| 75 | * to NDN stack and add the requested route |
| 76 | * |
| 77 | * If face has been already created before (same IP address), then this call will simply |
| 78 | * update FIB with requested prefix |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 79 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 80 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 81 | CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix, |
| 82 | int16_t metric = 1); |
Alexander Afanasyev | d573af2 | 2013-07-27 12:57:08 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
| 85 | * @brief Create TCP face |
| 86 | */ |
| 87 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 88 | CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix, |
| 89 | int16_t metric = 1); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } // namespace ndn |
| 93 | } // namespace ns3 |
| 94 | |
| 95 | #endif // NDN_IP_FACES_HELPER_H |