A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-http-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Magister Solutions
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Budiarto Herman <budiarto.herman@magister.fi>
7 *
8 */
9
10#ifndef THREE_GPP_HTTP_HEADER_H
11#define THREE_GPP_HTTP_HEADER_H
12
13#include <ns3/header.h>
14#include <ns3/nstime.h>
15
16namespace ns3
17{
18
19class Packet;
20
21/**
22 * @ingroup http
23 * @brief Header used by web browsing applications to transmit information about
24 * content type, content length and timestamps for delay statistics.
25 *
26 * The header contains the following fields (and their respective size when
27 * serialized):
28 * - content type (2 bytes);
29 * - content length (4 bytes);
30 * - client time stamp (8 bytes); and
31 * - server time stamp (8 bytes).
32 *
33 * The header is attached to every packet transmitted by ThreeGppHttpClient and
34 * ThreeGppHttpServer applications. In received, split packets, only the first packet
35 * of transmitted object contains the header, which helps to identify how many bytes are
36 * left to be received.
37 *
38 * The last 2 fields allow the applications to compute the propagation delay of
39 * each packet. The *client TS* field indicates the time when the request
40 * packet is sent by the ThreeGppHttpClient, while the *server TS* field indicates the
41 * time when the response packet is sent by the ThreeGppHttpServer.
42 */
44{
45 public:
46 /// Creates an empty instance.
48
49 /**
50 * Returns the object TypeId.
51 * @return The object TypeId.
52 */
53 static TypeId GetTypeId();
54
55 // Inherited from ObjectBase base class.
56 TypeId GetInstanceTypeId() const override;
57
58 // Inherited from Header base class.
59 uint32_t GetSerializedSize() const override;
60 void Serialize(Buffer::Iterator start) const override;
62 void Print(std::ostream& os) const override;
63
64 /**
65 * @return The string representation of the header.
66 */
67 std::string ToString() const;
68
69 /// The possible types of content (default = NOT_SET).
71 {
72 NOT_SET, ///< Integer equivalent = 0.
73 MAIN_OBJECT, ///< Integer equivalent = 1.
74 EMBEDDED_OBJECT ///< Integer equivalent = 2.
75 };
76
77 /**
78 * @param contentType The content type.
79 */
80 void SetContentType(ContentType_t contentType);
81
82 /**
83 * @return The content type.
84 */
85 ContentType_t GetContentType() const;
86
87 /**
88 * @param contentLength The content length (in bytes).
89 */
90 void SetContentLength(uint32_t contentLength);
91
92 /**
93 * @return The content length (in bytes).
94 */
96
97 /**
98 * @param clientTs The client time stamp.
99 */
100 void SetClientTs(Time clientTs);
101
102 /**
103 * @return The client time stamp.
104 */
105 Time GetClientTs() const;
106
107 /**
108 * @param serverTs The server time stamp.
109 */
110 void SetServerTs(Time serverTs);
111
112 /**
113 * @return The server time stamp.
114 */
115 Time GetServerTs() const;
116
117 private:
118 uint16_t m_contentType; //!<" Content type field in integer format.
119 uint32_t m_contentLength; //!<" Content length field (in bytes unit).
120 uint64_t m_clientTs; //!<" Client time stamp field (in time step unit).
121 uint64_t m_serverTs; //!<" Server time stamp field (in time step unit).
122
123}; // end of `class ThreeGppHttpHeader`
124
125} // namespace ns3
126
127#endif /* THREE_GPP_HTTP_HEADER_H */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
Header used by web browsing applications to transmit information about content type,...
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
void SetContentLength(uint32_t contentLength)
void Serialize(Buffer::Iterator start) const override
void SetContentType(ContentType_t contentType)
ContentType_t
The possible types of content (default = NOT_SET).
@ NOT_SET
Integer equivalent = 0.
@ EMBEDDED_OBJECT
Integer equivalent = 2.
@ MAIN_OBJECT
Integer equivalent = 1.
ThreeGppHttpHeader()
Creates an empty instance.
uint64_t m_clientTs
" Client time stamp field (in time step unit).
uint32_t m_contentLength
" Content length field (in bytes unit).
void Print(std::ostream &os) const override
uint64_t m_serverTs
" Server time stamp field (in time step unit).
ContentType_t GetContentType() const
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t m_contentType
" Content type field in integer format.
static TypeId GetTypeId()
Returns the object TypeId.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.