NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
ndn-app-face.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2
/*
3
* Copyright (c) 2011 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
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19
* Ilya Moiseenko <iliamo@cs.ucla.edu>
20
*
21
*/
22
23
#include "ndn-app-face.h"
24
25
#include "ns3/log.h"
26
#include "ns3/packet.h"
27
#include "ns3/node.h"
28
#include "ns3/assert.h"
29
#include "ns3/simulator.h"
30
31
#include "ns3/ndn-header-helper.h"
32
#include "ns3/ndn-app.h"
33
34
#include "ndn-interest.h"
35
#include "ndn-data.h"
36
37
NS_LOG_COMPONENT_DEFINE (
"ndn.AppFace"
);
38
39
namespace
ns3 {
40
namespace
ndn {
41
42
NS_OBJECT_ENSURE_REGISTERED (AppFace);
43
44
TypeId
45
AppFace::GetTypeId ()
46
{
47
static
TypeId tid = TypeId (
"ns3::ndn::AppFace"
)
48
.SetParent<
Face
> ()
49
.SetGroupName (
"Ndn"
)
50
;
51
return
tid;
52
}
53
54
AppFace::AppFace (Ptr<App> app)
55
:
Face
(app->GetNode ())
56
, m_app (app)
57
{
58
NS_LOG_FUNCTION (
this
<< app);
59
60
NS_ASSERT (m_app != 0);
61
SetFlags
(
Face::APPLICATION
);
62
}
63
64
AppFace::~AppFace ()
65
{
66
NS_LOG_FUNCTION_NOARGS ();
67
}
68
69
AppFace::AppFace ()
70
: Face (0)
71
{
72
}
73
74
AppFace::AppFace (
const
AppFace &)
75
: Face (0)
76
{
77
}
78
79
AppFace&
80
AppFace::operator= (
const
AppFace &)
81
{
82
return
*((
AppFace
*)0);
83
}
84
85
bool
86
AppFace::SendInterest
(Ptr<const Interest> interest)
87
{
88
NS_LOG_FUNCTION (
this
<< interest);
89
90
if
(!
IsUp
())
91
{
92
return
false
;
93
}
94
95
if
(interest->GetNack () > 0)
96
m_app->OnNack (interest);
97
else
98
m_app->OnInterest (interest);
99
100
return
true
;
101
}
102
103
bool
104
AppFace::SendData
(Ptr<const Data> data)
105
{
106
NS_LOG_FUNCTION (
this
<< data);
107
108
if
(!
IsUp
())
109
{
110
return
false
;
111
}
112
113
m_app->OnData (data);
114
return
true
;
115
}
116
117
std::ostream&
118
AppFace::Print
(std::ostream& os)
const
119
{
120
os <<
"dev=local("
<<
GetId
() <<
")"
;
121
return
os;
122
}
123
124
}
// namespace ndn
125
}
// namespace ns3
126
ns3::ndn::AppFace::SendData
virtual bool SendData(Ptr< const Data > data)
Send out Dat packet through the face.
Definition:
ndn-app-face.cc:104
ns3::ndn::Face::GetId
uint32_t GetId() const
Get face Id.
Definition:
ndn-face.h:314
ns3::ndn::AppFace::Print
virtual std::ostream & Print(std::ostream &os) const
Print information about the face into the stream.
Definition:
ndn-app-face.cc:118
ns3::ndn::Face
Virtual class defining NDN face.
Definition:
ndn-face.h:58
ns3::ndn::Face::APPLICATION
An application face.
Definition:
ndn-face.h:191
ns3::ndn::Face::SetFlags
void SetFlags(uint32_t flags)
Set face flags.
Definition:
ndn-face.cc:243
ns3::ndn::Face::Face
Face(Ptr< Node > node)
Default constructor.
Definition:
ndn-face.cc:69
ns3::ndn::AppFace::SendInterest
virtual bool SendInterest(Ptr< const Interest > interest)
Send out interest through the face.
Definition:
ndn-app-face.cc:86
ns3::ndn::Face::IsUp
bool IsUp() const
Returns true if this face is enabled, false otherwise.
Definition:
ndn-face.h:284
ns3::ndn::AppFace::AppFace
AppFace(Ptr< App > app)
Default constructor.
Definition:
ndn-app-face.cc:54
ndnSIM
model
ndn-app-face.cc
Generated on Mon Jan 19 2015 11:27:04 for ndnSIM by
1.8.7