blob: 928a76627c7a0ffdb33525db4bb6cc1cf89a02e8 [file] [log] [blame]
Alexander Afanasyevf4e24522013-06-24 14:11:57 -07001/* -*- 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 Afanasyevaa84fae2013-07-27 12:01:37 -070026#include "ns3/nstime.h"
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070027#include "ns3/ipv4-address.h"
28
29namespace ns3 {
30
31class Node;
32class NodeContainer;
33class Channel;
34
35namespace ndn {
36
37/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070038 * @ingroup ndn-helpers
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070039 * @brief Helper for NDN IP-based face creation
40 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041class IpFacesHelper {
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070042public:
43 /**
44 * @brief Install IpFaceStack interface on a node
45 * @param node Node to install IpFaceStack interface
46 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070047 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048 Install(Ptr<Node> node);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070049
50 /**
51 * @brief Install IpFaceStack interface on nodes
52 * @param nodes NodeContainer to install IpFaceStack interface
53 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070054 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080055 Install(const NodeContainer& nodes);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070056
57 /**
58 * @brief Install IpFaceStack interface on all nodes
59 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070060 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080061 InstallAll();
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070062
63 /**
64 * @brief Create TCP face
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080065 * @param when Time when to create face (use `Seconds (0)' if face should be created right
66 *away)
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070067 * @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 Afanasyevf4e24522013-06-24 14:11:57 -070077 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070078 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080079 CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
80 int16_t metric = 1);
Alexander Afanasyevd573af22013-07-27 12:57:08 -070081
82 /**
83 * @brief Create TCP face
84 */
85 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086 CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
87 int16_t metric = 1);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070088};
89
90} // namespace ndn
91} // namespace ns3
92
93#endif // NDN_IP_FACES_HELPER_H