NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-ip-face-stack.h
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_FACE_STACK_H
23 #define NDN_IP_FACE_STACK_H
24 
25 #include "ns3/application.h"
26 #include "ns3/socket.h"
27 #include "ns3/inet-socket-address.h"
28 #include "ns3/ptr.h"
29 #include "ns3/ndn-name.h"
30 
31 #include <map>
32 
33 namespace ns3 {
34 
35 class Packet;
36 
37 namespace ndn {
38 
39 class Face;
40 class TcpFace;
41 class UdpFace;
42 
49 class IpFaceStack: public Object
50 {
51 public:
52  static TypeId GetTypeId ();
53 
57  IpFaceStack ();
58  virtual ~IpFaceStack ();
59 
63  Ptr<TcpFace>
64  GetTcpFaceByAddress (const Ipv4Address &addr);
65 
69  void
70  DestroyTcpFace (Ptr<TcpFace> face);
71 
75  Ptr<UdpFace>
76  GetUdpFaceByAddress (const Ipv4Address &addr);
77 
83  Ptr<TcpFace>
84  CreateOrGetTcpFace (Ipv4Address address,
85  Callback< void, Ptr<Face> > onCreate = NULL_CREATE_CALLBACK);
86 
92  Ptr<UdpFace>
93  CreateOrGetUdpFace (Ipv4Address address);
94 
95 protected:
96  void
97  NotifyNewAggregate ();
98 
99 private:
100  void
101  StartServer ();
102 
103  bool
104  OnTcpConnectionRequest (Ptr< Socket > sock, const Address &addr);
105 
106  void
107  OnTcpConnectionAccept (Ptr< Socket > sock, const Address &addr);
108 
109  void
110  OnTcpConnectionClosed (Ptr< Socket > sock);
111 
112  void
113  OnUdpPacket (Ptr< Socket > sock);
114 
115 public:
116  const static Callback< void, Ptr<Face> > NULL_CREATE_CALLBACK;
117 
118 protected:
119  Ptr<Node> m_node;
120 
121  bool m_enableTcp;
122  bool m_enableUdp;
123 
124  Ptr<Socket> m_tcpServer;
125  Ptr<Socket> m_udpServer;
126 
127  typedef std::map< Ipv4Address, Ptr<TcpFace> > TcpFaceMap;
128  typedef std::map< Ipv4Address, Ptr<UdpFace> > UdpFaceMap;
129  TcpFaceMap m_tcpFaceMap;
130  UdpFaceMap m_udpFaceMap;
131 };
132 
133 } // namespace ndn
134 } // namespace ns3
135 
136 #endif // NDN_IP_FACE_STACK_H
Ptr< UdpFace > GetUdpFaceByAddress(const Ipv4Address &addr)
Lookup UdpFace for a given address.
Application that provides functionality of creating IP-based faces on NDN nodes.
Ptr< TcpFace > GetTcpFaceByAddress(const Ipv4Address &addr)
Lookup TcpFace for a given address.
void DestroyTcpFace(Ptr< TcpFace > face)
Destroy TcpFace, e.g., after TCP connection got dropped.
Ptr< TcpFace > CreateOrGetTcpFace(Ipv4Address address, Callback< void, Ptr< Face > > onCreate=NULL_CREATE_CALLBACK)
Method allowing creation and lookup of faces.
IpFaceStack()
Default constructor.
Ptr< UdpFace > CreateOrGetUdpFace(Ipv4Address address)
Method allowing creation and lookup of faces.