Model application which simulates the traffic of a web browser. More...
#include "three-gpp-http-client.h"
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< Socket > | GetSocket () 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. | |
void | SetRemote (const Address &addr) override |
set the remote address | |
Public Member Functions inherited from ns3::SourceApplication | |
SourceApplication () | |
~SourceApplication () override | |
Address | GetRemote () const |
get the remote address | |
Public Member Functions inherited from ns3::Application | |
Application () | |
~Application () override | |
virtual int64_t | AssignStreams (int64_t stream) |
Assign a fixed random variable stream number to the random variables used by this Application object. | |
Ptr< Node > | GetNode () const |
void | SetNode (Ptr< Node > node) |
void | SetStartTime (Time start) |
Specify application start time. | |
void | SetStopTime (Time stop) |
Specify application stop time. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const 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< Object > | GetObject () 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< Object > | GetObject (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. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static 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::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_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 | 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< Packet > | m_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< ThreeGppHttpVariables > | m_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. | |
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_t > | m_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< Socket > | m_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. | |
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::SourceApplication | |
Address | m_local |
Local address to bind to. | |
Address | m_peer |
Peer address. | |
uint8_t | m_tos |
The packets Type of Service. | |
Protected Attributes inherited from ns3::Application | |
Ptr< Node > | m_node |
The node that this application is installed on. | |
EventId | m_startEvent |
The event that will fire at m_startTime to start the application. | |
Time | m_startTime |
The simulation time that the application will start. | |
EventId | m_stopEvent |
The event that will fire at m_stopTime to end the application. | |
Time | m_stopTime |
The simulation time that the application will end. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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.
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).
ns3::ThreeGppHttpClient is accessible through the following paths with Config::Set and Config::Connect:
Address
Address
Address
Time
-9.22337e+18ns:+9.22337e+18ns Time
-9.22337e+18ns:+9.22337e+18ns Size of this type is 672 bytes (on a 64-bit architecture).
Definition at line 97 of file three-gpp-http-client.h.
typedef void(* ns3::ThreeGppHttpClient::RxPageTracedCallback) (Ptr< const ThreeGppHttpClient > httpClient, const Time &time, uint32_t numObjects, uint32_t numBytes) |
Callback signature for RxPage
trace sources.
httpClient | Pointer to this instance of ThreeGppHttpClient, which is where the trace originated. |
time | Elapsed time from the start to the end of the request. |
numObjects | Number of objects downloaded, including main and embedded objects. |
numBytes | Total number of bytes included in the page. |
Definition at line 177 of file three-gpp-http-client.h.
typedef void(* ns3::ThreeGppHttpClient::TracedCallback) (Ptr< const ThreeGppHttpClient > httpClient) |
Common callback signature for ConnectionEstablished
, RxMainObject
, and RxEmbeddedObject
trace sources.
httpClient | Pointer to this instance of ThreeGppHttpClient, which is where the trace originated. |
Definition at line 166 of file three-gpp-http-client.h.
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 123 of file three-gpp-http-client.h.
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 NS_LOG_FUNCTION.
|
private |
Cancels m_eventRequestMainObject, m_eventRequestEmbeddedObject, and m_eventParseMainObject.
Invoked by StopApplication() and when connection has been terminated.
Definition at line 781 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().
Invoked when m_socket cannot establish a connection with the web server.
Simulation will stop and error will be raised.
socket | Pointer to the socket where the event originates from. |
Definition at line 274 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.
Referenced by OpenConnection().
Invoked when a connection is established successfully on m_socket.
This triggers a request for a main object.
socket | Pointer to the socket where the event originates from. |
Definition at line 257 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().
|
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 215 of file three-gpp-http-client.cc.
References ns3::Application::DoDispose(), ns3::Simulator::IsFinished(), NS_LOG_FUNCTION, and StopApplication().
|
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 705 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().
|
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 761 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().
Invoked when connection between m_socket and the web sever is terminated.
Error will be logged, but simulation continues.
socket | Pointer to the socket where the event originates from. |
Definition at line 308 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().
|
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 832 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().
Returns a pointer to the associated socket.
Definition at line 171 of file three-gpp-http-client.cc.
References m_socket.
ThreeGppHttpClient::State_t ns3::ThreeGppHttpClient::GetState | ( | ) | const |
Returns the current state of the application.
Definition at line 177 of file three-gpp-http-client.cc.
References m_state.
std::string ns3::ThreeGppHttpClient::GetStateString | ( | ) | const |
Returns the current state of the application in string format.
Definition at line 183 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().
|
static |
Returns the given state in string format.
state | An arbitrary state of an application. |
Definition at line 190 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.
|
static |
Returns the object TypeId.
Definition at line 50 of file three-gpp-http-client.cc.
References ns3::TypeId::DEPRECATED, m_connectionClosedTrace, m_connectionEstablishedTrace, m_httpVariables, m_rxDelayTrace, m_rxEmbeddedObjectPacketTrace, m_rxEmbeddedObjectTrace, m_rxMainObjectPacketTrace, m_rxMainObjectTrace, m_rxPageTrace, m_rxRttTrace, m_rxTrace, m_stateTransitionTrace, m_txEmbeddedObjectRequestTrace, m_txMainObjectRequestTrace, m_txTrace, ns3::MakeAddressAccessor(), ns3::MakeAddressChecker(), ns3::MakePointerAccessor(), ns3::MakePointerChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), ns3::TypeId::SetParent(), SetPort(), and SetRemote().
Invoked when connection between m_socket and the web sever is terminated.
Error will be logged, but simulation continues.
socket | Pointer to the socket where the event originates from. |
Definition at line 289 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().
|
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 373 of file three-gpp-http-client.cc.
References ns3::Socket::Bind(), ns3::Socket::Bind6(), ns3::Socket::Connect(), CONNECTING, ConnectionFailedCallback(), ConnectionSucceededCallback(), ns3::Inet6SocketAddress::ConvertFrom(), ns3::InetSocketAddress::ConvertFrom(), ns3::Socket::CreateSocket(), ErrorCloseCallback(), EXPECTING_EMBEDDED_OBJECT, ns3::Socket::GetErrno(), ns3::InetSocketAddress::GetIpv4(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Application::GetNode(), ns3::Inet6SocketAddress::GetPort(), ns3::InetSocketAddress::GetPort(), GetStateString(), ns3::TcpSocketFactory::GetTypeId(), ns3::Address::IsInvalid(), ns3::Inet6SocketAddress::IsMatchingType(), ns3::InetSocketAddress::IsMatchingType(), ns3::SourceApplication::m_local, ns3::SourceApplication::m_peer, m_socket, m_state, ns3::SourceApplication::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, port, READING, ReceivedDataCallback(), ns3::ObjectBase::SetAttribute(), ns3::Socket::SetCloseCallbacks(), ns3::Socket::SetConnectCallback(), ns3::Socket::SetIpTos(), ns3::Socket::SetRecvCallback(), and SwitchToState().
Referenced by StartApplication().
|
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 723 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().
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().
packet | The received packet. If it is the first packet of the object, then it must have a ThreeGppHttpHeader attached to it. |
Definition at line 649 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().
Invoked when m_socket receives some packet data.
Fires the Rx
trace source and triggers ReceiveMainObject() or ReceiveEmbeddedObject().
socket | Pointer to the socket where the event originates from. |
Definition at line 323 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().
|
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().
packet | The received packet. |
from | Address of the sender. |
Definition at line 579 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().
|
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().
packet | The received packet. |
from | Address of the sender. |
Definition at line 525 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().
|
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 479 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().
|
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 441 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().
|
private |
set the remote port (temporary function until deprecated attributes are removed)
port | remote port |
Definition at line 155 of file three-gpp-http-client.cc.
References ns3::addressUtils::ConvertToSocketAddress(), ns3::Address::IsInvalid(), ns3::Ipv4Address::IsMatchingType(), ns3::Ipv6Address::IsMatchingType(), ns3::SourceApplication::m_peer, m_peerPort, NS_LOG_FUNCTION, and port.
Referenced by GetTypeId(), and SetRemote().
|
overridevirtual |
set the remote address
addr | remote address |
Reimplemented from ns3::SourceApplication.
Definition at line 141 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().
|
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 228 of file three-gpp-http-client.cc.
References GetStateString(), m_httpVariables, m_state, NOT_STARTED, NS_FATAL_ERROR, NS_LOG_FUNCTION, and OpenConnection().
|
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 244 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().
|
private |
Change the state of the client.
Fires the StateTransition
trace source.
state | The new state. |
Definition at line 809 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().
|
private |
The ConnectionClosed
trace source.
Definition at line 399 of file three-gpp-http-client.h.
Referenced by ErrorCloseCallback(), GetTypeId(), and NormalCloseCallback().
|
private |
The ConnectionEstablished
trace source.
Definition at line 397 of file three-gpp-http-client.h.
Referenced by ConnectionSucceededCallback(), and GetTypeId().
The packet constructed of one or more parts with ThreeGppHttpHeader.
Definition at line 370 of file three-gpp-http-client.h.
Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().
|
private |
Determined after parsing the main object.
Definition at line 376 of file three-gpp-http-client.h.
Referenced by ConnectionSucceededCallback(), ParseMainObject(), ReceiveEmbeddedObject(), and RequestEmbeddedObject().
|
private |
An event of ParseMainObject(), scheduled to trigger after parsing time has elapsed.
Definition at line 439 of file three-gpp-http-client.h.
Referenced by CancelAllPendingEvents(), and EnterParsingTime().
|
private |
An event of either RequestEmbeddedObject() or OpenConnection().
Definition at line 434 of file three-gpp-http-client.h.
Referenced by CancelAllPendingEvents(), ParseMainObject(), and ReceiveEmbeddedObject().
|
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 430 of file three-gpp-http-client.h.
Referenced by CancelAllPendingEvents(), ConnectionSucceededCallback(), and EnterReadingTime().
|
private |
The Variables
attribute.
Definition at line 387 of file three-gpp-http-client.h.
Referenced by EnterParsingTime(), EnterReadingTime(), GetTypeId(), ParseMainObject(), RequestEmbeddedObject(), RequestMainObject(), and StartApplication().
|
private |
Number of bytes received for the current page.
Definition at line 382 of file three-gpp-http-client.h.
Referenced by FinishReceivingPage(), and Receive().
|
private |
Number of embedded objects to requested in the current page.
Definition at line 380 of file three-gpp-http-client.h.
Referenced by FinishReceivingPage(), and ParseMainObject().
|
private |
According to the content length specified by the ThreeGppHttpHeader.
Definition at line 368 of file three-gpp-http-client.h.
Referenced by Receive(), ReceiveEmbeddedObject(), ReceiveMainObject(), and SwitchToState().
|
private |
The client time stamp of the ThreeGppHttpHeader from the last received packet.
Definition at line 372 of file three-gpp-http-client.h.
Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().
|
private |
The server time stamp of the ThreeGppHttpHeader from the last received packet.
Definition at line 374 of file three-gpp-http-client.h.
Referenced by Receive(), ReceiveEmbeddedObject(), and ReceiveMainObject().
|
private |
The time stamp when the page started loading.
Definition at line 378 of file three-gpp-http-client.h.
Referenced by FinishReceivingPage(), and RequestMainObject().
|
private |
The RemoteServerPort
attribute.
Definition at line 389 of file three-gpp-http-client.h.
Referenced by SetPort(), and SetRemote().
|
private |
The RxDelay
trace source.
Definition at line 417 of file three-gpp-http-client.h.
Referenced by GetTypeId(), ReceiveEmbeddedObject(), and ReceiveMainObject().
|
private |
The TxEmbeddedObjectPacket
trace source.
Definition at line 411 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and ReceiveEmbeddedObject().
|
private |
The TxEmbeddedObject
trace source.
Definition at line 413 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and ReceiveEmbeddedObject().
|
private |
The TxMainObjectPacket
trace source.
Definition at line 407 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and ReceiveMainObject().
|
private |
The TxMainObject
trace source.
Definition at line 409 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and ReceiveMainObject().
|
private |
The RxPage
trace source.
Definition at line 395 of file three-gpp-http-client.h.
Referenced by FinishReceivingPage(), and GetTypeId().
|
private |
The RxRtt
trace source.
Definition at line 419 of file three-gpp-http-client.h.
Referenced by GetTypeId(), ReceiveEmbeddedObject(), and ReceiveMainObject().
|
private |
The Rx
trace source.
Definition at line 415 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and ReceivedDataCallback().
The socket for sending and receiving packets to/from the web server.
Definition at line 366 of file three-gpp-http-client.h.
Referenced by ConnectionSucceededCallback(), GetSocket(), NormalCloseCallback(), OpenConnection(), RequestEmbeddedObject(), RequestMainObject(), and StopApplication().
|
private |
The current state of the client application. Begins with NOT_STARTED.
Definition at line 364 of file three-gpp-http-client.h.
Referenced by ConnectionFailedCallback(), ConnectionSucceededCallback(), EnterParsingTime(), EnterReadingTime(), GetState(), GetStateString(), OpenConnection(), ParseMainObject(), ReceivedDataCallback(), ReceiveEmbeddedObject(), ReceiveMainObject(), RequestEmbeddedObject(), RequestMainObject(), StartApplication(), and SwitchToState().
|
private |
The StateTransition
trace source.
Definition at line 421 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and SwitchToState().
|
private |
The TxEmbeddedObjectRequest
trace source.
Definition at line 405 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and RequestEmbeddedObject().
|
private |
The TxMainObjectRequest
trace source.
Definition at line 403 of file three-gpp-http-client.h.
Referenced by GetTypeId(), and RequestMainObject().
|
private |
The Tx
trace source.
Definition at line 401 of file three-gpp-http-client.h.
Referenced by GetTypeId(), RequestEmbeddedObject(), and RequestMainObject().