#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. | |
void | AddSocket (Ptr< Socket > socket) |
Add a new socket and create an empty transmission buffer for it. | |
void | CloseAllSockets () |
Close and remove all stored sockets, hence clearing the buffer. | |
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. | |
void | DepleteBufferSize (Ptr< Socket > socket, uint32_t amount) |
Decrements a buffer size by a given amount. | |
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. | |
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. | |
void | PrepareClose (Ptr< Socket > socket) |
Tell the buffer to close the associated socket once the buffer becomes empty. | |
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. | |
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. | |
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. | |
Public Member Functions inherited from ns3::SimpleRefCount< ThreeGppHttpServerTxBuffer > | |
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. | |
Private Attributes | |
std::map< Ptr< Socket >, TxBuffer_t > | m_txBuffer |
Collection of accepted sockets and its individual transmission buffer. | |
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 301 of file three-gpp-http-server.h.
ns3::ThreeGppHttpServerTxBuffer::ThreeGppHttpServerTxBuffer | ( | ) |
Create an empty instance of transmission buffer.
Definition at line 632 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 645 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 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_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 685 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 814 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 756 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 764 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 748 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 772 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 740 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 638 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 839 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 801 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 662 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 780 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 539 of file three-gpp-http-server.h.
Referenced by AddSocket(), CloseAllSockets(), CloseSocket(), DepleteBufferSize(), GetBufferContentType(), GetBufferSize(), GetClientTs(), HasTxedPartOfObject(), IsBufferEmpty(), IsSocketAvailable(), PrepareClose(), RecordNextServe(), RemoveSocket(), and WriteNewObject().