A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-http-server.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 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_SERVER_H
11#define THREE_GPP_HTTP_SERVER_H
12
13#include "sink-application.h"
15
16#include <ns3/address.h>
17#include <ns3/event-id.h>
18#include <ns3/nstime.h>
19#include <ns3/ptr.h>
20#include <ns3/simple-ref-count.h>
21#include <ns3/traced-callback.h>
22
23#include <map>
24#include <optional>
25#include <ostream>
26
27namespace ns3
28{
29
30class Socket;
31class Packet;
32class ThreeGppHttpVariables;
33class ThreeGppHttpServerTxBuffer;
34
35/**
36 * @ingroup http
37 * Model application which simulates the traffic of a web server. This
38 * application works in conjunction with ThreeGppHttpClient applications.
39 *
40 * The application works by responding to requests. Each request is a small
41 * packet of data which contains ThreeGppHttpHeader. The value of the *content
42 * type* field of the header determines the type of object that the client is
43 * requesting. The possible type is either a *main object* or an *embedded
44 * object*.
45 *
46 * The application is responsible to generate the right type of object and send
47 * it back to the client. The size of each object to be sent is randomly
48 * determined (see ThreeGppHttpVariables). Each object may be sent as multiple packets
49 * due to limited socket buffer space.
50 *
51 * To assist with the transmission, the application maintains several instances
52 * of ThreeGppHttpServerTxBuffer. Each instance keeps track of the object type to be
53 * served and the number of bytes left to be sent.
54 *
55 * The application accepts connection request from clients. Every connection is
56 * kept open until the client disconnects.
57 */
59{
60 public:
61 static constexpr uint16_t HTTP_DEFAULT_PORT{80}; //!< default HTTP port
62
63 /**
64 * Creates a new instance of HTTP server application.
65 *
66 * After creation, the application must be further configured through
67 * attributes. To avoid having to do this process manually, please use
68 * ThreeGppHttpServerHelper.
69 *
70 * Upon creation, the application randomly determines the MTU size that it
71 * will use (either 536 or 1460 bytes). The chosen size will be used while
72 * creating the listener socket.
73 */
75
76 /**
77 * Returns the object TypeId.
78 * @return The object TypeId.
79 */
80 static TypeId GetTypeId();
81
82 /**
83 * Sets the maximum transmission unit (MTU) size used by the application.
84 *
85 * This overrides the MTU size which is randomly determined once the
86 * application is created. Values other than the standard 536 and 1460 bytes
87 * can be set using this method.
88 *
89 * @param mtuSize MTU size in bytes.
90 */
91 void SetMtuSize(uint32_t mtuSize);
92
93 /**
94 * Returns a pointer to the listening socket.
95 * @return Pointer to the listening socket
96 */
97 Ptr<Socket> GetSocket() const;
98
99 /// The possible states of the application.
101 {
102 NOT_STARTED = 0, ///< Before StartApplication() is invoked.
103 STARTED, ///< Passively listening and responding to requests.
104 STOPPED ///< After StopApplication() is invoked.
105 };
106
107 /**
108 * Returns the current state of the application.
109 * @return The current state of the application.
110 */
111 State_t GetState() const;
112
113 /**
114 * Returns the current state of the application in string format.
115 * @return The current state of the application in string format.
116 */
117 std::string GetStateString() const;
118
119 /**
120 * Returns the given state in string format.
121 * @param state An arbitrary state of an application.
122 * @return The given state equivalently expressed in string format.
123 */
124 static std::string GetStateString(State_t state);
125
126 /**
127 * Common callback signature for `MainObject` and `EmbeddedObject` trace
128 * sources.
129 * @param size Size of the generated object in bytes.
130 */
132
133 /**
134 * Callback signature for `ConnectionEstablished` trace source.
135 * @param httpServer Pointer to this instance of ThreeGppHttpServer, which is where
136 * the trace originated.
137 * @param socket Pointer to the socket where the connection is established.
138 */
140 Ptr<Socket> socket);
141
142 protected:
143 void DoDispose() override;
144
145 private:
146 void StartApplication() override;
147 void StopApplication() override;
148 void SetLocal(const Address& addr) override;
149 void SetPort(uint32_t port) override;
150
151 // SOCKET CALLBACK METHODS
152
153 /**
154 * Invoked when #m_initialSocket receives a connection request.
155 * @param socket Pointer to the socket where the event originates from.
156 * @param address The address of the remote client where the connection
157 * request comes from.
158 * @return Always true, to indicate to the other end that the connection
159 * request is accepted.
160 */
161 bool ConnectionRequestCallback(Ptr<Socket> socket, const Address& address);
162 /**
163 * Invoked when a new connection has been established.
164 * @param socket Pointer to the socket that maintains the connection to the
165 * remote client. This socket will be saved to the Tx buffer.
166 * @param address The address the connection is incoming from.
167 */
168 void NewConnectionCreatedCallback(Ptr<Socket> socket, const Address& address);
169 /**
170 * Invoked when a connection with a web client is terminated. The
171 * corresponding socket will be removed from Tx buffer.
172 * @param socket Pointer to the socket where the event originates from.
173 */
174 void NormalCloseCallback(Ptr<Socket> socket);
175 /**
176 * Invoked when a connection with a web client is terminated. The
177 * corresponding socket will be removed from Tx buffer.
178 * @param socket Pointer to the socket where the event originates from.
179 */
180 void ErrorCloseCallback(Ptr<Socket> socket);
181 /**
182 * Invoked when #m_initialSocket receives some packet data. It will check the
183 * packet for ThreeGppHttpHeader. It also fires the `Rx` trace source.
184 *
185 * Depending on the type of object requested, the method will trigger
186 * ServeMainObject() or ServeEmbeddedObject() after some delays.
187 *
188 * @param socket Pointer to the socket where the event originates from.
189 */
191 /**
192 * Invoked when more buffer space for transmission is added to a socket. The
193 * method will invoke ServeFromTxBuffer() to start some transmission using
194 * the socket.
195 * @param socket Pointer to the socket where the event originates from.
196 * @param availableBufferSize The number of bytes available in the socket's
197 * transmission buffer.
198 */
199 void SendCallback(Ptr<Socket> socket, uint32_t availableBufferSize);
200
201 // TX-RELATED METHODS
202
203 /**
204 * Generates a new main object and push it into the Tx buffer.
205 *
206 * The size of the object is randomly determined by ThreeGppHttpVariables.
207 * Fires the `MainObject` trace source. It then immediately triggers
208 * ServeFromTxBuffer() to send the object.
209 *
210 * @param socket Pointer to the socket which is associated with the
211 * destination client.
212 */
213 void ServeNewMainObject(Ptr<Socket> socket);
214 /**
215 * Generates a new embedded object and push it into the Tx buffer.
216 *
217 * The size of the object is randomly determined by ThreeGppHttpVariables.
218 * Fires the `EmbeddedObject` trace source. It then immediately triggers
219 * ServeFromTxBuffer() to send the object.
220 *
221 * @param socket Pointer to the socket which is associated with the
222 * destination client.
223 */
225 /**
226 * Creates a packet out of a pending object in the Tx buffer send it over the
227 * given socket. If the socket capacity is smaller than the object size, then
228 * the method only convert a part of the object into a packet.
229 *
230 * ThreeGppHttpHeader will be attached in the beginning of each application
231 * layer packet - if a packet is split, then then the following parts will
232 * not have the header. The method fires the `Tx` trace source after sending
233 * the packet to the socket.
234 *
235 * This method is invoked when a new object is generated by
236 * ServeNewMainObject() or ServeNewEmbeddedObject(). It's also invoked when
237 * the socket informs (through SendCallback()) that more buffer space for
238 * transmission has become available.
239 *
240 * @param socket Pointer to the socket which is associated with the
241 * destination client.
242 * @return Size of the packet sent (in bytes).
243 */
245
246 /**
247 * Change the state of the server. Fires the `StateTransition` trace source.
248 * @param state The new state.
249 */
250 void SwitchToState(State_t state);
251
252 /// The current state of the client application. Begins with NOT_STARTED.
254 /// The listening socket, for receiving connection requests from clients.
256 /// Pointer to the transmission buffer.
258
259 // ATTRIBUTES
260
261 /// The `Variables` attribute.
263 /// The `LocalPort` attribute.
264 /// Note: this is a trick needed because we have 2 ports attributes, Port and LocalPort, where
265 /// the latter is deprecated and hence this will actually go away once we can remove deprecated
266 /// attributes and code.
267 std::optional<uint16_t> m_optPort;
268 /// The `Tos` attribute.
269 uint8_t m_tos;
270 /// The `Mtu` attribute.
272
273 // TRACE SOURCES
274
275 /// The `ConnectionEstablished` trace source.
277 /// The `MainObject` trace source.
279 /// The `EmbeddedObject` trace source.
281 /// The `Tx` trace source.
283 /// The `Rx` trace source.
285 /// The `Rx` trace source with the local address.
287 /// The `RxDelay` trace source.
289 /// The `StateTransition` trace source.
291
292}; // end of `class ThreeGppHttpServer`
293
294/**
295 * @internal
296 * @ingroup http
297 * Transmission buffer used by an HTTP server instance.
298 *
299 * The class handles the sockets which face the connected HTTP clients. An
300 * individual buffer is allocated for each socket. The buffer indicates the
301 * length (in bytes) and the type of the data within, i.e., it does *not*
302 * contain the actual packet data.
303 *
304 * Types of data are expressed using the ThreeGppHttpHeader::ContentType_t type. Only one
305 * type of data can be active for one client at a time, i.e., the current
306 * content of a buffer has to be removed before a different type of data can
307 * be added.
308 */
309class ThreeGppHttpServerTxBuffer : public SimpleRefCount<ThreeGppHttpServerTxBuffer>
310{
311 public:
312 /// Create an empty instance of transmission buffer.
314
315 // SOCKET MANAGEMENT
316
317 /**
318 * This method is typically used before calling other methods. For example,
319 * AddSocket() requires that the given socket does not exist among the stored
320 * buffers. On the other hand, all the other methods that accept a pointer to
321 * a socket as an argument require the existence of a buffer allocated to the
322 * given socket.
323 * @param socket Pointer to the socket to be found.
324 * @return True if the given socket is found within the buffer.
325 */
326 bool IsSocketAvailable(Ptr<Socket> socket) const;
327
328 /**
329 * Add a new socket and create an empty transmission buffer for it. After the
330 * method is completed, IsSocketAvailable() for the same pointer of socket
331 * shall return true.
332 * @param socket Pointer to the new socket to be added (must not exist in the
333 * buffer).
334 * @warning Must be called only when IsSocketAvailable() for the given socket
335 * is false.
336 */
337 void AddSocket(Ptr<Socket> socket);
338
339 /**
340 * Remove a socket and its associated transmission buffer, and then unset the
341 * socket's callbacks to prevent further interaction with the socket. If the
342 * socket has a pending transmission event, it will be canceled.
343 *
344 * This method is useful for discarding a socket which is already closed,
345 * e.g., by the HTTP client. This is due to the fact that double closing of a
346 * socket may introduce undefined behaviour.
347 *
348 * After the method is completed, IsSocketAvailable() for the same pointer of
349 * socket shall return false.
350 *
351 * @param socket Pointer to the socket to be removed.
352 * @warning Must be called only when IsSocketAvailable() for the given socket
353 * is true.
354 */
355 void RemoveSocket(Ptr<Socket> socket);
356
357 /**
358 * Close and remove a socket and its associated transmission buffer, and then
359 * unset the socket's callback to prevent further interaction with the
360 * socket.
361 *
362 * This method is similar with RemoveSocket(), except that the latter does
363 * not close the socket.
364 *
365 * After the method is completed, IsSocketAvailable() for the same pointer of
366 * socket shall return false.
367 *
368 * @param socket Pointer to the socket to be closed and removed.
369 * @warning Must be called only when IsSocketAvailable() for the given socket
370 * is true.
371 */
372 void CloseSocket(Ptr<Socket> socket);
373
374 /**
375 * Close and remove all stored sockets, hence clearing the buffer.
376 */
377 void CloseAllSockets();
378
379 // BUFFER MANAGEMENT
380
381 /**
382 * @param socket Pointer to the socket which is associated with the
383 * transmission buffer of interest.
384 * @return True if the current length of the transmission buffer is zero,
385 * i.e., no pending packet.
386 * @warning Must be called only when IsSocketAvailable() for the given socket
387 * is true.
388 */
389 bool IsBufferEmpty(Ptr<Socket> socket) const;
390
391 /**
392 * @param socket Pointer to the socket which is associated with the
393 * transmission buffer of interest
394 * @return The client time stamp that comes from the last request packet
395 * received by the given socket. It indicates the time the request
396 * packet was transmitted by the client.
397 */
398 Time GetClientTs(Ptr<Socket> socket) const;
399
400 /**
401 * Returns ThreeGppHttpHeader::NOT_SET when the buffer is new and never been filled
402 * with any data before. Otherwise, returns either ThreeGppHttpHeader::MAIN_OBJECT
403 * or ThreeGppHttpHeader::EMBEDDED_OBJECT.
404 * @param socket Pointer to the socket which is associated with the
405 * transmission buffer of interest
406 * @return The content type of the current data inside the transmission
407 * buffer.
408 * @warning Must be called only when IsSocketAvailable() for the given socket
409 * is true.
410 */
412
413 /**
414 * @param socket Pointer to the socket which is associated with the
415 * transmission buffer of interest
416 * @return The length (in bytes) of the current data inside the transmission
417 * buffer.
418 * @warning Must be called only when IsSocketAvailable() for the given socket
419 * is true.
420 */
421 uint32_t GetBufferSize(Ptr<Socket> socket) const;
422
423 /**
424 * @param socket pointer to the socket which is associated with the
425 * transmission buffer of interest
426 * @return true if the buffer content has been read since it is written
427 *
428 * @warning Must be called only when IsSocketAvailable() for the given socket
429 * is true.
430 *
431 * This method returns true after WriteNewObject() method is called. It
432 * becomes false after DepleteBufferSize() method is called.
433 */
434 bool HasTxedPartOfObject(Ptr<Socket> socket) const;
435
436 /**
437 * Writes a data representing a new main object or embedded object to the
438 * transmission buffer.
439 *
440 * The stored data can be later consumed wholly of partially by
441 * DepleteBufferSize() method.
442 *
443 * @param socket Pointer to the socket which is associated with the
444 * transmission buffer of interest.
445 * @param contentType The content-type of the data to be written (must not
446 * equal to ThreeGppHttpHeader:NOT_SET).
447 * @param objectSize The length (in bytes) of the new object to be created
448 * (must be greater than zero).
449 * @warning Must be called only when both IsSocketAvailable() and
450 * IsBufferEmpty() for the given socket are true.
451 */
452 void WriteNewObject(Ptr<Socket> socket,
454 uint32_t objectSize);
455
456 /**
457 * Informs about a pending transmission event associated with the socket, so
458 * that it would be automatically canceled in case the socket is closed.
459 *
460 * The method also indicates the time stamp given by the client. The time
461 * stamp will be included in every packet sent.
462 *
463 * @param socket pointer to the socket which is associated with the
464 * transmission buffer of interest
465 * @param eventId the event to be recorded, e.g., the return value of
466 * Simulator::Schedule function
467 * @param clientTs client time stamp
468 *
469 * @warning Must be called only when IsSocketAvailable() for the given socket
470 * is true.
471 */
472 void RecordNextServe(Ptr<Socket> socket, const EventId& eventId, const Time& clientTs);
473
474 /**
475 * Decrements a buffer size by a given amount.
476 *
477 * The content type of the object to be consumed can be inquired beforehand
478 * by the GetBufferContentType() method.
479 *
480 * If the method has consumed all the remaining bytes within the buffer,
481 * IsBufferEmpty() for the buffer shall return true.
482 *
483 * @param socket Pointer to the socket which is associated with the
484 * transmission buffer of interest.
485 * @param amount The length (in bytes) to be consumed (must be greater than
486 * zero).
487 *
488 * @warning Must be called only when IsSocketAvailable() for the given socket
489 * is true. In addition, the requested amount must be larger than
490 * the current buffer size, which can be checked by calling the
491 * GetBufferSize() method.
492 */
493 void DepleteBufferSize(Ptr<Socket> socket, uint32_t amount);
494
495 /**
496 * Tell the buffer to close the associated socket once the buffer becomes
497 * empty.
498 * @param socket Pointer to the socket which is associated with the
499 * transmission buffer of interest.
500 * @warning Must be called only when IsSocketAvailable() for the given socket
501 * is true.
502 */
503 void PrepareClose(Ptr<Socket> socket);
504
505 private:
506 /**
507 * Set of fields representing a single transmission buffer, which will be
508 * associated with a socket.
509 */
511 {
512 /**
513 * Pending transmission event which will be automatically canceled when the
514 * associated socket is closed.
515 */
517 /**
518 * The client time stamp that comes from the request packet. This value
519 * will be set in ThreeGppHttpHeader of every corresponding response packet sent, to
520 * be used by the client to compute round trip delay time (RTT).
521 */
523 /**
524 * The content type of the current data inside the transmission buffer.
525 * Accessible using the GetBufferContentType() method.
526 */
528 /**
529 * The length (in bytes) of the current data inside the transmission
530 * buffer. Accessible using the GetBufferSize() method.
531 */
533 /**
534 * True if the remote end has issued a request to close, which means that
535 * this socket will immediately closes itself once the buffer becomes
536 * empty.
537 */
539 /**
540 * @brief True if the buffer content has been read since it is written.
541 * Accessible using the HasTxedPartOfObject() method.
542 */
544 };
545
546 /// Collection of accepted sockets and its individual transmission buffer.
547 std::map<Ptr<Socket>, TxBuffer_t> m_txBuffer;
548
549}; // end of `class ThreeGppHttpServerTxBuffer`
550
551} // namespace ns3
552
553#endif /* THREE_GPP_HTTP_SERVER_H */
a polymophic address class
Definition address.h:90
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Base class for sink applications.
ContentType_t
The possible types of content (default = NOT_SET).
Model application which simulates the traffic of a web server.
static constexpr uint16_t HTTP_DEFAULT_PORT
default HTTP port
State_t
The possible states of the application.
@ NOT_STARTED
Before StartApplication() is invoked.
@ STOPPED
After StopApplication() is invoked.
@ STARTED
Passively listening and responding to requests.
void StartApplication() override
Application specific startup code.
uint32_t ServeFromTxBuffer(Ptr< Socket > socket)
Creates a packet out of a pending object in the Tx buffer send it over the given socket.
State_t m_state
The current state of the client application. Begins with NOT_STARTED.
void(* ThreeGppHttpObjectCallback)(uint32_t size)
Common callback signature for MainObject and EmbeddedObject trace sources.
Ptr< ThreeGppHttpVariables > m_httpVariables
The Variables attribute.
void SetLocal(const Address &addr) override
set the local address
TracedCallback< uint32_t > m_embeddedObjectTrace
The EmbeddedObject trace source.
void ReceivedDataCallback(Ptr< Socket > socket)
Invoked when m_initialSocket receives some packet data.
void ServeNewMainObject(Ptr< Socket > socket)
Generates a new main object and push it into the Tx buffer.
TracedCallback< uint32_t > m_mainObjectTrace
The MainObject trace source.
uint32_t m_mtuSize
The Mtu attribute.
TracedCallback< const Time &, const Address & > m_rxDelayTrace
The RxDelay trace source.
State_t GetState() const
Returns the current state of the application.
Ptr< ThreeGppHttpServerTxBuffer > m_txBuffer
Pointer to the transmission buffer.
void(* ConnectionEstablishedCallback)(Ptr< const ThreeGppHttpServer > httpServer, Ptr< Socket > socket)
Callback signature for ConnectionEstablished trace source.
bool ConnectionRequestCallback(Ptr< Socket > socket, const Address &address)
Invoked when m_initialSocket receives a connection request.
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_rxTraceWithAddresses
The Rx trace source with the local address.
void ServeNewEmbeddedObject(Ptr< Socket > socket)
Generates a new embedded object and push it into the Tx buffer.
TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
void ErrorCloseCallback(Ptr< Socket > socket)
Invoked when a connection with a web client is terminated.
void SendCallback(Ptr< Socket > socket, uint32_t availableBufferSize)
Invoked when more buffer space for transmission is added to a socket.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
The Rx trace source.
uint8_t m_tos
The Tos attribute.
Ptr< Socket > GetSocket() const
Returns a pointer to the listening socket.
TracedCallback< Ptr< const ThreeGppHttpServer >, Ptr< Socket > > m_connectionEstablishedTrace
The ConnectionEstablished trace source.
Ptr< Socket > m_initialSocket
The listening socket, for receiving connection requests from clients.
static TypeId GetTypeId()
Returns the object TypeId.
std::string GetStateString() const
Returns the current state of the application in string format.
ThreeGppHttpServer()
Creates a new instance of HTTP server application.
TracedCallback< Ptr< const Packet > > m_txTrace
The Tx trace source.
void NormalCloseCallback(Ptr< Socket > socket)
Invoked when a connection with a web client is terminated.
void DoDispose() override
Destructor implementation.
void StopApplication() override
Application specific shutdown code.
void NewConnectionCreatedCallback(Ptr< Socket > socket, const Address &address)
Invoked when a new connection has been established.
void SetMtuSize(uint32_t mtuSize)
Sets the maximum transmission unit (MTU) size used by the application.
std::optional< uint16_t > m_optPort
The LocalPort attribute.
void SwitchToState(State_t state)
Change the state of the server.
void SetPort(uint32_t port) override
set the server port
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
void CloseAllSockets()
Close and remove all stored sockets, hence clearing the buffer.
bool HasTxedPartOfObject(Ptr< Socket > socket) const
void PrepareClose(Ptr< Socket > socket)
Tell the buffer to close the associated socket once the buffer becomes empty.
Time GetClientTs(Ptr< Socket > socket) const
void CloseSocket(Ptr< Socket > socket)
Close and remove a socket and its associated transmission buffer, and then unset the socket's callbac...
ThreeGppHttpServerTxBuffer()
Create an empty instance of transmission buffer.
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...
std::map< Ptr< Socket >, TxBuffer_t > m_txBuffer
Collection of accepted sockets and its individual transmission buffer.
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.
bool IsBufferEmpty(Ptr< Socket > socket) const
bool IsSocketAvailable(Ptr< Socket > socket) const
This method is typically used before calling other methods.
void AddSocket(Ptr< Socket > socket)
Add a new socket and create an empty transmission buffer for it.
void RemoveSocket(Ptr< Socket > socket)
Remove a socket and its associated transmission buffer, and then unset the socket's callbacks to prev...
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
uint16_t port
Definition dsdv-manet.cc:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Set of fields representing a single transmission buffer, which will be associated with a socket.
ThreeGppHttpHeader::ContentType_t txBufferContentType
The content type of the current data inside the transmission buffer.
uint32_t txBufferSize
The length (in bytes) of the current data inside the transmission buffer.
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...
bool hasTxedPartOfObject
True if the buffer content has been read since it is written.
Time clientTs
The client time stamp that comes from the request packet.