A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::ThreeGppHttpClient Class Reference

Model application which simulates the traffic of a web browser. More...

#include "three-gpp-http-client.h"

Inheritance diagram for ns3::ThreeGppHttpClient:
Collaboration diagram for ns3::ThreeGppHttpClient:

Public Types

typedef void(* RxPageTracedCallback) (Ptr< const ThreeGppHttpClient > httpClient, const Time &time, uint32_t numObjects, uint32_t numBytes)
 Callback signature for RxPage trace sources.
enum  State_t {
  NOT_STARTED = 0 , CONNECTING , EXPECTING_MAIN_OBJECT , PARSING_MAIN_OBJECT ,
  EXPECTING_EMBEDDED_OBJECT , READING , STOPPED
}
 The possible states of the application. More...
typedef void(* TracedCallback) (Ptr< const ThreeGppHttpClient > httpClient)
 Common callback signature for ConnectionEstablished, RxMainObject, and RxEmbeddedObject trace sources.
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.

Public Member Functions

 ThreeGppHttpClient ()
 Creates a new instance of HTTP client application.
State_t GetState () const
 Returns the current state of the application.
std::string GetStateString () const
 Returns the current state of the application in string format.
void SetRemote (const Address &addr) override
 set the remote address
Public Member Functions inherited from ns3::SourceApplication
 SourceApplication (bool allowPacketSocket=true)
 Constructor.
 ~SourceApplication () override
Address GetRemote () const
 get the remote address
Ptr< SocketGetSocket () const
 Get the socket this application is attached to.
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< NodeGetNode () 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< ObjectGetObject () 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< ObjectGetObject (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.
SimpleRefCountoperator= (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 std::string GetStateString (State_t state)
 Returns the given state in string format.
static TypeId GetTypeId ()
 Returns the object TypeId.
Static Public Member Functions inherited from ns3::SourceApplication
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 Member Functions

void DoDispose () override
 Destructor implementation.
Protected Member Functions inherited from ns3::SourceApplication
bool CloseSocket ()
 Close the socket.
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.

Private Member Functions

void CancelEvents () override
 Cancel all pending events.
void DoConnectionFailed (Ptr< Socket > socket) override
 Application specific code for child subclasses upon a Connection Failed event.
void DoConnectionSucceeded (Ptr< Socket > socket) override
 Application specific code for child subclasses upon a Connection Succeed event.
void DoStartApplication () override
 Application specific startup code for child subclasses.
void DoStopApplication () override
 Application specific shutdown code for child subclasses.
void EnterParsingTime ()
 Becomes idle for a randomly determined amount of time, and then triggers ParseMainObject().
void EnterReadingTime ()
 Becomes idle for a randomly determined amount of time, and then triggers RequestMainObject().
void ErrorCloseCallback (Ptr< Socket > socket)
 Invoked when connection between m_socket and the web sever is terminated.
void FinishReceivingPage ()
 Finish receiving a page.
void NormalCloseCallback (Ptr< Socket > socket)
 Invoked when connection between m_socket and the web sever is terminated.
void OpenConnection ()
 Initialize m_socket to connect to the destination web server at m_peer and m_peerPort and set up callbacks to listen to its event.
void ParseMainObject ()
 Randomly determines the number of embedded objects in the main object.
void Receive (Ptr< Packet > packet)
 Simulate a consumption of the received packet by subtracting the packet size from the internal counter at m_objectBytesToBeReceived.
void ReceivedDataCallback (Ptr< Socket > socket)
 Invoked when m_socket receives some packet data.
void ReceiveEmbeddedObject (Ptr< Packet > packet, const Address &from)
 Receive a packet of embedded object from the destination web server.
void ReceiveMainObject (Ptr< Packet > packet, const Address &from)
 Receive a packet of main object from the destination web server.
void RequestEmbeddedObject ()
 Send a request object for an embedded object to the destination web server.
void RequestMainObject ()
 Send a request object for a main object to the destination web server.
void SetPort (uint16_t port)
 set the remote port (temporary function until deprecated attributes are removed)
void SwitchToState (State_t state)
 Change the state of the client.

Private Attributes

ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionClosedTrace
 The ConnectionClosed trace source.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionEstablishedTrace
 The ConnectionEstablished trace source.
Ptr< Packetm_constructedPacket
 The packet constructed of one or more parts with ThreeGppHttpHeader.
uint32_t m_embeddedObjectsToBeRequested {0}
 Determined after parsing the main object.
EventId m_eventParseMainObject
 An event of ParseMainObject(), scheduled to trigger after parsing time has elapsed.
EventId m_eventRequestEmbeddedObject
 An event of either RequestEmbeddedObject() or OpenConnection().
EventId m_eventRequestMainObject
 An event of either RequestMainObject() or OpenConnection(), scheduled to trigger after a connection has been established or reading time has elapsed.
Ptr< ThreeGppHttpVariablesm_httpVariables
 The Variables attribute.
uint32_t m_numberBytesPage {0}
 Number of bytes received for the current page.
uint32_t m_numberEmbeddedObjectsRequested {0}
 Number of embedded objects to requested in the current page.
uint32_t m_objectBytesToBeReceived {0}
 According to the content length specified by the ThreeGppHttpHeader.
Time m_objectClientTs
 The client time stamp of the ThreeGppHttpHeader from the last received packet.
Time m_objectServerTs
 The server time stamp of the ThreeGppHttpHeader from the last received packet.
Time m_pageLoadStartTs
 The time stamp when the page started loading.
std::optional< uint16_t > m_peerPort
 The RemoteServerPort attribute.
ns3::TracedCallback< const Time &, const Address & > m_rxDelayTrace
 The RxDelay trace source.
ns3::TracedCallback< Ptr< const Packet > > m_rxEmbeddedObjectPacketTrace
 The TxEmbeddedObjectPacket trace source.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxEmbeddedObjectTrace
 The TxEmbeddedObject trace source.
ns3::TracedCallback< Ptr< const Packet > > m_rxMainObjectPacketTrace
 The TxMainObjectPacket trace source.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxMainObjectTrace
 The TxMainObject trace source.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, const Time &, uint32_t, uint32_tm_rxPageTrace
 The RxPage trace source.
ns3::TracedCallback< const Time &, const Address & > m_rxRttTrace
 The RxRtt trace source.
ns3::TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
 The Rx trace source.
State_t m_state {NOT_STARTED}
 The current state of the client application. Begins with NOT_STARTED.
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
 The StateTransition trace source.
ns3::TracedCallback< Ptr< const Packet > > m_txEmbeddedObjectRequestTrace
 The TxEmbeddedObjectRequest trace source.
ns3::TracedCallback< Ptr< const Packet > > m_txMainObjectRequestTrace
 The TxMainObjectRequest trace source.

Additional Inherited Members

Protected Types inherited from ns3::SourceApplication
typedef void(* ConnectionEventCallback) (Ptr< Socket > socket, const Address &local, const Address &remote)
 TracedCallback signature for connection success/failure event.
Protected Attributes inherited from ns3::SourceApplication
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< Socketm_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< Nodem_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.

Detailed Description

Model application which simulates the traffic of a web browser.

This application works in conjunction with an ThreeGppHttpServer application.

In summary, the application works as follows.

  1. Upon start, it opens a connection to the destination web server (ThreeGppHttpServer).
  2. After the connection is established, the application immediately requests a main object from the server by sending a request packet.
  3. After receiving a main object (which can take some time if it consists of several packets), the application "parses" the main object.
  4. The parsing takes a short time (randomly determined) to determine the number of embedded objects (also randomly determined) in the web page.
    • If at least one embedded object is determined, the application requests the first embedded object from the server. The request for the next embedded object follows after the previous embedded object has been completely received.
    • If there is no more embedded object to request, the application enters the reading time.
  5. Reading time is a long delay (again, randomly determined) where the application does not induce any network traffic, thus simulating the user reading the downloaded web page.
  6. After the reading time is finished, the process repeats to step #2.

The client models HTTP persistent connection, i.e., HTTP 1.1, where the connection to the server is maintained and used for transmitting and receiving all objects.

Each request by default has a constant size of 350 bytes. A ThreeGppHttpHeader is attached to each request packet. The header contains information such as the content type requested (either main object or embedded object) and the timestamp when the packet is transmitted (which will be used to compute the delay and RTT of the packet).

Config Paths

ns3::ThreeGppHttpClient is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/ApplicationList/[i]/$ns3::SourceApplication/$ns3::ThreeGppHttpClient"
  • "/NodeList/[i]/ApplicationList/[i]/$ns3::ThreeGppHttpClient"

Attributes

  • RemoteServerAddress: The address of the destination server.
    • Set with class: ns3::AddressValue
    • Underlying type: Address
    • Initial value:
    • Flags: constructwrite
    • Support level: DEPRECATED: Replaced by Remote in ns-3.44.
  • RemoteServerPort: The destination port of the outbound packets.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint16_t 0:65535
    • Initial value: 80
    • Flags: constructwrite
    • Support level: DEPRECATED: Replaced by Remote in ns-3.44.
  • Variables: Variable collection, which is used to control e.g. timing and HTTP request size.

Attributes defined in parent class ns3::SourceApplication

  • Local: The Address on which to bind the socket. If not set, it is generated automatically when needed by the application.
    • Set with class: ns3::AddressValue
    • Underlying type: Address
    • Initial value:
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • Remote: The address of the destination, made of the remote IP address and the destination port
    • Set with class: ns3::AddressValue
    • Underlying type: Address
    • Initial value:
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • Tos: The Type of Service used to send IPv4 packets. All 8 bits of the TOS byte are set (including ECN bits).
    • Set with class: ns3::UintegerValue
    • Underlying type: uint8_t 0:255
    • Initial value: 0
    • Flags: constructwriteread
    • Support level: SUPPORTED

Attributes defined in parent class ns3::Application

  • StartTime: Time at which the application will start
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • StopTime: Time at which the application will stop
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
    • Support level: SUPPORTED

TraceSources

TraceSources defined in parent class ns3::SourceApplication

ns3::ThreeGppHttpClient does not belong to a group
Size of this type is 720 bytes (on a 64-bit architecture).

Definition at line 96 of file three-gpp-http-client.h.

Member Typedef Documentation

◆ RxPageTracedCallback

typedef void(* ns3::ThreeGppHttpClient::RxPageTracedCallback) (Ptr< const ThreeGppHttpClient > httpClient, const Time &time, uint32_t numObjects, uint32_t numBytes)

Callback signature for RxPage trace sources.

Parameters
httpClientPointer to this instance of ThreeGppHttpClient, which is where the trace originated.
timeElapsed time from the start to the end of the request.
numObjectsNumber of objects downloaded, including main and embedded objects.
numBytesTotal number of bytes included in the page.

Definition at line 170 of file three-gpp-http-client.h.

◆ TracedCallback

typedef void(* ns3::ThreeGppHttpClient::TracedCallback) (Ptr< const ThreeGppHttpClient > httpClient)

Common callback signature for ConnectionEstablished, RxMainObject, and RxEmbeddedObject trace sources.

Parameters
httpClientPointer to this instance of ThreeGppHttpClient, which is where the trace originated.

Definition at line 159 of file three-gpp-http-client.h.

Member Enumeration Documentation

◆ State_t

The possible states of the application.

Enumerator
NOT_STARTED 

Before StartApplication() is invoked.

CONNECTING 

Sent the server a connection request and waiting for the server to be accept it.

EXPECTING_MAIN_OBJECT 

Sent the server a request for a main object and waiting to receive the packets.

PARSING_MAIN_OBJECT 

Parsing a main object that has just been received.

EXPECTING_EMBEDDED_OBJECT 

Sent the server a request for an embedded object and waiting to receive the packets.

READING 

User reading a web page that has just been received.

STOPPED 

After StopApplication() is invoked.

Definition at line 116 of file three-gpp-http-client.h.

Constructor & Destructor Documentation

◆ ThreeGppHttpClient()

ns3::ThreeGppHttpClient::ThreeGppHttpClient ( )

Creates a new instance of HTTP client application.

After creation, the application must be further configured through attributes. To avoid having to do this process manually, please use ThreeGppHttpClientHelper.

Definition at line 32 of file three-gpp-http-client.cc.

References ns3::SourceApplication::SourceApplication(), ns3::CreateObject(), ns3::TypeId::LookupByName(), m_httpVariables, ns3::SourceApplication::m_protocolTid, and NS_LOG_FUNCTION.

Here is the call graph for this function:

Member Function Documentation

◆ CancelEvents()

void ns3::ThreeGppHttpClient::CancelEvents ( )
overrideprivatevirtual

Cancel all pending events.

Implements ns3::SourceApplication.

Definition at line 703 of file three-gpp-http-client.cc.

References ns3::Simulator::Cancel(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::IsExpired(), m_eventParseMainObject, m_eventRequestEmbeddedObject, m_eventRequestMainObject, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.

Referenced by DoDispose(), ErrorCloseCallback(), and NormalCloseCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoConnectionFailed()

void ns3::ThreeGppHttpClient::DoConnectionFailed ( Ptr< Socket > socket)
overrideprivatevirtual

Application specific code for child subclasses upon a Connection Failed event.

Parameters
socketthe not connected socket

Reimplemented from ns3::SourceApplication.

Definition at line 253 of file three-gpp-http-client.cc.

References CONNECTING, GetStateString(), ns3::SourceApplication::m_peer, m_state, NS_FATAL_ERROR, NS_LOG_ERROR, and NS_LOG_FUNCTION.

Here is the call graph for this function:

◆ DoConnectionSucceeded()

void ns3::ThreeGppHttpClient::DoConnectionSucceeded ( Ptr< Socket > socket)
overrideprivatevirtual

Application specific code for child subclasses upon a Connection Succeed event.

Parameters
socketthe connected socket

Reimplemented from ns3::SourceApplication.

Definition at line 236 of file three-gpp-http-client.cc.

References CONNECTING, GetStateString(), m_connectionEstablishedTrace, m_embeddedObjectsToBeRequested, m_eventRequestMainObject, ns3::SourceApplication::m_socket, m_state, ns3::MakeCallback(), NS_ASSERT, NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_FUNCTION, ReceivedDataCallback(), RequestMainObject(), and ns3::Simulator::ScheduleNow().

Here is the call graph for this function:

◆ DoDispose()

void ns3::ThreeGppHttpClient::DoDispose ( )
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::SourceApplication.

Definition at line 199 of file three-gpp-http-client.cc.

References CancelEvents(), ns3::SourceApplication::CloseSocket(), ns3::SourceApplication::DoDispose(), ns3::Simulator::IsFinished(), and NS_LOG_FUNCTION.

Here is the call graph for this function:

◆ DoStartApplication()

void ns3::ThreeGppHttpClient::DoStartApplication ( )
overrideprivatevirtual

Application specific startup code for child subclasses.

Reimplemented from ns3::SourceApplication.

Definition at line 213 of file three-gpp-http-client.cc.

References GetStateString(), m_httpVariables, m_state, NOT_STARTED, NS_FATAL_ERROR, NS_LOG_FUNCTION, and OpenConnection().

Here is the call graph for this function:

◆ DoStopApplication()

void ns3::ThreeGppHttpClient::DoStopApplication ( )
overrideprivatevirtual

Application specific shutdown code for child subclasses.

Reimplemented from ns3::SourceApplication.

Definition at line 229 of file three-gpp-http-client.cc.

References NS_LOG_FUNCTION, STOPPED, and SwitchToState().

Here is the call graph for this function:

◆ EnterParsingTime()

void ns3::ThreeGppHttpClient::EnterParsingTime ( )
private

Becomes idle for a randomly determined amount of time, and then triggers ParseMainObject().

The length of idle time is determined by TheeGppHttpVariables.

The method is invoked after a complete main object has been received.

Definition at line 628 of file three-gpp-http-client.cc.

References EXPECTING_MAIN_OBJECT, GetStateString(), m_eventParseMainObject, m_httpVariables, m_state, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, ParseMainObject(), PARSING_MAIN_OBJECT, ns3::Time::S, ns3::Simulator::Schedule(), and SwitchToState().

Referenced by ReceiveMainObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnterReadingTime()

void ns3::ThreeGppHttpClient::EnterReadingTime ( )
private

Becomes idle for a randomly determined amount of time, and then triggers RequestMainObject().

The length of idle time is determined by ThreeGppHttpVariables.

The method is invoked after a complete web page has been received.

Definition at line 683 of file three-gpp-http-client.cc.

References EXPECTING_EMBEDDED_OBJECT, GetStateString(), m_eventRequestMainObject, m_httpVariables, m_state, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, PARSING_MAIN_OBJECT, READING, RequestMainObject(), ns3::Time::S, ns3::Simulator::Schedule(), and SwitchToState().

Referenced by ParseMainObject(), and ReceiveEmbeddedObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ErrorCloseCallback()

void ns3::ThreeGppHttpClient::ErrorCloseCallback ( Ptr< Socket > socket)
private

Invoked when connection between m_socket and the web sever is terminated.

Error will be logged, but simulation continues.

Parameters
socketPointer to the socket where the event originates from.

Definition at line 287 of file three-gpp-http-client.cc.

References CancelEvents(), ns3::Socket::ERROR_NOTERROR, m_connectionClosedTrace, NS_LOG_ERROR, and NS_LOG_FUNCTION.

Referenced by OpenConnection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinishReceivingPage()

void ns3::ThreeGppHttpClient::FinishReceivingPage ( )
private

Finish receiving a page.

This function should be called when a full-page finishes loading, including the main object and all embedded objects.

Definition at line 753 of file three-gpp-http-client.cc.

References m_numberBytesPage, m_numberEmbeddedObjectsRequested, m_pageLoadStartTs, m_rxPageTrace, and ns3::Simulator::Now().

Referenced by ParseMainObject(), and ReceiveEmbeddedObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetState()

ThreeGppHttpClient::State_t ns3::ThreeGppHttpClient::GetState ( ) const

Returns the current state of the application.

Returns
The current state of the application.

Definition at line 161 of file three-gpp-http-client.cc.

References m_state.

◆ GetStateString() [1/2]

std::string ns3::ThreeGppHttpClient::GetStateString ( ) const

Returns the current state of the application in string format.

Returns
The current state of the application in string format.

Definition at line 167 of file three-gpp-http-client.cc.

References GetStateString(), and m_state.

Referenced by DoConnectionFailed(), DoConnectionSucceeded(), DoStartApplication(), EnterParsingTime(), EnterReadingTime(), GetStateString(), OpenConnection(), ParseMainObject(), ReceivedDataCallback(), ReceiveEmbeddedObject(), ReceiveMainObject(), RequestEmbeddedObject(), RequestMainObject(), and SwitchToState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStateString() [2/2]

std::string ns3::ThreeGppHttpClient::GetStateString ( ThreeGppHttpClient::State_t state)
static

Returns the given state in string format.

Parameters
stateAn arbitrary state of an application.
Returns
The given state equivalently expressed in string format.

Definition at line 174 of file three-gpp-http-client.cc.

References CONNECTING, EXPECTING_EMBEDDED_OBJECT, EXPECTING_MAIN_OBJECT, NOT_STARTED, NS_FATAL_ERROR, PARSING_MAIN_OBJECT, READING, and STOPPED.

◆ GetTypeId()

◆ NormalCloseCallback()

void ns3::ThreeGppHttpClient::NormalCloseCallback ( Ptr< Socket > socket)
private

Invoked when connection between m_socket and the web sever is terminated.

Error will be logged, but simulation continues.

Parameters
socketPointer to the socket where the event originates from.

Definition at line 268 of file three-gpp-http-client.cc.

References CancelEvents(), ns3::Socket::ERROR_NOTERROR, m_connectionClosedTrace, ns3::SourceApplication::m_socket, ns3::MakeNullCallback(), NS_LOG_ERROR, and NS_LOG_FUNCTION.

Referenced by OpenConnection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenConnection()

void ns3::ThreeGppHttpClient::OpenConnection ( )
private

Initialize m_socket to connect to the destination web server at m_peer and m_peerPort and set up callbacks to listen to its event.

Invoked upon the start of the application.

Definition at line 350 of file three-gpp-http-client.cc.

References CONNECTING, ErrorCloseCallback(), EXPECTING_EMBEDDED_OBJECT, GetStateString(), ns3::SourceApplication::m_socket, m_state, ns3::MakeCallback(), NormalCloseCallback(), NOT_STARTED, NS_FATAL_ERROR, NS_LOG_FUNCTION, PARSING_MAIN_OBJECT, READING, ReceivedDataCallback(), and SwitchToState().

Referenced by DoStartApplication().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseMainObject()

void ns3::ThreeGppHttpClient::ParseMainObject ( )
private

Randomly determines the number of embedded objects in the main object.

ThreeGppHttpVariables is utilized for this purpose. Then proceeds with RequestEmbeddedObject(). If the number of embedded objects has been determined as zero, then EnterReadingTime() is triggered.

The method is invoked after parsing time has elapsed.

Definition at line 646 of file three-gpp-http-client.cc.

References EnterReadingTime(), FinishReceivingPage(), GetStateString(), m_embeddedObjectsToBeRequested, m_eventRequestEmbeddedObject, m_httpVariables, m_numberEmbeddedObjectsRequested, m_state, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, PARSING_MAIN_OBJECT, RequestEmbeddedObject(), and ns3::Simulator::ScheduleNow().

Referenced by EnterParsingTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Receive()

void ns3::ThreeGppHttpClient::Receive ( Ptr< Packet > packet)
private

Simulate a consumption of the received packet by subtracting the packet size from the internal counter at m_objectBytesToBeReceived.

Also updates m_objectClientTs and m_objectServerTs according to the ThreeGppHttpHeader found in the packet.

This method is invoked as a sub-procedure of ReceiveMainObject() and ReceiveEmbeddedObject().

Parameters
packetThe received packet. If it is the first packet of the object, then it must have a ThreeGppHttpHeader attached to it.

Definition at line 575 of file three-gpp-http-client.cc.

References ns3::ThreeGppHttpHeader::GetClientTs(), ns3::ThreeGppHttpHeader::GetContentLength(), ns3::ThreeGppHttpHeader::GetServerTs(), m_constructedPacket, m_numberBytesPage, m_objectBytesToBeReceived, m_objectClientTs, m_objectServerTs, NS_LOG_FUNCTION, and NS_LOG_WARN.

Referenced by ReceiveEmbeddedObject(), and ReceiveMainObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceivedDataCallback()

void ns3::ThreeGppHttpClient::ReceivedDataCallback ( Ptr< Socket > socket)
private

Invoked when m_socket receives some packet data.

Fires the Rx trace source and triggers ReceiveMainObject() or ReceiveEmbeddedObject().

Parameters
socketPointer to the socket where the event originates from.

Definition at line 302 of file three-gpp-http-client.cc.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::InetSocketAddress::ConvertFrom(), EXPECTING_EMBEDDED_OBJECT, EXPECTING_MAIN_OBJECT, GetStateString(), ns3::Inet6SocketAddress::IsMatchingType(), ns3::InetSocketAddress::IsMatchingType(), m_rxTrace, m_state, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, ReceiveEmbeddedObject(), and ReceiveMainObject().

Referenced by DoConnectionSucceeded(), and OpenConnection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceiveEmbeddedObject()

void ns3::ThreeGppHttpClient::ReceiveEmbeddedObject ( Ptr< Packet > packet,
const Address & from )
private

Receive a packet of embedded object from the destination web server.

Fires the RxEmbeddedObjectPacket trace source.

An embedded object may come from more than one packets. This is determined by comparing the content length specified in the TheeGppHttpHeader of the packet and the actual packet size. m_objectBytesToBeReceived keeps track of the number of bytes that has been received.

If the received packet is not the last packet of the object, then the method simply quits, expecting it to be invoked again when the next packet comes.

If the received packet is the last packet of the object, then the method fires the RxEmbeddedObject, RxDelay, and RxRtt trace sources. Depending on the number of embedded objects remaining (m_embeddedObjectsToBeRequested) the client can either trigger RequestEmbeddedObject() or EnterReadingTime().

Parameters
packetThe received packet.
fromAddress of the sender.

Definition at line 505 of file three-gpp-http-client.cc.

References EnterReadingTime(), EXPECTING_EMBEDDED_OBJECT, FinishReceivingPage(), GetStateString(), m_constructedPacket, m_embeddedObjectsToBeRequested, m_eventRequestEmbeddedObject, m_objectBytesToBeReceived, m_objectClientTs, m_objectServerTs, m_rxDelayTrace, m_rxEmbeddedObjectPacketTrace, m_rxEmbeddedObjectTrace, m_rxRttTrace, m_state, ns3::MilliSeconds(), ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, Receive(), RequestEmbeddedObject(), and ns3::Simulator::ScheduleNow().

Referenced by ReceivedDataCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceiveMainObject()

void ns3::ThreeGppHttpClient::ReceiveMainObject ( Ptr< Packet > packet,
const Address & from )
private

Receive a packet of main object from the destination web server.

Fires the RxMainObjectPacket trace source.

A main object may come from more than one packets. This is determined by comparing the content length specified in the ThreeGppHttpHeader of the packet and the actual packet size. m_objectBytesToBeReceived keeps track of the number of bytes that has been received.

If the received packet is not the last packet of the object, then the method simply quits, expecting it to be invoked again when the next packet comes.

If the received packet is the last packet of the object, then the method fires the RxMainObject, RxDelay, and RxRtt trace sources. The client then triggers EnterParsingTime().

Parameters
packetThe received packet.
fromAddress of the sender.

Definition at line 451 of file three-gpp-http-client.cc.

References EnterParsingTime(), EXPECTING_MAIN_OBJECT, GetStateString(), m_constructedPacket, m_objectBytesToBeReceived, m_objectClientTs, m_objectServerTs, m_rxDelayTrace, m_rxMainObjectPacketTrace, m_rxMainObjectTrace, m_rxRttTrace, m_state, ns3::MilliSeconds(), ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, and Receive().

Referenced by ReceivedDataCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RequestEmbeddedObject()

void ns3::ThreeGppHttpClient::RequestEmbeddedObject ( )
private

Send a request object for an embedded object to the destination web server.

The size of the request packet is randomly determined by ThreeGppHttpVariables and is assumed to be smaller than 536 bytes. Fires the TxEmbeddedObjectRequest trace source.

Definition at line 406 of file three-gpp-http-client.cc.

References CONNECTING, ns3::Create(), ns3::ThreeGppHttpHeader::EMBEDDED_OBJECT, EXPECTING_EMBEDDED_OBJECT, GetStateString(), m_embeddedObjectsToBeRequested, m_httpVariables, ns3::SourceApplication::m_socket, m_state, m_txEmbeddedObjectRequestTrace, ns3::SourceApplication::m_txTrace, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_WARN, packetSize, PARSING_MAIN_OBJECT, ns3::ThreeGppHttpHeader::SetClientTs(), ns3::ThreeGppHttpHeader::SetContentLength(), ns3::ThreeGppHttpHeader::SetContentType(), and SwitchToState().

Referenced by ParseMainObject(), and ReceiveEmbeddedObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RequestMainObject()

void ns3::ThreeGppHttpClient::RequestMainObject ( )
private

Send a request object for a main object to the destination web server.

The size of the request packet is randomly determined by HttpVariables and is assumed to be smaller than 536 bytes. Fires the TxMainObjectRequest trace source.

The method is invoked after a connection is established or after a reading time has elapsed.

Definition at line 369 of file three-gpp-http-client.cc.

References CONNECTING, ns3::Create(), EXPECTING_MAIN_OBJECT, GetStateString(), m_httpVariables, m_pageLoadStartTs, ns3::SourceApplication::m_socket, m_state, m_txMainObjectRequestTrace, ns3::SourceApplication::m_txTrace, ns3::ThreeGppHttpHeader::MAIN_OBJECT, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, packetSize, READING, ns3::ThreeGppHttpHeader::SetClientTs(), ns3::ThreeGppHttpHeader::SetContentLength(), ns3::ThreeGppHttpHeader::SetContentType(), and SwitchToState().

Referenced by DoConnectionSucceeded(), and EnterReadingTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPort()

void ns3::ThreeGppHttpClient::SetPort ( uint16_t port)
private

set the remote port (temporary function until deprecated attributes are removed)

Parameters
portremote port

Definition at line 145 of file three-gpp-http-client.cc.

References ns3::addressUtils::ConvertToSocketAddress(), ns3::Ipv4Address::IsMatchingType(), ns3::Ipv6Address::IsMatchingType(), ns3::SourceApplication::m_peer, m_peerPort, NS_LOG_FUNCTION, and port.

Referenced by GetTypeId(), and SetRemote().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetRemote()

void ns3::ThreeGppHttpClient::SetRemote ( const Address & addr)
overridevirtual

set the remote address

Parameters
addrremote address

Reimplemented from ns3::SourceApplication.

Definition at line 131 of file three-gpp-http-client.cc.

References ns3::Address::IsInvalid(), ns3::SourceApplication::m_peer, m_peerPort, NS_LOG_FUNCTION, and SetPort().

Referenced by GetTypeId().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SwitchToState()

void ns3::ThreeGppHttpClient::SwitchToState ( ThreeGppHttpClient::State_t state)
private

Change the state of the client.

Fires the StateTransition trace source.

Parameters
stateThe new state.

Definition at line 731 of file three-gpp-http-client.cc.

References EXPECTING_EMBEDDED_OBJECT, EXPECTING_MAIN_OBJECT, GetStateString(), m_objectBytesToBeReceived, m_state, m_stateTransitionTrace, NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by DoStopApplication(), EnterParsingTime(), EnterReadingTime(), OpenConnection(), RequestEmbeddedObject(), and RequestMainObject().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_connectionClosedTrace

ns3::TracedCallback<Ptr<const ThreeGppHttpClient> > ns3::ThreeGppHttpClient::m_connectionClosedTrace
private

The ConnectionClosed trace source.

Definition at line 374 of file three-gpp-http-client.h.

Referenced by ErrorCloseCallback(), GetTypeId(), and NormalCloseCallback().

◆ m_connectionEstablishedTrace

ns3::TracedCallback<Ptr<const ThreeGppHttpClient> > ns3::ThreeGppHttpClient::m_connectionEstablishedTrace
private

The ConnectionEstablished trace source.

Definition at line 372 of file three-gpp-http-client.h.

Referenced by DoConnectionSucceeded(), and GetTypeId().

◆ m_constructedPacket

Ptr<Packet> ns3::ThreeGppHttpClient::m_constructedPacket
private

The packet constructed of one or more parts with ThreeGppHttpHeader.

Definition at line 345 of file three-gpp-http-client.h.

Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().

◆ m_embeddedObjectsToBeRequested

uint32_t ns3::ThreeGppHttpClient::m_embeddedObjectsToBeRequested {0}
private

Determined after parsing the main object.

Definition at line 351 of file three-gpp-http-client.h.

Referenced by DoConnectionSucceeded(), ParseMainObject(), ReceiveEmbeddedObject(), and RequestEmbeddedObject().

◆ m_eventParseMainObject

EventId ns3::ThreeGppHttpClient::m_eventParseMainObject
private

An event of ParseMainObject(), scheduled to trigger after parsing time has elapsed.

Definition at line 412 of file three-gpp-http-client.h.

Referenced by CancelEvents(), and EnterParsingTime().

◆ m_eventRequestEmbeddedObject

EventId ns3::ThreeGppHttpClient::m_eventRequestEmbeddedObject
private

An event of either RequestEmbeddedObject() or OpenConnection().

Definition at line 407 of file three-gpp-http-client.h.

Referenced by CancelEvents(), ParseMainObject(), and ReceiveEmbeddedObject().

◆ m_eventRequestMainObject

EventId ns3::ThreeGppHttpClient::m_eventRequestMainObject
private

An event of either RequestMainObject() or OpenConnection(), scheduled to trigger after a connection has been established or reading time has elapsed.

Definition at line 403 of file three-gpp-http-client.h.

Referenced by CancelEvents(), DoConnectionSucceeded(), and EnterReadingTime().

◆ m_httpVariables

Ptr<ThreeGppHttpVariables> ns3::ThreeGppHttpClient::m_httpVariables
private

◆ m_numberBytesPage

uint32_t ns3::ThreeGppHttpClient::m_numberBytesPage {0}
private

Number of bytes received for the current page.

Definition at line 357 of file three-gpp-http-client.h.

Referenced by FinishReceivingPage(), and Receive().

◆ m_numberEmbeddedObjectsRequested

uint32_t ns3::ThreeGppHttpClient::m_numberEmbeddedObjectsRequested {0}
private

Number of embedded objects to requested in the current page.

Definition at line 355 of file three-gpp-http-client.h.

Referenced by FinishReceivingPage(), and ParseMainObject().

◆ m_objectBytesToBeReceived

uint32_t ns3::ThreeGppHttpClient::m_objectBytesToBeReceived {0}
private

According to the content length specified by the ThreeGppHttpHeader.

Definition at line 343 of file three-gpp-http-client.h.

Referenced by Receive(), ReceiveEmbeddedObject(), ReceiveMainObject(), and SwitchToState().

◆ m_objectClientTs

Time ns3::ThreeGppHttpClient::m_objectClientTs
private

The client time stamp of the ThreeGppHttpHeader from the last received packet.

Definition at line 347 of file three-gpp-http-client.h.

Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().

◆ m_objectServerTs

Time ns3::ThreeGppHttpClient::m_objectServerTs
private

The server time stamp of the ThreeGppHttpHeader from the last received packet.

Definition at line 349 of file three-gpp-http-client.h.

Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().

◆ m_pageLoadStartTs

Time ns3::ThreeGppHttpClient::m_pageLoadStartTs
private

The time stamp when the page started loading.

Definition at line 353 of file three-gpp-http-client.h.

Referenced by FinishReceivingPage(), and RequestMainObject().

◆ m_peerPort

std::optional<uint16_t> ns3::ThreeGppHttpClient::m_peerPort
private

The RemoteServerPort attribute.

Definition at line 364 of file three-gpp-http-client.h.

Referenced by SetPort(), and SetRemote().

◆ m_rxDelayTrace

ns3::TracedCallback<const Time&, const Address&> ns3::ThreeGppHttpClient::m_rxDelayTrace
private

The RxDelay trace source.

Definition at line 390 of file three-gpp-http-client.h.

Referenced by GetTypeId(), ReceiveEmbeddedObject(), and ReceiveMainObject().

◆ m_rxEmbeddedObjectPacketTrace

ns3::TracedCallback<Ptr<const Packet> > ns3::ThreeGppHttpClient::m_rxEmbeddedObjectPacketTrace
private

The TxEmbeddedObjectPacket trace source.

Definition at line 384 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceiveEmbeddedObject().

◆ m_rxEmbeddedObjectTrace

ns3::TracedCallback<Ptr<const ThreeGppHttpClient>, Ptr<const Packet> > ns3::ThreeGppHttpClient::m_rxEmbeddedObjectTrace
private

The TxEmbeddedObject trace source.

Definition at line 386 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceiveEmbeddedObject().

◆ m_rxMainObjectPacketTrace

ns3::TracedCallback<Ptr<const Packet> > ns3::ThreeGppHttpClient::m_rxMainObjectPacketTrace
private

The TxMainObjectPacket trace source.

Definition at line 380 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceiveMainObject().

◆ m_rxMainObjectTrace

ns3::TracedCallback<Ptr<const ThreeGppHttpClient>, Ptr<const Packet> > ns3::ThreeGppHttpClient::m_rxMainObjectTrace
private

The TxMainObject trace source.

Definition at line 382 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceiveMainObject().

◆ m_rxPageTrace

ns3::TracedCallback<Ptr<const ThreeGppHttpClient>, const Time&, uint32_t, uint32_t> ns3::ThreeGppHttpClient::m_rxPageTrace
private

The RxPage trace source.

Definition at line 370 of file three-gpp-http-client.h.

Referenced by FinishReceivingPage(), and GetTypeId().

◆ m_rxRttTrace

ns3::TracedCallback<const Time&, const Address&> ns3::ThreeGppHttpClient::m_rxRttTrace
private

The RxRtt trace source.

Definition at line 392 of file three-gpp-http-client.h.

Referenced by GetTypeId(), ReceiveEmbeddedObject(), and ReceiveMainObject().

◆ m_rxTrace

ns3::TracedCallback<Ptr<const Packet>, const Address&> ns3::ThreeGppHttpClient::m_rxTrace
private

The Rx trace source.

Definition at line 388 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceivedDataCallback().

◆ m_state

◆ m_stateTransitionTrace

ns3::TracedCallback<const std::string&, const std::string&> ns3::ThreeGppHttpClient::m_stateTransitionTrace
private

The StateTransition trace source.

Definition at line 394 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and SwitchToState().

◆ m_txEmbeddedObjectRequestTrace

ns3::TracedCallback<Ptr<const Packet> > ns3::ThreeGppHttpClient::m_txEmbeddedObjectRequestTrace
private

The TxEmbeddedObjectRequest trace source.

Definition at line 378 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and RequestEmbeddedObject().

◆ m_txMainObjectRequestTrace

ns3::TracedCallback<Ptr<const Packet> > ns3::ThreeGppHttpClient::m_txMainObjectRequestTrace
private

The TxMainObjectRequest trace source.

Definition at line 376 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and RequestMainObject().


The documentation for this class was generated from the following files: