|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #ifndef THREE_GPP_HTTP_SERVER_H
23 #define THREE_GPP_HTTP_SERVER_H
26 #include <ns3/simple-ref-count.h>
27 #include <ns3/nstime.h>
28 #include <ns3/event-id.h>
29 #include <ns3/three-gpp-http-header.h>
30 #include <ns3/application.h>
31 #include <ns3/address.h>
32 #include <ns3/traced-callback.h>
42 class ThreeGppHttpVariables;
43 class ThreeGppHttpServerTxBuffer;
461 uint32_t objectSize);
481 const Time &clientTs);
a unique identifier for an interface.
void NewConnectionCreatedCallback(Ptr< Socket > socket, const Address &address)
Invoked when a new connection has been established.
State_t
The possible states of the application.
virtual void StopApplication()
Application specific shutdown code.
void CloseAllSockets()
Close and remove all stored sockets, hence clearing the buffer.
An identifier for simulation events.
State_t GetState() const
Returns the current state of the application.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ThreeGppHttpServerTxBuffer()
Create an empty instance of transmission buffer.
bool HasTxedPartOfObject(Ptr< Socket > socket) const
virtual void StartApplication()
Application specific startup code.
void SetMtuSize(uint32_t mtuSize)
Sets the maximum transmission unit (MTU) size used by the application.
uint32_t GetBufferSize(Ptr< Socket > socket) const
uint16_t m_localPort
The LocalPort attribute.
Address m_localAddress
The LocalAddress attribute.
void NormalCloseCallback(Ptr< Socket > socket)
Invoked when a connection with a web client is terminated.
bool hasTxedPartOfObject
True if the buffer content has been read since it is written.
A template-based reference counting class.
uint32_t m_mtuSize
The Mtu attribute.
bool IsSocketAvailable(Ptr< Socket > socket) const
This method is typically used before calling other methods.
void CloseSocket(Ptr< Socket > socket)
Close and remove a socket and its associated transmission buffer, and then unset the socket's callbac...
ThreeGppHttpServer()
Creates a new instance of HTTP server application.
void ServeNewMainObject(Ptr< Socket > socket)
Generates a new main object and push it into the Tx buffer.
Ptr< Socket > m_initialSocket
The listening socket, for receiving connection requests from clients.
void RemoveSocket(Ptr< Socket > socket)
Remove a socket and its associated transmission buffer, and then unset the socket's callbacks to prev...
ThreeGppHttpHeader::ContentType_t txBufferContentType
The content type of the current data inside the transmission buffer.
void AddSocket(Ptr< Socket > socket)
Add a new socket and create an empty transmission buffer for it.
ThreeGppHttpHeader::ContentType_t GetBufferContentType(Ptr< Socket > socket) const
Returns ThreeGppHttpHeader::NOT_SET when the buffer is new and never been filled with any data before...
EventId nextServe
Pending transmission event which will be automatically canceled when the associated socket is closed.
bool isClosing
True if the remote end has issued a request to close, which means that this socket will immediately c...
void ServeNewEmbeddedObject(Ptr< Socket > socket)
Generates a new embedded object and push it into the Tx buffer.
Set of fields representing a single transmission buffer, which will be associated with a socket.
Time GetClientTs(Ptr< Socket > socket) const
void PrepareClose(Ptr< Socket > socket)
Tell the buffer to close the associated socket once the buffer becomes empty.
Time clientTs
The client time stamp that comes from the request packet.
Ptr< ThreeGppHttpVariables > m_httpVariables
The Variables attribute.
void ReceivedDataCallback(Ptr< Socket > socket)
Invoked when m_initialSocket receives some packet data.
@ STOPPED
After StopApplication() is invoked.
a polymophic address class
@ NOT_STARTED
Before StartApplication() is invoked.
bool ConnectionRequestCallback(Ptr< Socket > socket, const Address &address)
Invoked when m_initialSocket receives a connection request.
Simulation virtual time values and global simulation resolution.
Ptr< Socket > GetSocket() const
Returns a pointer to the listening socket.
bool IsBufferEmpty(Ptr< Socket > socket) const
TracedCallback< const Time &, const Address & > m_rxDelayTrace
The RxDelay trace source.
void DepleteBufferSize(Ptr< Socket > socket, uint32_t amount)
Decrements a buffer size by a given amount.
Ptr< ThreeGppHttpServerTxBuffer > m_txBuffer
Pointer to the transmission buffer.
virtual void DoDispose()
Destructor implementation.
State_t m_state
The current state of the client application. Begins with NOT_STARTED.
void RecordNextServe(Ptr< Socket > socket, const EventId &eventId, const Time &clientTs)
Informs about a pending transmission event associated with the socket, so that it would be automatica...
void ErrorCloseCallback(Ptr< Socket > socket)
Invoked when a connection with a web client is terminated.
Model application which simulates the traffic of a web server.
uint32_t ServeFromTxBuffer(Ptr< Socket > socket)
Creates a packet out of a pending object in the Tx buffer send it over the given socket.
void(* ThreeGppHttpObjectCallback)(uint32_t size)
Common callback signature for MainObject and EmbeddedObject trace sources.
std::map< Ptr< Socket >, TxBuffer_t > m_txBuffer
Collection of accepted sockets and its individual transmission buffer.
TracedCallback< uint32_t > m_embeddedObjectTrace
The EmbeddedObject trace source.
void WriteNewObject(Ptr< Socket > socket, ThreeGppHttpHeader::ContentType_t contentType, uint32_t objectSize)
Writes a data representing a new main object or embedded object to the transmission buffer.
std::string GetStateString() const
Returns the current state of the application in string format.
TracedCallback< uint32_t > m_mainObjectTrace
The MainObject trace source.
TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
Forward calls to a chain of Callback.
uint32_t txBufferSize
The length (in bytes) of the current data inside the transmission buffer.
void SendCallback(Ptr< Socket > socket, uint32_t availableBufferSize)
Invoked when more buffer space for transmission is added to a socket.
static TypeId GetTypeId()
Returns the object TypeId.
The base class for all ns3 applications.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
The Rx trace source.
void SwitchToState(State_t state)
Change the state of the server.
TracedCallback< Ptr< const ThreeGppHttpServer >, Ptr< Socket > > m_connectionEstablishedTrace
The ConnectionEstablished trace source.
void(* ConnectionEstablishedCallback)(Ptr< const ThreeGppHttpServer > httpServer, Ptr< Socket > socket)
Callback signature for ConnectionEstablished trace source.
TracedCallback< Ptr< const Packet > > m_txTrace
The Tx trace source.
@ STARTED
Passively listening and responding to requests.