blob: b167437bf4b1ce16cf427701e540583881dd94fa [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
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070025#include "ns3/ndnSIM/model/ndn-common.hpp"
26
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070027#include "ns3/ptr.h"
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070028#include "ns3/nstime.h"
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070029#include "ns3/ipv4-address.h"
30
31namespace ns3 {
32
33class Node;
34class NodeContainer;
35class Channel;
36
37namespace ndn {
38
39/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070040 * @ingroup ndn-helpers
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070041 * @brief Helper for NDN IP-based face creation
42 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080043class IpFacesHelper {
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070044public:
45 /**
46 * @brief Install IpFaceStack interface on a node
47 * @param node Node to install IpFaceStack interface
48 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070049 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 Install(Ptr<Node> node);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070051
52 /**
53 * @brief Install IpFaceStack interface on nodes
54 * @param nodes NodeContainer to install IpFaceStack interface
55 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070056 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057 Install(const NodeContainer& nodes);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070058
59 /**
60 * @brief Install IpFaceStack interface on all nodes
61 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070062 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063 InstallAll();
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070064
65 /**
66 * @brief Create TCP face
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080067 * @param when Time when to create face (use `Seconds (0)' if face should be created right
68 *away)
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070069 * @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 Afanasyevf4e24522013-06-24 14:11:57 -070079 */
Alexander Afanasyevaa84fae2013-07-27 12:01:37 -070080 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081 CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
82 int16_t metric = 1);
Alexander Afanasyevd573af22013-07-27 12:57:08 -070083
84 /**
85 * @brief Create TCP face
86 */
87 static void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080088 CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
89 int16_t metric = 1);
Alexander Afanasyevf4e24522013-06-24 14:11:57 -070090};
91
92} // namespace ndn
93} // namespace ns3
94
95#endif // NDN_IP_FACES_HELPER_H