A Discrete-Event Network Simulator
API
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

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. More...
 
- Public Types inherited from ns3::Application
typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 

Public Member Functions

 ThreeGppHttpClient ()
 Creates a new instance of HTTP client application. More...
 
Ptr< SocketGetSocket () const
 Returns a pointer to the associated socket. More...
 
State_t GetState () const
 Returns the current state of the application. More...
 
std::string GetStateString () const
 Returns the current state of the application in string format. More...
 
- Public Member Functions inherited from ns3::Application
 Application ()
 
virtual ~Application ()
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static std::string GetStateString (State_t state)
 Returns the given state in string format. More...
 
static TypeId GetTypeId ()
 Returns the object TypeId. More...
 
- Static Public Member Functions inherited from ns3::Application
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Protected Member Functions

virtual void DoDispose ()
 Destructor implementation. More...
 
virtual void StartApplication ()
 Application specific startup code. More...
 
virtual void StopApplication ()
 Application specific shutdown code. More...
 
- Protected Member Functions inherited from ns3::Application
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Member Functions

void CancelAllPendingEvents ()
 Cancels m_eventRequestMainObject, m_eventRequestEmbeddedObject, and m_eventParseMainObject. More...
 
void ConnectionFailedCallback (Ptr< Socket > socket)
 Invoked when m_socket cannot establish a connection with the web server. More...
 
void ConnectionSucceededCallback (Ptr< Socket > socket)
 Invoked when a connection is established successfully on m_socket. More...
 
void EnterParsingTime ()
 Becomes idle for a randomly determined amount of time, and then triggers ParseMainObject(). More...
 
void EnterReadingTime ()
 Becomes idle for a randomly determined amount of time, and then triggers RequestMainObject(). More...
 
void ErrorCloseCallback (Ptr< Socket > socket)
 Invoked when connection between m_socket and the web sever is terminated. More...
 
void NormalCloseCallback (Ptr< Socket > socket)
 Invoked when connection between m_socket and the web sever is terminated. More...
 
void OpenConnection ()
 Initialize m_socket to connect to the destination web server at m_remoteServerAddress and m_remoteServerPort and set up callbacks to listen to its event. More...
 
void ParseMainObject ()
 Randomly determines the number of embedded objects in the main object. More...
 
void Receive (Ptr< Packet > packet)
 Simulate a consumption of the received packet by subtracting the packet size from the internal counter at m_objectBytesToBeReceived. More...
 
void ReceivedDataCallback (Ptr< Socket > socket)
 Invoked when m_socket receives some packet data. More...
 
void ReceiveEmbeddedObject (Ptr< Packet > packet, const Address &from)
 Receive a packet of embedded object from the destination web server. More...
 
void ReceiveMainObject (Ptr< Packet > packet, const Address &from)
 Receive a packet of main object from the destination web server. More...
 
void RequestEmbeddedObject ()
 Send a request object for an embedded object to the destination web server. More...
 
void RequestMainObject ()
 Send a request object for a main object to the destination web server. More...
 
void SwitchToState (State_t state)
 Change the state of the client. More...
 

Private Attributes

ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionClosedTrace
 The ConnectionClosed trace source. More...
 
ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionEstablishedTrace
 The ConnectionEstablished trace source. More...
 
Ptr< Packetm_constructedPacket
 The packet constructed of one or more parts with ThreeGppHttpHeader. More...
 
uint32_t m_embeddedObjectsToBeRequested
 Determined after parsing the main object. More...
 
EventId m_eventParseMainObject
 An event of ParseMainObject(), scheduled to trigger after parsing time has elapsed. More...
 
EventId m_eventRequestEmbeddedObject
 An event of either RequestEmbeddedObject() or OpenConnection(). More...
 
EventId m_eventRequestMainObject
 An event of either RequestMainObject() or OpenConnection(), scheduled to trigger after a connection has been established or reading time has elapsed. More...
 
Ptr< ThreeGppHttpVariablesm_httpVariables
 The Variables attribute. More...
 
uint32_t m_objectBytesToBeReceived
 According to the content length specified by the ThreeGppHttpHeader. More...
 
Time m_objectClientTs
 The client time stamp of the ThreeGppHttpHeader from the last received packet. More...
 
Time m_objectServerTs
 The server time stamp of the ThreeGppHttpHeader from the last received packet. More...
 
Address m_remoteServerAddress
 The RemoteServerAddress attribute. The address of the web server. More...
 
uint16_t m_remoteServerPort
 The RemoteServerPort attribute. More...
 
ns3::TracedCallback< const Time &, const Address & > m_rxDelayTrace
 The RxDelay trace source. More...
 
ns3::TracedCallback< Ptr< const Packet > > m_rxEmbeddedObjectPacketTrace
 The TxEmbeddedObjectPacket trace source. More...
 
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxEmbeddedObjectTrace
 The TxEmbeddedObject trace source. More...
 
ns3::TracedCallback< Ptr< const Packet > > m_rxMainObjectPacketTrace
 The TxMainObjectPacket trace source. More...
 
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxMainObjectTrace
 The TxMainObject trace source. More...
 
ns3::TracedCallback< const Time &, const Address & > m_rxRttTrace
 The RxRtt trace source. More...
 
ns3::TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
 The Rx trace source. More...
 
Ptr< Socketm_socket
 The socket for sending and receiving packets to/from the web server. More...
 
State_t m_state
 The current state of the client application. Begins with NOT_STARTED. More...
 
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
 The StateTransition trace source. More...
 
ns3::TracedCallback< Ptr< const Packet > > m_txEmbeddedObjectRequestTrace
 The TxEmbeddedObjectRequest trace source. More...
 
ns3::TracedCallback< Ptr< const Packet > > m_txMainObjectRequestTrace
 The TxMainObjectRequest trace source. More...
 
ns3::TracedCallback< Ptr< const Packet > > m_txTrace
 The Tx trace source. More...
 

Additional Inherited Members

- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

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::ThreeGppHttpClient"

Attributes

  • Variables: Variable collection, which is used to control e.g. timing and HTTP request size.
  • RemoteServerAddress: The address of the destination server.
    • Set with class: AddressValue
    • Underlying type: Address
    • Initial value: 00-00-00
    • Flags: construct write read
  • RemoteServerPort: The destination port of the outbound packets.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint16_t 0:65535
    • Initial value: 80
    • Flags: construct write read

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: construct write read
  • 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: construct write read

TraceSources

Size of this type is 472 bytes (on a 64-bit architecture).

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

Member Typedef Documentation

◆ 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 176 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 133 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 47 of file three-gpp-http-client.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ CancelAllPendingEvents()

void ns3::ThreeGppHttpClient::CancelAllPendingEvents ( )
private

◆ ConnectionFailedCallback()

void ns3::ThreeGppHttpClient::ConnectionFailedCallback ( Ptr< Socket socket)
private

Invoked when m_socket cannot establish a connection with the web server.

Simulation will stop and error will be raised.

Parameters
socketPointer to the socket where the event originates from.

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

References CONNECTING, GetStateString(), m_remoteServerAddress, m_remoteServerPort, m_state, NS_FATAL_ERROR, 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:

◆ ConnectionSucceededCallback()

void ns3::ThreeGppHttpClient::ConnectionSucceededCallback ( Ptr< Socket socket)
private

Invoked when a connection is established successfully on m_socket.

This triggers a request for a main object.

Parameters
socketPointer to the socket where the event originates from.

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

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

Referenced by OpenConnection().

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

◆ DoDispose()

void ns3::ThreeGppHttpClient::DoDispose ( void  )
protectedvirtual

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.

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

References ns3::Application::DoDispose(), ns3::Simulator::IsFinished(), NS_LOG_FUNCTION, and StopApplication().

+ 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 735 of file three-gpp-http-client.cc.

References ns3::Time::As(), 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 799 of file three-gpp-http-client.cc.

References ns3::Time::As(), 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 303 of file three-gpp-http-client.cc.

References CancelAllPendingEvents(), ns3::Socket::ERROR_NOTERROR, ns3::Socket::GetErrno(), 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:

◆ GetSocket()

Ptr< Socket > ns3::ThreeGppHttpClient::GetSocket ( void  ) const

Returns a pointer to the associated socket.

Returns
Pointer to the associated socket.

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

References m_socket.

◆ 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 147 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 154 of file three-gpp-http-client.cc.

References m_state.

Referenced by ConnectionFailedCallback(), ConnectionSucceededCallback(), EnterParsingTime(), EnterReadingTime(), OpenConnection(), ParseMainObject(), ReceivedDataCallback(), ReceiveEmbeddedObject(), ReceiveMainObject(), RequestEmbeddedObject(), RequestMainObject(), StartApplication(), and SwitchToState().

+ 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 161 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 283 of file three-gpp-http-client.cc.

References CancelAllPendingEvents(), ns3::Socket::ERROR_NOTERROR, ns3::Socket::GetErrno(), m_connectionClosedTrace, m_socket, ns3::MakeNullCallback(), NS_LOG_ERROR, NS_LOG_FUNCTION, and ns3::Socket::SetCloseCallbacks().

Referenced by OpenConnection().

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

◆ OpenConnection()

◆ 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 758 of file three-gpp-http-client.cc.

References EnterReadingTime(), GetStateString(), m_embeddedObjectsToBeRequested, m_eventRequestEmbeddedObject, m_httpVariables, 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 679 of file three-gpp-http-client.cc.

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::Copy(), ns3::ThreeGppHttpHeader::GetClientTs(), ns3::ThreeGppHttpHeader::GetContentLength(), ns3::ThreeGppHttpHeader::GetServerTs(), ns3::Packet::GetSize(), m_constructedPacket, m_objectBytesToBeReceived, m_objectClientTs, m_objectServerTs, NS_LOG_FUNCTION, NS_LOG_WARN, and ns3::Packet::RemoveHeader().

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

◆ 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 602 of file three-gpp-http-client.cc.

References EnterReadingTime(), EXPECTING_EMBEDDED_OBJECT, GetStateString(), ns3::Time::IsZero(), 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 540 of file three-gpp-http-client.cc.

References EnterParsingTime(), EXPECTING_MAIN_OBJECT, GetStateString(), ns3::Time::IsZero(), 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 488 of file three-gpp-http-client.cc.

References ns3::Packet::AddHeader(), CONNECTING, ns3::ThreeGppHttpHeader::EMBEDDED_OBJECT, EXPECTING_EMBEDDED_OBJECT, ns3::Socket::GetErrno(), ns3::Packet::GetSize(), GetStateString(), m_embeddedObjectsToBeRequested, m_httpVariables, m_socket, m_state, m_txEmbeddedObjectRequestTrace, 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::Socket::Send(), 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 446 of file three-gpp-http-client.cc.

References ns3::Packet::AddHeader(), CONNECTING, EXPECTING_MAIN_OBJECT, ns3::Socket::GetErrno(), ns3::Packet::GetSize(), GetStateString(), m_httpVariables, m_socket, m_state, m_txMainObjectRequestTrace, m_txTrace, ns3::ThreeGppHttpHeader::MAIN_OBJECT, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, packetSize, READING, ns3::Socket::Send(), ns3::ThreeGppHttpHeader::SetClientTs(), ns3::ThreeGppHttpHeader::SetContentLength(), ns3::ThreeGppHttpHeader::SetContentType(), and SwitchToState().

Referenced by ConnectionSucceededCallback(), and EnterReadingTime().

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

◆ StartApplication()

void ns3::ThreeGppHttpClient::StartApplication ( void  )
protectedvirtual

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 209 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:

◆ StopApplication()

void ns3::ThreeGppHttpClient::StopApplication ( void  )
protectedvirtual

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 227 of file three-gpp-http-client.cc.

References CancelAllPendingEvents(), ns3::Socket::Close(), m_socket, ns3::MakeNullCallback(), NS_LOG_FUNCTION, ns3::Socket::SetConnectCallback(), ns3::Socket::SetRecvCallback(), STOPPED, and SwitchToState().

Referenced by DoDispose().

+ 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 854 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 EnterParsingTime(), EnterReadingTime(), OpenConnection(), RequestEmbeddedObject(), RequestMainObject(), and StopApplication().

+ 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 378 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 376 of file three-gpp-http-client.h.

Referenced by ConnectionSucceededCallback(), and GetTypeId().

◆ m_constructedPacket

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

The packet constructed of one or more parts with ThreeGppHttpHeader.

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

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

◆ m_embeddedObjectsToBeRequested

uint32_t ns3::ThreeGppHttpClient::m_embeddedObjectsToBeRequested
private

Determined after parsing the main object.

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

Referenced by ConnectionSucceededCallback(), 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 418 of file three-gpp-http-client.h.

Referenced by CancelAllPendingEvents(), and EnterParsingTime().

◆ m_eventRequestEmbeddedObject

EventId ns3::ThreeGppHttpClient::m_eventRequestEmbeddedObject
private

◆ 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 409 of file three-gpp-http-client.h.

Referenced by CancelAllPendingEvents(), ConnectionSucceededCallback(), and EnterReadingTime().

◆ m_httpVariables

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

◆ m_objectBytesToBeReceived

uint32_t ns3::ThreeGppHttpClient::m_objectBytesToBeReceived
private

According to the content length specified by the ThreeGppHttpHeader.

Definition at line 354 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 358 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 360 of file three-gpp-http-client.h.

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

◆ m_remoteServerAddress

Address ns3::ThreeGppHttpClient::m_remoteServerAddress
private

The RemoteServerAddress attribute. The address of the web server.

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

Referenced by ConnectionFailedCallback(), GetTypeId(), and OpenConnection().

◆ m_remoteServerPort

uint16_t ns3::ThreeGppHttpClient::m_remoteServerPort
private

The RemoteServerPort attribute.

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

Referenced by ConnectionFailedCallback(), GetTypeId(), and OpenConnection().

◆ m_rxDelayTrace

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

The RxDelay trace source.

Definition at line 396 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 390 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 392 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 386 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 388 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceiveMainObject().

◆ m_rxRttTrace

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

The RxRtt trace source.

Definition at line 398 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 394 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and ReceivedDataCallback().

◆ m_socket

Ptr<Socket> ns3::ThreeGppHttpClient::m_socket
private

The socket for sending and receiving packets to/from the web server.

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

Referenced by ConnectionSucceededCallback(), GetSocket(), NormalCloseCallback(), OpenConnection(), RequestEmbeddedObject(), RequestMainObject(), and StopApplication().

◆ m_state

◆ m_stateTransitionTrace

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

The StateTransition trace source.

Definition at line 400 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 384 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 382 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and RequestMainObject().

◆ m_txTrace

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

The Tx trace source.

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

Referenced by GetTypeId(), RequestEmbeddedObject(), and RequestMainObject().


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