#include "three-gpp-http-server.h"
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 () const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
Assignment operator. More... | |
void | Ref () const |
Increment the reference count. More... | |
void | Unref () const |
Decrement the reference count. More... | |
Private Attributes | |
std::map< Ptr< Socket >, TxBuffer_t > | m_txBuffer |
Collection of accepted sockets and its individual transmission buffer. More... | |
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 312 of file three-gpp-http-server.h.
ns3::ThreeGppHttpServerTxBuffer::ThreeGppHttpServerTxBuffer | ( | ) |
Create an empty instance of transmission buffer.
Definition at line 628 of file three-gpp-http-server.cc.
References NS_LOG_FUNCTION.
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.
socket | Pointer to the new socket to be added (must not exist in the buffer). |
Definition at line 641 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.
void ns3::ThreeGppHttpServerTxBuffer::CloseAllSockets | ( | ) |
Close and remove all stored sockets, hence clearing the buffer.
Definition at line 712 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.
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.
socket | Pointer to the socket to be closed and removed. |
Definition at line 681 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().
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.
socket | Pointer to the socket which is associated with the transmission buffer of interest. |
amount | The length (in bytes) to be consumed (must be greater than zero). |
Definition at line 810 of file three-gpp-http-server.cc.
References CloseSocket(), m_txBuffer, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
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.
socket | Pointer to the socket which is associated with the transmission buffer of interest |
Definition at line 752 of file three-gpp-http-server.cc.
References m_txBuffer, and NS_ASSERT_MSG.
socket | Pointer to the socket which is associated with the transmission buffer of interest |
Definition at line 760 of file three-gpp-http-server.cc.
References m_txBuffer, and NS_ASSERT_MSG.
socket | Pointer to the socket which is associated with the transmission buffer of interest |
Definition at line 744 of file three-gpp-http-server.cc.
References m_txBuffer, and NS_ASSERT_MSG.
socket | pointer to the socket which is associated with the transmission buffer of interest |
This method returns true after WriteNewObject() method is called. It becomes false after DepleteBufferSize() method is called.
Definition at line 768 of file three-gpp-http-server.cc.
References m_txBuffer, and NS_ASSERT_MSG.
socket | Pointer to the socket which is associated with the transmission buffer of interest. |
Definition at line 736 of file three-gpp-http-server.cc.
References m_txBuffer, and NS_ASSERT_MSG.
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.
socket | Pointer to the socket to be found. |
Definition at line 634 of file three-gpp-http-server.cc.
References m_txBuffer.
Referenced by AddSocket().
Tell the buffer to close the associated socket once the buffer becomes empty.
socket | Pointer to the socket which is associated with the transmission buffer of interest. |
Definition at line 835 of file three-gpp-http-server.cc.
References m_txBuffer, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
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.
socket | pointer to the socket which is associated with the transmission buffer of interest |
eventId | the event to be recorded, e.g., the return value of Simulator::Schedule function |
clientTs | client time stamp |
Definition at line 797 of file three-gpp-http-server.cc.
References ns3::Time::As(), m_txBuffer, NS_ASSERT_MSG, NS_LOG_FUNCTION, and ns3::Time::S.
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.
socket | Pointer to the socket to be removed. |
Definition at line 658 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.
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.
socket | Pointer to the socket which is associated with the transmission buffer of interest. |
contentType | The content-type of the data to be written (must not equal to ThreeGppHttpHeader:NOT_SET). |
objectSize | The length (in bytes) of the new object to be created (must be greater than zero). |
Definition at line 776 of file three-gpp-http-server.cc.
References m_txBuffer, ns3::ThreeGppHttpHeader::NOT_SET, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
|
private |
Collection of accepted sockets and its individual transmission buffer.
Definition at line 550 of file three-gpp-http-server.h.
Referenced by AddSocket(), CloseAllSockets(), CloseSocket(), DepleteBufferSize(), GetBufferContentType(), GetBufferSize(), GetClientTs(), HasTxedPartOfObject(), IsBufferEmpty(), IsSocketAvailable(), PrepareClose(), RecordNextServe(), RemoveSocket(), and WriteNewObject().