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.
 
Ptr< SocketGetSocket () const
 Returns a pointer to the associated socket.
 
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.
 
- 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 override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () 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.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
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.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy 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::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::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 CancelAllPendingEvents ()
 Cancels m_eventRequestMainObject, m_eventRequestEmbeddedObject, and m_eventParseMainObject.
 
void ConnectionFailedCallback (Ptr< Socket > socket)
 Invoked when m_socket cannot establish a connection with the web server.
 
void ConnectionSucceededCallback (Ptr< Socket > socket)
 Invoked when a connection is established successfully on m_socket.
 
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_remoteServerAddress and m_remoteServerPort 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 StartApplication () override
 Application specific startup code.
 
void StopApplication () override
 Application specific shutdown code.
 
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
 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
 Number of bytes received for the current page.
 
uint32_t m_numberEmbeddedObjectsRequested
 Number of embedded objects to requested in the current page.
 
uint32_t m_objectBytesToBeReceived
 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.
 
Address m_remoteServerAddress
 The RemoteServerAddress attribute. The address of the web server.
 
uint16_t m_remoteServerPort
 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.
 
Ptr< Socketm_socket
 The socket for sending and receiving packets to/from the web server.
 
State_t m_state
 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.
 
uint8_t m_tos
 The Tos attribute.
 
ns3::TracedCallback< Ptr< const Packet > > m_txEmbeddedObjectRequestTrace
 The TxEmbeddedObjectRequest trace source.
 
ns3::TracedCallback< Ptr< const Packet > > m_txMainObjectRequestTrace
 The TxMainObjectRequest trace source.
 
ns3::TracedCallback< Ptr< const Packet > > m_txTrace
 The Tx trace source.
 

Additional Inherited Members

- 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).

Definition at line 95 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 174 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 163 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 120 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 33 of file three-gpp-http-client.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ CancelAllPendingEvents()

void ns3::ThreeGppHttpClient::CancelAllPendingEvents ( )
private

Cancels m_eventRequestMainObject, m_eventRequestEmbeddedObject, and m_eventParseMainObject.

Invoked by StopApplication() and when connection has been terminated.

Definition at line 782 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 ErrorCloseCallback(), NormalCloseCallback(), and StopApplication().

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

◆ 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 249 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 229 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(), and ns3::Simulator::ScheduleNow().

Referenced by OpenConnection().

+ Here is the call graph for this function:
+ Here is the caller 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::Application.

Definition at line 187 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 700 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 760 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 285 of file three-gpp-http-client.cc.

References CancelAllPendingEvents(), 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 833 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:

◆ GetSocket()

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

Returns a pointer to the associated socket.

Returns
Pointer to the associated socket.

Definition at line 143 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 149 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 155 of file three-gpp-http-client.cc.

References GetStateString(), and m_state.

Referenced by ConnectionFailedCallback(), ConnectionSucceededCallback(), EnterParsingTime(), EnterReadingTime(), GetStateString(), OpenConnection(), ParseMainObject(), ReceivedDataCallback(), ReceiveEmbeddedObject(), ReceiveMainObject(), RequestEmbeddedObject(), RequestMainObject(), StartApplication(), 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 162 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 266 of file three-gpp-http-client.cc.

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

void ns3::ThreeGppHttpClient::OpenConnection ( )
private

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.

Invoked upon the start of the application.

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

References ns3::Socket::Bind(), ns3::Socket::Bind6(), ns3::Socket::Connect(), CONNECTING, ConnectionFailedCallback(), ConnectionSucceededCallback(), ns3::Ipv4Address::ConvertFrom(), ns3::Ipv6Address::ConvertFrom(), ns3::Socket::CreateSocket(), ErrorCloseCallback(), EXPECTING_EMBEDDED_OBJECT, ns3::Socket::GetErrno(), ns3::Application::GetNode(), GetStateString(), ns3::TcpSocketFactory::GetTypeId(), ns3::Address::IsInvalid(), ns3::Ipv4Address::IsMatchingType(), ns3::Ipv6Address::IsMatchingType(), m_remoteServerAddress, m_remoteServerPort, m_socket, m_state, m_tos, ns3::MakeCallback(), NormalCloseCallback(), NOT_STARTED, NS_ABORT_MSG_IF, NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, PARSING_MAIN_OBJECT, READING, ReceivedDataCallback(), ns3::ObjectBase::SetAttribute(), ns3::Socket::SetCloseCallbacks(), ns3::Socket::SetConnectCallback(), ns3::Socket::SetIpTos(), ns3::Socket::SetRecvCallback(), and SwitchToState().

Referenced by StartApplication().

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

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), 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 300 of file three-gpp-http-client.cc.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::InetSocketAddress::ConvertFrom(), EXPECTING_EMBEDDED_OBJECT, EXPECTING_MAIN_OBJECT, ns3::InetSocketAddress::GetIpv4(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::GetPort(), ns3::InetSocketAddress::GetPort(), 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 ConnectionSucceededCallback(), 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 568 of file three-gpp-http-client.cc.

References EnterReadingTime(), EXPECTING_EMBEDDED_OBJECT, FinishReceivingPage(), 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 508 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 458 of file three-gpp-http-client.cc.

References CONNECTING, ns3::Create(), ns3::ThreeGppHttpHeader::EMBEDDED_OBJECT, EXPECTING_EMBEDDED_OBJECT, ns3::Socket::GetErrno(), 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 418 of file three-gpp-http-client.cc.

References CONNECTING, ns3::Create(), EXPECTING_MAIN_OBJECT, ns3::Socket::GetErrno(), GetStateString(), m_httpVariables, m_pageLoadStartTs, 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 ( )
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 200 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 ( )
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 216 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 810 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 394 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 392 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 361 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 367 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 434 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 425 of file three-gpp-http-client.h.

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

◆ m_httpVariables

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

◆ m_numberBytesPage

uint32_t ns3::ThreeGppHttpClient::m_numberBytesPage
private

Number of bytes received for the current page.

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

Referenced by FinishReceivingPage(), and Receive().

◆ m_numberEmbeddedObjectsRequested

uint32_t ns3::ThreeGppHttpClient::m_numberEmbeddedObjectsRequested
private

Number of embedded objects to requested in the current page.

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

Referenced by FinishReceivingPage(), and ParseMainObject().

◆ m_objectBytesToBeReceived

uint32_t ns3::ThreeGppHttpClient::m_objectBytesToBeReceived
private

According to the content length specified by the ThreeGppHttpHeader.

Definition at line 359 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 363 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 365 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 369 of file three-gpp-http-client.h.

Referenced by FinishReceivingPage(), and RequestMainObject().

◆ m_remoteServerAddress

Address ns3::ThreeGppHttpClient::m_remoteServerAddress
private

The RemoteServerAddress attribute. The address of the web server.

Definition at line 380 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 382 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 412 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 406 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 408 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 402 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 404 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 390 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 414 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 410 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 357 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 416 of file three-gpp-http-client.h.

Referenced by GetTypeId(), and SwitchToState().

◆ m_tos

uint8_t ns3::ThreeGppHttpClient::m_tos
private

The Tos attribute.

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

Referenced by GetTypeId(), and OpenConnection().

◆ m_txEmbeddedObjectRequestTrace

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

The TxEmbeddedObjectRequest trace source.

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

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


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