Base class for source applications. More...
#include "source-application.h"
Public Member Functions | |
| SourceApplication (bool allowPacketSocket=true) | |
| Constructor. | |
| ~SourceApplication () override | |
| Address | GetRemote () const |
| get the remote address | |
| Ptr< Socket > | GetSocket () const |
| Get the socket this application is attached to. | |
| virtual void | SetRemote (const Address &addr) |
| set the remote address | |
| Public Member Functions inherited from ns3::Application | |
| Application () | |
| ~Application () override | |
| virtual int64_t | AssignStreams (int64_t stream) |
| Assign a fixed random variable stream number to the random variables used by this Application object. | |
| Ptr< Node > | GetNode () const |
| void | SetNode (Ptr< Node > node) |
| void | SetStartTime (Time start) |
| Specify application start time. | |
| void | SetStopTime (Time stop) |
| Specify application stop time. | |
| Public Member Functions inherited from ns3::Object | |
| Object () | |
| Constructor. | |
| ~Object () override | |
| Destructor. | |
| void | AggregateObject (Ptr< Object > other) |
| Aggregate two Objects together. | |
| void | Dispose () |
| Dispose of this Object. | |
| AggregateIterator | GetAggregateIterator () const |
| Get an iterator to the Objects aggregated to this one. | |
| TypeId | GetInstanceTypeId () const final |
| Get the most derived TypeId for this Object. | |
| template<> | |
| Ptr< Object > | GetObject () const |
| Specialization of () for objects of type ns3::Object. | |
| template<typename T> | |
| Ptr< T > | GetObject () const |
| Get a pointer to the requested aggregated Object. | |
| template<> | |
| Ptr< Object > | GetObject (TypeId tid) const |
| Specialization of (TypeId tid) for objects of type ns3::Object. | |
| template<typename T> | |
| Ptr< T > | GetObject (TypeId tid) const |
| Get a pointer to the requested aggregated Object by TypeId. | |
| void | Initialize () |
| Invoke DoInitialize on all Objects aggregated to this one. | |
| bool | IsInitialized () const |
| Check if the object has been initialized. | |
| void | UnidirectionalAggregateObject (Ptr< Object > other) |
| Aggregate an Object to another Object. | |
| Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
| SimpleRefCount () | |
| Default constructor. | |
| uint32_t | GetReferenceCount () const |
| Get the reference count of the object. | |
| SimpleRefCount & | operator= (const SimpleRefCount &o) |
| Assignment operator. | |
| void | Ref () const |
| Increment the reference count. | |
| void | Unref () const |
| Decrement the reference count. | |
| Public Member Functions inherited from ns3::ObjectBase | |
| virtual | ~ObjectBase () |
| Virtual destructor. | |
| void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
| Get the value of an attribute, raising fatal errors if unsuccessful. | |
| bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
| Get the value of an attribute without raising errors. | |
| void | SetAttribute (std::string name, const AttributeValue &value) |
| Set a single attribute, raising fatal errors if unsuccessful. | |
| bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
| Set a single attribute without raising errors. | |
| bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
| Connect a TraceSource to a Callback with a context. | |
| bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
| Connect a TraceSource to a Callback without a context. | |
| bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
| Disconnect from a TraceSource a Callback previously connected with a context. | |
| bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
| Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
| Static Public Member Functions inherited from ns3::Application | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
| Static Public Member Functions inherited from ns3::Object | |
| static TypeId | GetTypeId () |
| Register this type. | |
| Static Public Member Functions inherited from ns3::ObjectBase | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
Protected Types | |
| typedef void(* | ConnectionEventCallback) (Ptr< Socket > socket, const Address &local, const Address &remote) |
| TracedCallback signature for connection success/failure event. | |
Protected Member Functions | |
| bool | CloseSocket () |
| Close the socket. | |
| void | DoDispose () override |
| Destructor implementation. | |
| Protected Member Functions inherited from ns3::Application | |
| void | DoInitialize () override |
| Initialize() implementation. | |
| Protected Member Functions inherited from ns3::Object | |
| Object (const Object &o) | |
| Copy an Object. | |
| virtual void | NotifyNewAggregate () |
| Notify all Objects aggregated to this one of a new Object being aggregated. | |
| Protected Member Functions inherited from ns3::ObjectBase | |
| void | ConstructSelf (const AttributeConstructionList &attributes) |
| Complete construction of ObjectBase; invoked by derived classes. | |
| virtual void | NotifyConstructionCompleted () |
| Notifier called once the ObjectBase is fully constructed. | |
Protected Attributes | |
| bool | m_connected {false} |
| flag whether socket is connected | |
| TracedCallback< Ptr< Socket >, const Address &, const Address & > | m_connectionFailure |
| Traced Callback: connection failure event. | |
| TracedCallback< Ptr< Socket >, const Address &, const Address & > | m_connectionSuccess |
| Traced Callback: connection success event. | |
| Address | m_local |
| Local address to bind to. | |
| Address | m_peer |
| Peer address. | |
| TypeId | m_protocolTid |
| Protocol TypeId value. | |
| Ptr< Socket > | m_socket |
| Socket. | |
| uint8_t | m_tos |
| The packets Type of Service. | |
| TracedCallback< Ptr< const Packet > > | m_txTrace |
| Traced Callback: transmitted packets. | |
| Protected Attributes inherited from ns3::Application | |
| Ptr< Node > | m_node |
| The node that this application is installed on. | |
| EventId | m_startEvent |
| The event that will fire at m_startTime to start the application. | |
| Time | m_startTime |
| The simulation time that the application will start. | |
| EventId | m_stopEvent |
| The event that will fire at m_stopTime to end the application. | |
| Time | m_stopTime |
| The simulation time that the application will end. | |
Private Member Functions | |
| virtual void | CancelEvents ()=0 |
| Cancel all pending events. | |
| void | ConnectionFailed (Ptr< Socket > socket) |
| Handle a Connection Failed event. | |
| void | ConnectionSucceeded (Ptr< Socket > socket) |
| Handle a Connection Succeed event. | |
| virtual void | DoConnectionFailed (Ptr< Socket > socket) |
| Application specific code for child subclasses upon a Connection Failed event. | |
| virtual void | DoConnectionSucceeded (Ptr< Socket > socket) |
| Application specific code for child subclasses upon a Connection Succeed event. | |
| virtual void | DoStartApplication () |
| Application specific startup code for child subclasses. | |
| virtual void | DoStopApplication () |
| Application specific shutdown code for child subclasses. | |
| void | StartApplication () override |
| Application specific startup code. | |
| void | StopApplication () override |
| Application specific shutdown code. | |
Private Attributes | |
| bool | m_allowPacketSocket |
| Allow use of packet socket. | |
Additional Inherited Members | |
| Public Types inherited from ns3::Application | |
| typedef void(* | DelayAddressCallback) (const Time &delay, const Address &from) |
| Common callback signature for packet delay and address. | |
| typedef void(* | StateTransitionCallback) (const std::string &oldState, const std::string &newState) |
| Common signature used by callbacks to application's state transition trace source. | |
| Related Symbols inherited from ns3::ObjectBase | |
| static TypeId | GetObjectIid () |
| Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Base class for source applications.
This class can be used as a base class for source applications. A source application is one that primarily sources new data towards a single remote client address and port, and may also receive data (such as an HTTP server).
The main purpose of this base class application public API is to provide a uniform way to configure remote and local addresses.
Unlike the SinkApplication, the SourceApplication does not expose an individual Port attribute. Instead, the port values are embedded in the Local and Remote address attributes, which should be configured to an InetSocketAddress or Inet6SocketAddress value that contains the desired port number.
ns3::SourceApplication is accessible through the following paths with Config::Set and Config::Connect:
Address Address Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns Group: Applications
Size of this type is 264 bytes (on a 64-bit architecture).
Definition at line 38 of file source-application.h.
|
protected |
TracedCallback signature for connection success/failure event.
| [in] | socket | The socket for which connection succeeded/failed. |
| [in] | local | The local address. |
| [in] | remote | The remote address. |
Definition at line 91 of file source-application.h.
|
explicit |
Constructor.
| allowPacketSocket | flag whether the application should allow the use of packet sockets |
Definition at line 66 of file source-application.cc.
References m_allowPacketSocket, and NS_LOG_FUNCTION.
Referenced by ns3::ThreeGppHttpClient::ThreeGppHttpClient(), ns3::UdpClient::UdpClient(), ns3::UdpEchoClient::UdpEchoClient(), ns3::UdpTraceClient::UdpTraceClient(), ns3::BulkSendApplication::GetTypeId(), ns3::OnOffApplication::GetTypeId(), ns3::ThreeGppHttpClient::GetTypeId(), ns3::UdpClient::GetTypeId(), ns3::UdpEchoClient::GetTypeId(), and ns3::UdpTraceClient::GetTypeId().
|
override |
Definition at line 72 of file source-application.cc.
References NS_LOG_FUNCTION.
|
privatepure virtual |
Cancel all pending events.
Implemented in ns3::BulkSendApplication, ns3::OnOffApplication, ns3::ThreeGppHttpClient, ns3::UdpClient, ns3::UdpEchoClient, and ns3::UdpTraceClient.
Referenced by DoDispose(), StartApplication(), and StopApplication().
|
protected |
Close the socket.
Definition at line 170 of file source-application.cc.
References m_connected, m_socket, and ns3::MakeNullCallback().
Referenced by ns3::ThreeGppHttpClient::DoDispose(), ns3::OnOffApplication::ScheduleNextTx(), and StopApplication().
Handle a Connection Failed event.
| socket | the not connected socket |
Definition at line 194 of file source-application.cc.
References DoConnectionFailed(), m_connected, m_connectionFailure, m_local, m_peer, and NS_LOG_FUNCTION.
Referenced by StartApplication().
Handle a Connection Succeed event.
| socket | the connected socket |
Definition at line 185 of file source-application.cc.
References DoConnectionSucceeded(), m_connected, m_connectionSuccess, m_local, m_peer, and NS_LOG_FUNCTION.
Referenced by StartApplication().
Application specific code for child subclasses upon a Connection Failed event.
| socket | the not connected socket |
Reimplemented in ns3::ThreeGppHttpClient.
Definition at line 221 of file source-application.cc.
References NS_LOG_FUNCTION.
Referenced by ConnectionFailed().
Application specific code for child subclasses upon a Connection Succeed event.
| socket | the connected socket |
Reimplemented in ns3::BulkSendApplication, ns3::OnOffApplication, and ns3::ThreeGppHttpClient.
Definition at line 215 of file source-application.cc.
References NS_LOG_FUNCTION.
Referenced by ConnectionSucceeded().
|
overrideprotectedvirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.
It is safe to call GetObject() from within this method.
Reimplemented from ns3::Application.
Reimplemented in ns3::ThreeGppHttpClient.
Definition at line 78 of file source-application.cc.
References CancelEvents(), ns3::Application::DoDispose(), m_socket, and NS_LOG_FUNCTION.
Referenced by ns3::ThreeGppHttpClient::DoDispose().
|
privatevirtual |
Application specific startup code for child subclasses.
Reimplemented in ns3::BulkSendApplication, ns3::OnOffApplication, ns3::ThreeGppHttpClient, ns3::UdpClient, ns3::UdpEchoClient, and ns3::UdpTraceClient.
Definition at line 203 of file source-application.cc.
References NS_LOG_FUNCTION.
Referenced by StartApplication().
|
privatevirtual |
Application specific shutdown code for child subclasses.
Reimplemented in ns3::ThreeGppHttpClient.
Definition at line 209 of file source-application.cc.
References NS_LOG_FUNCTION.
Referenced by StopApplication().
| Address ns3::SourceApplication::GetRemote | ( | ) | const |
get the remote address
Definition at line 97 of file source-application.cc.
References m_peer.
Referenced by GetTypeId().
Get the socket this application is attached to.
Definition at line 103 of file source-application.cc.
References m_socket.
|
static |
Get the type ID.
Definition at line 26 of file source-application.cc.
References ns3::Application::Application(), GetRemote(), m_connectionFailure, m_connectionSuccess, m_local, m_tos, m_txTrace, ns3::MakeAddressAccessor(), ns3::MakeAddressChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), ns3::TypeId::SetParent(), and SetRemote().
|
virtual |
set the remote address
| addr | remote address |
Reimplemented in ns3::ThreeGppHttpClient, ns3::UdpClient, ns3::UdpEchoClient, and ns3::UdpTraceClient.
Definition at line 87 of file source-application.cc.
References ns3::Address::IsInvalid(), m_peer, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
overrideprivatevirtual |
Application specific startup code.
The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 109 of file source-application.cc.
References CancelEvents(), ConnectionFailed(), ConnectionSucceeded(), ns3::Socket::CreateSocket(), DoStartApplication(), ns3::Application::GetNode(), ns3::Inet6SocketAddress::IsMatchingType(), ns3::InetSocketAddress::IsMatchingType(), ns3::PacketSocketAddress::IsMatchingType(), m_allowPacketSocket, m_local, m_peer, m_protocolTid, m_socket, m_tos, ns3::MakeCallback(), NS_ABORT_MSG_IF, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Application specific shutdown code.
The StopApplication method is called at the stop time specified by Stop This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 161 of file source-application.cc.
References CancelEvents(), CloseSocket(), DoStopApplication(), and NS_LOG_FUNCTION.
|
private |
Allow use of packet socket.
Definition at line 154 of file source-application.h.
Referenced by SourceApplication(), and StartApplication().
|
protected |
flag whether socket is connected
Definition at line 109 of file source-application.h.
Referenced by CloseSocket(), ConnectionFailed(), ConnectionSucceeded(), ns3::BulkSendApplication::DataSend(), ns3::BulkSendApplication::DoStartApplication(), ns3::OnOffApplication::DoStartApplication(), and ns3::BulkSendApplication::SendData().
|
protected |
Traced Callback: connection failure event.
Definition at line 99 of file source-application.h.
Referenced by ConnectionFailed(), and GetTypeId().
|
protected |
Traced Callback: connection success event.
Definition at line 96 of file source-application.h.
Referenced by ConnectionSucceeded(), and GetTypeId().
|
protected |
Local address to bind to.
Definition at line 106 of file source-application.h.
Referenced by ConnectionFailed(), ConnectionSucceeded(), GetTypeId(), and StartApplication().
|
protected |
Peer address.
Definition at line 105 of file source-application.h.
Referenced by ConnectionFailed(), ConnectionSucceeded(), ns3::ThreeGppHttpClient::DoConnectionFailed(), ns3::BulkSendApplication::DoStartApplication(), ns3::UdpClient::DoStartApplication(), ns3::UdpClient::GetPort(), ns3::UdpEchoClient::GetPort(), ns3::UdpTraceClient::GetPort(), GetRemote(), ns3::UdpClient::GetRemote(), ns3::UdpEchoClient::GetRemote(), ns3::UdpTraceClient::GetRemote(), ns3::UdpEchoClient::Send(), ns3::OnOffApplication::SendPacket(), ns3::UdpTraceClient::SendPacket(), ns3::ThreeGppHttpClient::SetPort(), ns3::UdpClient::SetPort(), ns3::UdpEchoClient::SetPort(), ns3::UdpTraceClient::SetPort(), SetRemote(), ns3::ThreeGppHttpClient::SetRemote(), ns3::UdpClient::SetRemote(), ns3::UdpEchoClient::SetRemote(), ns3::UdpTraceClient::SetRemote(), and StartApplication().
|
protected |
Protocol TypeId value.
Definition at line 103 of file source-application.h.
Referenced by ns3::ThreeGppHttpClient::ThreeGppHttpClient(), ns3::UdpClient::UdpClient(), ns3::UdpEchoClient::UdpEchoClient(), ns3::UdpTraceClient::UdpTraceClient(), ns3::BulkSendApplication::GetTypeId(), ns3::OnOffApplication::GetTypeId(), and StartApplication().
Definition at line 101 of file source-application.h.
Referenced by CloseSocket(), ns3::ThreeGppHttpClient::DoConnectionSucceeded(), DoDispose(), ns3::BulkSendApplication::DoStartApplication(), ns3::OnOffApplication::DoStartApplication(), ns3::UdpClient::DoStartApplication(), ns3::UdpEchoClient::DoStartApplication(), ns3::UdpTraceClient::DoStartApplication(), GetSocket(), ns3::ThreeGppHttpClient::NormalCloseCallback(), ns3::ThreeGppHttpClient::OpenConnection(), ns3::ThreeGppHttpClient::RequestEmbeddedObject(), ns3::ThreeGppHttpClient::RequestMainObject(), ns3::UdpClient::Send(), ns3::UdpEchoClient::Send(), ns3::BulkSendApplication::SendData(), ns3::OnOffApplication::SendPacket(), ns3::UdpTraceClient::SendPacket(), and StartApplication().
|
protected |
The packets Type of Service.
Definition at line 107 of file source-application.h.
Referenced by GetTypeId(), and StartApplication().
|
protected |
Traced Callback: transmitted packets.
Definition at line 82 of file source-application.h.
Referenced by GetTypeId(), ns3::ThreeGppHttpClient::RequestEmbeddedObject(), ns3::ThreeGppHttpClient::RequestMainObject(), ns3::UdpClient::Send(), ns3::UdpEchoClient::Send(), ns3::BulkSendApplication::SendData(), ns3::OnOffApplication::SendPacket(), and ns3::UdpTraceClient::SendPacket().