A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
applications
model
packet-sink.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright 2007 University of Washington
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: Tom Henderson (tomhend@u.washington.edu)
19
*/
20
21
#ifndef PACKET_SINK_H
22
#define PACKET_SINK_H
23
24
#include "ns3/application.h"
25
#include "ns3/event-id.h"
26
#include "ns3/ptr.h"
27
#include "ns3/traced-callback.h"
28
#include "ns3/address.h"
29
30
namespace
ns3
{
31
32
class
Address;
33
class
Socket;
34
class
Packet;
35
68
class
PacketSink
:
public
Application
69
{
70
public
:
75
static
TypeId
GetTypeId
(
void
);
76
PacketSink
();
77
78
virtual
~PacketSink
();
79
83
uint64_t
GetTotalRx
()
const
;
84
88
Ptr<Socket>
GetListeningSocket
(
void
)
const
;
89
93
std::list<Ptr<Socket> >
GetAcceptedSockets
(
void
)
const
;
94
95
protected
:
96
virtual
void
DoDispose
(
void
);
97
private
:
98
// inherited from Application base class.
99
virtual
void
StartApplication
(
void
);
// Called at time specified by Start
100
virtual
void
StopApplication
(
void
);
// Called at time specified by Stop
101
106
void
HandleRead
(
Ptr<Socket>
socket);
112
void
HandleAccept
(
Ptr<Socket>
socket,
const
Address
& from);
117
void
HandlePeerClose
(
Ptr<Socket>
socket);
122
void
HandlePeerError
(
Ptr<Socket>
socket);
123
124
// In the case of TCP, each socket accept returns a new socket, so the
125
// listening socket is stored separately from the accepted sockets
126
Ptr<Socket>
m_socket
;
127
std::list<Ptr<Socket> >
m_socketList
;
128
129
Address
m_local
;
130
uint64_t
m_totalRx
;
131
TypeId
m_tid
;
132
134
TracedCallback<Ptr<const Packet>
,
const
Address
&>
m_rxTrace
;
135
137
TracedCallback<Ptr<const Packet>
,
const
Address
&,
const
Address
&>
m_rxTraceWithAddresses
;
138
139
};
140
141
}
// namespace ns3
142
143
#endif
/* PACKET_SINK_H */
144
ns3::Ptr< Socket >
ns3::PacketSink::m_local
Address m_local
Local address to bind to.
Definition:
packet-sink.h:129
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition:
traced-callback.h:62
ns3::PacketSink::GetTotalRx
uint64_t GetTotalRx() const
Definition:
packet-sink.cc:81
ns3::PacketSink::m_rxTrace
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
Definition:
packet-sink.h:134
ns3::PacketSink::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
packet-sink.cc:42
ns3::PacketSink::GetAcceptedSockets
std::list< Ptr< Socket > > GetAcceptedSockets(void) const
Definition:
packet-sink.cc:95
ns3::Address
a polymophic address class
Definition:
address.h:90
ns3::PacketSink::m_rxTraceWithAddresses
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_rxTraceWithAddresses
Callback for tracing the packet Rx events, includes source and destination addresses.
Definition:
packet-sink.h:137
ns3::Application
The base class for all ns3 applications.
Definition:
application.h:60
ns3::PacketSink::HandleRead
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
Definition:
packet-sink.cc:166
ns3::PacketSink::m_tid
TypeId m_tid
Protocol TypeId.
Definition:
packet-sink.h:131
ns3::PacketSink::StopApplication
virtual void StopApplication(void)
Application specific shutdown code.
Definition:
packet-sink.cc:150
ns3::PacketSink::HandlePeerClose
void HandlePeerClose(Ptr< Socket > socket)
Handle an connection close.
Definition:
packet-sink.cc:204
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::PacketSink::m_totalRx
uint64_t m_totalRx
Total bytes received.
Definition:
packet-sink.h:130
ns3::PacketSink::~PacketSink
virtual ~PacketSink()
Definition:
packet-sink.cc:76
ns3::PacketSink::PacketSink
PacketSink()
Definition:
packet-sink.cc:69
ns3::PacketSink::m_socketList
std::list< Ptr< Socket > > m_socketList
the accepted sockets
Definition:
packet-sink.h:127
ns3::PacketSink::HandleAccept
void HandleAccept(Ptr< Socket > socket, const Address &from)
Handle an incoming connection.
Definition:
packet-sink.cc:215
ns3::PacketSink::HandlePeerError
void HandlePeerError(Ptr< Socket > socket)
Handle an connection error.
Definition:
packet-sink.cc:209
ns3::PacketSink::GetListeningSocket
Ptr< Socket > GetListeningSocket(void) const
Definition:
packet-sink.cc:88
ns3::PacketSink::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
packet-sink.cc:101
ns3::PacketSink::StartApplication
virtual void StartApplication(void)
Application specific startup code.
Definition:
packet-sink.cc:113
ns3::PacketSink
Receive and consume traffic generated to an IP address and port.
Definition:
packet-sink.h:68
ns3::PacketSink::m_socket
Ptr< Socket > m_socket
Listening socket.
Definition:
packet-sink.h:126
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
Generated on Wed Nov 7 2018 10:01:47 for ns-3 by
1.8.14