A Discrete-Event Network Simulator
API
ns3::ThreeGppHttpServerTxBuffer Class Reference

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

+ Inheritance diagram for ns3::ThreeGppHttpServerTxBuffer:
+ Collaboration diagram for ns3::ThreeGppHttpServerTxBuffer:

Classes

struct  TxBuffer_t
 Set of fields representing a single transmission buffer, which will be associated with a socket. More...
 

Public Member Functions

 ThreeGppHttpServerTxBuffer ()
 Create an empty instance of transmission buffer. More...
 
void AddSocket (Ptr< Socket > socket)
 Add a new socket and create an empty transmission buffer for it. More...
 
void CloseAllSockets ()
 Close and remove all stored sockets, hence clearing the buffer. More...
 
void CloseSocket (Ptr< Socket > socket)
 Close and remove a socket and its associated transmission buffer, and then unset the socket's callback to prevent further interaction with the socket. More...
 
void DepleteBufferSize (Ptr< Socket > socket, uint32_t amount)
 Decrements a buffer size by a given amount. More...
 
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. More...
 
uint32_t GetBufferSize (Ptr< Socket > socket) const
 
Time GetClientTs (Ptr< Socket > socket) const
 
bool HasTxedPartOfObject (Ptr< Socket > socket) const
 
bool IsBufferEmpty (Ptr< Socket > socket) const
 
bool IsSocketAvailable (Ptr< Socket > socket) const
 This method is typically used before calling other methods. More...
 
void PrepareClose (Ptr< Socket > socket)
 Tell the buffer to close the associated socket once the buffer becomes empty. More...
 
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 automatically canceled in case the socket is closed. More...
 
void RemoveSocket (Ptr< Socket > socket)
 Remove a socket and its associated transmission buffer, and then unset the socket's callbacks to prevent further interaction with the socket. More...
 
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. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< ThreeGppHttpServerTxBuffer >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 

Private Attributes

std::map< Ptr< Socket >, TxBuffer_tm_txBuffer
 Collection of accepted sockets and its individual transmission buffer. More...
 

Detailed Description

Internal:

Transmission buffer used by an HTTP server instance.

The class handles the sockets which face the connected HTTP clients. An individual buffer is allocated for each socket. The buffer indicates the length (in bytes) and the type of the data within, i.e., it does not contain the actual packet data.

Types of data are expressed using the ThreeGppHttpHeader::ContentType_t type. Only one type of data can be active for one client at a time, i.e., the current content of a buffer has to be removed before a different type of data can be added.

Definition at line 316 of file three-gpp-http-server.h.

Constructor & Destructor Documentation

◆ ThreeGppHttpServerTxBuffer()

ns3::ThreeGppHttpServerTxBuffer::ThreeGppHttpServerTxBuffer ( )

Create an empty instance of transmission buffer.

Definition at line 684 of file three-gpp-http-server.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddSocket()

void ns3::ThreeGppHttpServerTxBuffer::AddSocket ( Ptr< Socket socket)

Add a new socket and create an empty transmission buffer for it.

After the method is completed, IsSocketAvailable() for the same pointer of socket shall return true.

Parameters
socketPointer to the new socket to be added (must not exist in the buffer).
Warning
Must be called only when IsSocketAvailable() for the given socket is false.

Definition at line 698 of file three-gpp-http-server.cc.

References ns3::ThreeGppHttpServerTxBuffer::TxBuffer_t::hasTxedPartOfObject, ns3::ThreeGppHttpServerTxBuffer::TxBuffer_t::isClosing, IsSocketAvailable(), m_txBuffer, ns3::ThreeGppHttpHeader::NOT_SET, NS_ASSERT_MSG, NS_LOG_FUNCTION, ns3::ThreeGppHttpServerTxBuffer::TxBuffer_t::txBufferContentType, and ns3::ThreeGppHttpServerTxBuffer::TxBuffer_t::txBufferSize.

+ Here is the call graph for this function:

◆ CloseAllSockets()

void ns3::ThreeGppHttpServerTxBuffer::CloseAllSockets ( )

Close and remove all stored sockets, hence clearing the buffer.

Definition at line 778 of file three-gpp-http-server.cc.

References ns3::Time::As(), ns3::Simulator::Cancel(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::IsExpired(), m_txBuffer, ns3::MakeNullCallback(), NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.

+ Here is the call graph for this function:

◆ CloseSocket()

void ns3::ThreeGppHttpServerTxBuffer::CloseSocket ( Ptr< Socket socket)

Close and remove a socket and its associated transmission buffer, and then unset the socket's callback to prevent further interaction with the socket.

This method is similar with RemoveSocket(), except that the latter does not close the socket.

After the method is completed, IsSocketAvailable() for the same pointer of socket shall return false.

Parameters
socketPointer to the socket to be closed and removed.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 743 of file three-gpp-http-server.cc.

References ns3::Time::As(), ns3::Simulator::Cancel(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::IsExpired(), m_txBuffer, ns3::MakeNullCallback(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_WARN, and ns3::Time::S.

Referenced by DepleteBufferSize().

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

◆ DepleteBufferSize()

void ns3::ThreeGppHttpServerTxBuffer::DepleteBufferSize ( Ptr< Socket socket,
uint32_t  amount 
)

Decrements a buffer size by a given amount.

The content type of the object to be consumed can be inquired beforehand by the GetBufferContentType() method.

If the method has consumed all the remaining bytes within the buffer, IsBufferEmpty() for the buffer shall return true.

Parameters
socketPointer to the socket which is associated with the transmission buffer of interest.
amountThe length (in bytes) to be consumed (must be greater than zero).
Warning
Must be called only when IsSocketAvailable() for the given socket is true. In addition, the requested amount must be larger than the current buffer size, which can be checked by calling the GetBufferSize() method.

Definition at line 901 of file three-gpp-http-server.cc.

References CloseSocket(), m_txBuffer, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetBufferContentType()

ThreeGppHttpHeader::ContentType_t ns3::ThreeGppHttpServerTxBuffer::GetBufferContentType ( Ptr< Socket socket) const

Returns ThreeGppHttpHeader::NOT_SET when the buffer is new and never been filled with any data before.

Otherwise, returns either ThreeGppHttpHeader::MAIN_OBJECT or ThreeGppHttpHeader::EMBEDDED_OBJECT.

Parameters
socketPointer to the socket which is associated with the transmission buffer of interest
Returns
The content type of the current data inside the transmission buffer.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 827 of file three-gpp-http-server.cc.

References m_txBuffer, and NS_ASSERT_MSG.

◆ GetBufferSize()

uint32_t ns3::ThreeGppHttpServerTxBuffer::GetBufferSize ( Ptr< Socket socket) const
Parameters
socketPointer to the socket which is associated with the transmission buffer of interest
Returns
The length (in bytes) of the current data inside the transmission buffer.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 838 of file three-gpp-http-server.cc.

References m_txBuffer, and NS_ASSERT_MSG.

◆ GetClientTs()

Time ns3::ThreeGppHttpServerTxBuffer::GetClientTs ( Ptr< Socket socket) const
Parameters
socketPointer to the socket which is associated with the transmission buffer of interest
Returns
The client time stamp that comes from the last request packet received by the given socket. It indicates the time the request packet was transmitted by the client.

Definition at line 816 of file three-gpp-http-server.cc.

References m_txBuffer, and NS_ASSERT_MSG.

◆ HasTxedPartOfObject()

bool ns3::ThreeGppHttpServerTxBuffer::HasTxedPartOfObject ( Ptr< Socket socket) const
Parameters
socketpointer to the socket which is associated with the transmission buffer of interest
Returns
true if the buffer content has been read since it is written
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

This method returns true after WriteNewObject() method is called. It becomes false after DepleteBufferSize() method is called.

Definition at line 849 of file three-gpp-http-server.cc.

References m_txBuffer, and NS_ASSERT_MSG.

◆ IsBufferEmpty()

bool ns3::ThreeGppHttpServerTxBuffer::IsBufferEmpty ( Ptr< Socket socket) const
Parameters
socketPointer to the socket which is associated with the transmission buffer of interest.
Returns
True if the current length of the transmission buffer is zero, i.e., no pending packet.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 805 of file three-gpp-http-server.cc.

References m_txBuffer, and NS_ASSERT_MSG.

◆ IsSocketAvailable()

bool ns3::ThreeGppHttpServerTxBuffer::IsSocketAvailable ( Ptr< Socket socket) const

This method is typically used before calling other methods.

For example, AddSocket() requires that the given socket does not exist among the stored buffers. On the other hand, all the other methods that accept a pointer to a socket as an argument require the existence of a buffer allocated to the given socket.

Parameters
socketPointer to the socket to be found.
Returns
True if the given socket is found within the buffer.

Definition at line 690 of file three-gpp-http-server.cc.

References m_txBuffer.

Referenced by AddSocket().

+ Here is the caller graph for this function:

◆ PrepareClose()

void ns3::ThreeGppHttpServerTxBuffer::PrepareClose ( Ptr< Socket socket)

Tell the buffer to close the associated socket once the buffer becomes empty.

Parameters
socketPointer to the socket which is associated with the transmission buffer of interest.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 929 of file three-gpp-http-server.cc.

References m_txBuffer, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

◆ RecordNextServe()

void ns3::ThreeGppHttpServerTxBuffer::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 automatically canceled in case the socket is closed.

The method also indicates the time stamp given by the client. The time stamp will be included in every packet sent.

Parameters
socketpointer to the socket which is associated with the transmission buffer of interest
eventIdthe event to be recorded, e.g., the return value of Simulator::Schedule function
clientTsclient time stamp
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 885 of file three-gpp-http-server.cc.

References ns3::Time::As(), m_txBuffer, NS_ASSERT_MSG, NS_LOG_FUNCTION, and ns3::Time::S.

+ Here is the call graph for this function:

◆ RemoveSocket()

void ns3::ThreeGppHttpServerTxBuffer::RemoveSocket ( Ptr< Socket socket)

Remove a socket and its associated transmission buffer, and then unset the socket's callbacks to prevent further interaction with the socket.

If the socket has a pending transmission event, it will be canceled.

This method is useful for discarding a socket which is already closed, e.g., by the HTTP client. This is due to the fact that double closing of a socket may introduce undefined behaviour.

After the method is completed, IsSocketAvailable() for the same pointer of socket shall return false.

Parameters
socketPointer to the socket to be removed.
Warning
Must be called only when IsSocketAvailable() for the given socket is true.

Definition at line 716 of file three-gpp-http-server.cc.

References ns3::Time::As(), ns3::Simulator::Cancel(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::IsExpired(), m_txBuffer, ns3::MakeNullCallback(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.

+ Here is the call graph for this function:

◆ WriteNewObject()

void ns3::ThreeGppHttpServerTxBuffer::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.

The stored data can be later consumed wholly of partially by DepleteBufferSize() method.

Parameters
socketPointer to the socket which is associated with the transmission buffer of interest.
contentTypeThe content-type of the data to be written (must not equal to ThreeGppHttpHeader:NOT_SET).
objectSizeThe length (in bytes) of the new object to be created (must be greater than zero).
Warning
Must be called only when both IsSocketAvailable() and IsBufferEmpty() for the given socket are true.

Definition at line 860 of file three-gpp-http-server.cc.

References m_txBuffer, ns3::ThreeGppHttpHeader::NOT_SET, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_txBuffer

std::map<Ptr<Socket>, TxBuffer_t> ns3::ThreeGppHttpServerTxBuffer::m_txBuffer
private

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