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 | |
| 25 | #include "ns3/ptr.h" |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 26 | #include "ns3/nstime.h" |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 27 | #include "ns3/ipv4-address.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | |
| 31 | class Node; |
| 32 | class NodeContainer; |
| 33 | class Channel; |
| 34 | |
| 35 | namespace ndn { |
| 36 | |
| 37 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 38 | * @ingroup ndn-helpers |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 39 | * @brief Helper for NDN IP-based face creation |
| 40 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 41 | class IpFacesHelper { |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 42 | public: |
| 43 | /** |
| 44 | * @brief Install IpFaceStack interface on a node |
| 45 | * @param node Node to install IpFaceStack interface |
| 46 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 47 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 48 | Install(Ptr<Node> node); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * @brief Install IpFaceStack interface on nodes |
| 52 | * @param nodes NodeContainer to install IpFaceStack interface |
| 53 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 54 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 55 | Install(const NodeContainer& nodes); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * @brief Install IpFaceStack interface on all nodes |
| 59 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 60 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 61 | InstallAll(); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * @brief Create TCP face |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 65 | * @param when Time when to create face (use `Seconds (0)' if face should be created right |
| 66 | *away) |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 67 | * @param node Node to add TCP face (will initiate connection) |
| 68 | * @param address IP address to connect (using standard 9695 port) |
| 69 | * @param prefix Prefix to associate with the face |
| 70 | * @param metric Metric that will be assigned to the face |
| 71 | * |
| 72 | * This call schedules connection initiation and after successful connection it will add new face |
| 73 | * to NDN stack and add the requested route |
| 74 | * |
| 75 | * If face has been already created before (same IP address), then this call will simply |
| 76 | * update FIB with requested prefix |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 77 | */ |
Alexander Afanasyev | aa84fae | 2013-07-27 12:01:37 -0700 | [diff] [blame] | 78 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 79 | CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix, |
| 80 | int16_t metric = 1); |
Alexander Afanasyev | d573af2 | 2013-07-27 12:57:08 -0700 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * @brief Create TCP face |
| 84 | */ |
| 85 | static void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix, |
| 87 | int16_t metric = 1); |
Alexander Afanasyev | f4e2452 | 2013-06-24 14:11:57 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | } // namespace ndn |
| 91 | } // namespace ns3 |
| 92 | |
| 93 | #endif // NDN_IP_FACES_HELPER_H |