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-tcp-face.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2013 University of California, Los Angeles
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  */
20 
21 #ifndef NDN_TCP_FACE_H
22 #define NDN_TCP_FACE_H
23 
24 #include "ns3/ndn-face.h"
25 #include "ns3/socket.h"
26 #include "ns3/ptr.h"
27 #include "ns3/callback.h"
28 
29 #include <map>
30 
31 namespace ns3 {
32 namespace ndn {
33 
40 class TcpFace : public Face
41 {
42 public:
43  static TypeId
44  GetTypeId ();
45 
51  TcpFace (Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address);
52  virtual ~TcpFace();
53 
54  void
55  OnTcpConnectionClosed (Ptr<Socket> socket);
56 
57  Ipv4Address
58  GetAddress () const;
59 
60  static Ptr<TcpFace>
61  GetFaceByAddress (const Ipv4Address &addr);
62 
63  void
64  SetCreateCallback (Callback< void, Ptr<Face> > callback);
65 
66  void
67  OnConnect (Ptr<Socket> socket);
68 
70  // methods overloaded from ndn::Face
71  virtual void
72  RegisterProtocolHandlers (const InterestHandler &interestHandler, const DataHandler &dataHandler);
73 
74  virtual void
76 
77  virtual std::ostream&
78  Print (std::ostream &os) const;
79 
80 protected:
81  // also from ndn::Face
82  virtual bool
83  Send (Ptr<Packet> p);
84 
85 private:
86  TcpFace (const TcpFace &);
87  TcpFace& operator= (const TcpFace &);
88 
89  void
90  ReceiveFromTcp (Ptr< Socket > clientSocket);
91 
92 private:
93  Ptr<Socket> m_socket;
94  Ipv4Address m_address;
95  uint32_t m_pendingPacketLength;
96  Callback< void, Ptr<Face> > m_onCreateCallback;
97 };
98 
99 } // namespace ndn
100 } // namespace ns3
101 
102 #endif // NDN_TCP_FACE_H
TcpFace(Ptr< Node > node, Ptr< Socket > socket, Ipv4Address address)
Constructor.
virtual std::ostream & Print(std::ostream &os) const
Print information about the face into the stream.
Virtual class defining NDN face.
Definition: ndn-face.h:58
virtual void UnRegisterProtocolHandlers()
Un-Register callback to call when new packet arrives on the face.
Implementation of TCP/IP NDN face.
Definition: ndn-tcp-face.h:40
Callback< void, Ptr< Face >, Ptr< Interest > > InterestHandler
NDN protocol handlers.
Definition: ndn-face.h:71
virtual bool Send(Ptr< Packet > p)
Send packet down to the stack (towards app or network)
virtual void RegisterProtocolHandlers(const InterestHandler &interestHandler, const DataHandler &dataHandler)
Register callback to call when new packet arrives on the face.