A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-http-client.cc
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
11
13
14#include "ns3/address-utils.h"
15#include "ns3/callback.h"
16#include "ns3/double.h"
17#include "ns3/log.h"
18#include "ns3/packet.h"
19#include "ns3/pointer.h"
20#include "ns3/simulator.h"
21#include "ns3/socket.h"
22#include "ns3/tcp-socket-factory.h"
23#include "ns3/uinteger.h"
24
25NS_LOG_COMPONENT_DEFINE("ThreeGppHttpClient");
26
27namespace ns3
28{
29
31
39
40// static
43{
44 static TypeId tid =
45 TypeId("ns3::ThreeGppHttpClient")
47 .AddConstructor<ThreeGppHttpClient>()
48 .AddAttribute(
49 "Variables",
50 "Variable collection, which is used to control e.g. timing and HTTP request size.",
54 // NS_DEPRECATED_3_44
55 .AddAttribute("RemoteServerAddress",
56 "The address of the destination server.",
61 "Replaced by Remote in ns-3.44.")
62 // NS_DEPRECATED_3_44
63 .AddAttribute("RemoteServerPort",
64 "The destination port of the outbound packets.",
65 UintegerValue(80), // the default HTTP port
69 "Replaced by Remote in ns-3.44.")
70 .AddTraceSource("RxPage",
71 "A page has been received.",
73 "ns3::ThreeGppHttpClient::RxPageTracedCallback")
74 .AddTraceSource(
75 "ConnectionEstablished",
76 "Connection to the destination web server has been established.",
78 "ns3::ThreeGppHttpClient::TracedCallback")
79 .AddTraceSource("ConnectionClosed",
80 "Connection to the destination web server is closed.",
82 "ns3::ThreeGppHttpClient::TracedCallback")
83 .AddTraceSource(
84 "TxMainObjectRequest",
85 "Sent a request for a main object.",
87 "ns3::Packet::TracedCallback")
88 .AddTraceSource(
89 "TxEmbeddedObjectRequest",
90 "Sent a request for an embedded object.",
92 "ns3::Packet::TracedCallback")
93 .AddTraceSource("RxMainObjectPacket",
94 "A packet of main object has been received.",
96 "ns3::Packet::TracedCallback")
97 .AddTraceSource("RxMainObject",
98 "Received a whole main object. Header is included.",
100 "ns3::ThreeGppHttpClient::TracedCallback")
101 .AddTraceSource(
102 "RxEmbeddedObjectPacket",
103 "A packet of embedded object has been received.",
105 "ns3::Packet::TracedCallback")
106 .AddTraceSource("RxEmbeddedObject",
107 "Received a whole embedded object. Header is included.",
109 "ns3::ThreeGppHttpClient::TracedCallback")
110 .AddTraceSource("Rx",
111 "General trace for receiving a packet of any kind.",
113 "ns3::Packet::PacketAddressTracedCallback")
114 .AddTraceSource("RxDelay",
115 "General trace of delay for receiving a complete object.",
117 "ns3::Application::DelayAddressCallback")
118 .AddTraceSource(
119 "RxRtt",
120 "General trace of round trip delay time for receiving a complete object.",
122 "ns3::Application::DelayAddressCallback")
123 .AddTraceSource("StateTransition",
124 "Trace fired upon every HTTP client state transition.",
126 "ns3::Application::StateTransitionCallback");
127 return tid;
128}
129
130void
132{
133 NS_LOG_FUNCTION(this << addr);
134 if (!addr.IsInvalid())
135 {
136 m_peer = addr;
137 if (m_peerPort)
138 {
140 }
141 }
142}
143
144void
146{
147 NS_LOG_FUNCTION(this << port);
148 if (m_peer.IsInvalid())
149 {
150 // save for later
152 return;
153 }
155 {
157 }
158}
159
162{
163 return m_state;
164}
165
166std::string
171
172// static
173std::string
175{
176 switch (state)
177 {
178 case NOT_STARTED:
179 return "NOT_STARTED";
180 case CONNECTING:
181 return "CONNECTING";
183 return "EXPECTING_MAIN_OBJECT";
185 return "PARSING_MAIN_OBJECT";
187 return "EXPECTING_EMBEDDED_OBJECT";
188 case READING:
189 return "READING";
190 case STOPPED:
191 return "STOPPED";
192 default:
193 NS_FATAL_ERROR("Unknown state");
194 return "FATAL_ERROR";
195 }
196}
197
198void
200{
201 NS_LOG_FUNCTION(this);
202
204 {
205 CancelEvents();
206 CloseSocket();
207 }
208
209 SourceApplication::DoDispose(); // Chain up.
210}
211
212void
214{
215 NS_LOG_FUNCTION(this);
216
217 if (m_state == NOT_STARTED)
218 {
219 m_httpVariables->Initialize();
221 }
222 else
223 {
224 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for StartApplication().");
225 }
226}
227
228void
234
235void
237{
238 NS_LOG_FUNCTION(this << socket);
239
240 if (m_state != CONNECTING)
241 {
242 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ConnectionSucceeded().");
243 }
244
245 NS_ASSERT_MSG(m_socket == socket, "Invalid socket.");
247 socket->SetRecvCallback(MakeCallback(&ThreeGppHttpClient::ReceivedDataCallback, this));
250}
251
252void
254{
255 NS_LOG_FUNCTION(this << socket);
256
257 if (m_state == CONNECTING)
258 {
259 NS_LOG_ERROR("Client failed to connect to remote address " << m_peer);
260 }
261 else
262 {
263 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ConnectionFailed().");
264 }
265}
266
267void
269{
270 NS_LOG_FUNCTION(this << socket);
271
272 CancelEvents();
273
274 if (socket->GetErrno() != Socket::ERROR_NOTERROR)
275 {
276 NS_LOG_ERROR(this << " Connection has been terminated,"
277 << " error code: " << socket->GetErrno() << ".");
278 }
279
280 m_socket->SetCloseCallbacks(MakeNullCallback<void, Ptr<Socket>>(),
282
284}
285
286void
288{
289 NS_LOG_FUNCTION(this << socket);
290
291 CancelEvents();
292 if (socket->GetErrno() != Socket::ERROR_NOTERROR)
293 {
294 NS_LOG_ERROR(this << " Connection has been terminated,"
295 << " error code: " << socket->GetErrno() << ".");
296 }
297
299}
300
301void
303{
304 NS_LOG_FUNCTION(this << socket);
305
306 Address from;
307 while (auto packet = socket->RecvFrom(from))
308 {
309 if (packet->GetSize() == 0)
310 {
311 break; // EOF
312 }
313
314#ifdef NS3_LOG_ENABLE
315 // Some log messages.
317 {
318 NS_LOG_INFO(this << " A packet of " << packet->GetSize() << " bytes"
319 << " received from " << InetSocketAddress::ConvertFrom(from).GetIpv4()
320 << " port " << InetSocketAddress::ConvertFrom(from).GetPort() << " / "
321 << InetSocketAddress::ConvertFrom(from) << ".");
322 }
324 {
325 NS_LOG_INFO(this << " A packet of " << packet->GetSize() << " bytes"
326 << " received from " << Inet6SocketAddress::ConvertFrom(from).GetIpv6()
327 << " port " << Inet6SocketAddress::ConvertFrom(from).GetPort() << " / "
328 << Inet6SocketAddress::ConvertFrom(from) << ".");
329 }
330#endif /* NS3_LOG_ENABLE */
331
332 m_rxTrace(packet, from);
333
334 switch (m_state)
335 {
337 ReceiveMainObject(packet, from);
338 break;
340 ReceiveEmbeddedObject(packet, from);
341 break;
342 default:
343 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ReceivedData().");
344 break;
345 }
346 }
347}
348
349void
351{
352 NS_LOG_FUNCTION(this);
353
356 {
357 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for OpenConnection().");
358 }
359
361
365 m_socket->SetAttribute("MaxSegLifetime", DoubleValue(0.02)); // 20 ms.
366}
367
368void
370{
371 NS_LOG_FUNCTION(this);
372
373 if (m_state != CONNECTING && m_state != READING)
374 {
375 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for RequestMainObject().");
376 }
377
378 ThreeGppHttpHeader header;
379 header.SetContentLength(0); // Request does not need any content length.
381 header.SetClientTs(Simulator::Now());
382
383 const auto requestSize = m_httpVariables->GetRequestSize();
384 auto packet = Create<Packet>(requestSize);
385 packet->AddHeader(header);
386 const auto packetSize = packet->GetSize();
388 m_txTrace(packet);
389 const auto actualBytes = m_socket->Send(packet);
390 NS_LOG_DEBUG(this << " Send() packet " << packet << " of " << packet->GetSize() << " bytes,"
391 << " return value= " << actualBytes << ".");
392 if (actualBytes != static_cast<int>(packetSize))
393 {
394 NS_LOG_ERROR(this << " Failed to send request for embedded object,"
395 << " GetErrNo= " << m_socket->GetErrno() << ","
396 << " waiting for another Tx opportunity.");
397 }
398 else
399 {
401 m_pageLoadStartTs = Simulator::Now(); // start counting page loading time
402 }
403}
404
405void
407{
408 NS_LOG_FUNCTION(this);
409
412 {
413 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for RequestEmbeddedObject().");
414 }
415
417 {
418 NS_LOG_WARN(this << " No embedded object to be requested.");
419 return;
420 }
421
422 ThreeGppHttpHeader header;
423 header.SetContentLength(0); // Request does not need any content length.
425 header.SetClientTs(Simulator::Now());
426
427 const auto requestSize = m_httpVariables->GetRequestSize();
428 auto packet = Create<Packet>(requestSize);
429 packet->AddHeader(header);
430 const auto packetSize = packet->GetSize();
432 m_txTrace(packet);
433 const auto actualBytes = m_socket->Send(packet);
434 NS_LOG_DEBUG(this << " Send() packet " << packet << " of " << packet->GetSize() << " bytes,"
435 << " return value= " << actualBytes << ".");
436
437 if (actualBytes != static_cast<int>(packetSize))
438 {
439 NS_LOG_ERROR(this << " Failed to send request for embedded object,"
440 << " GetErrNo= " << m_socket->GetErrno() << ","
441 << " waiting for another Tx opportunity.");
442 }
443 else
444 {
447 }
448}
449
450void
452{
453 NS_LOG_FUNCTION(this << packet << from);
454
456 {
457 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ReceiveMainObject().");
458 }
459
460 /*
461 * In the following call to Receive(), #m_objectBytesToBeReceived *will*
462 * be updated. #m_objectClientTs and #m_objectServerTs *may* be updated.
463 * ThreeGppHttpHeader will be removed from the packet, if it is the first
464 * packet of the object to be received; the header will be available in
465 * #m_constructedPacketHeader.
466 * #m_constructedPacket will also be updated.
467 */
468 Receive(packet);
470
472 {
473 /*
474 * There are more packets of this main object, so just stay still
475 * and wait until they arrive.
476 */
477 NS_LOG_INFO(this << " " << m_objectBytesToBeReceived << " byte(s)"
478 << " remains from this chunk of main object.");
479 return;
480 }
481
482 /*
483 * This is the last packet of this main object. Acknowledge the
484 * reception of a whole main object
485 */
486 NS_LOG_INFO(this << " Finished receiving a main object.");
488
489 if (!m_objectServerTs.IsZero())
490 {
492 m_objectServerTs = MilliSeconds(0); // Reset back to zero.
493 }
494
495 if (!m_objectClientTs.IsZero())
496 {
498 m_objectClientTs = MilliSeconds(0); // Reset back to zero.
499 }
500
502}
503
504void
506{
507 NS_LOG_FUNCTION(this << packet << from);
508
510 {
511 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ReceiveEmbeddedObject().");
512 }
513
514 /*
515 * In the following call to Receive(), #m_objectBytesToBeReceived *will*
516 * be updated. #m_objectClientTs and #m_objectServerTs *may* be updated.
517 * ThreeGppHttpHeader will be removed from the packet, if it is the first
518 * packet of the object to be received; the header will be available in
519 * #m_constructedPacket, which will also be updated.
520 */
521 Receive(packet);
523
525 {
526 /*
527 * There are more packets of this embedded object, so just stay
528 * still and wait until they arrive.
529 */
530 NS_LOG_INFO(this << " " << m_objectBytesToBeReceived << " byte(s)"
531 << " remains from this chunk of embedded object");
532 return;
533 }
534
535 /*
536 * This is the last packet of this embedded object. Acknowledge
537 * the reception of a whole embedded object
538 */
539 NS_LOG_INFO(this << " Finished receiving an embedded object.");
541
542 if (!m_objectServerTs.IsZero())
543 {
545 m_objectServerTs = MilliSeconds(0); // Reset back to zero.
546 }
547
548 if (!m_objectClientTs.IsZero())
549 {
551 m_objectClientTs = MilliSeconds(0); // Reset back to zero.
552 }
553
555 {
557 << " more embedded object(s) to be requested.");
558 // Immediately request another using the existing connection.
561 }
562 else
563 {
564 /*
565 * There is no more embedded object, the web page has been
566 * downloaded completely. Now is the time to read it.
567 */
568 NS_LOG_INFO(this << " Finished receiving a web page.");
569 FinishReceivingPage(); // trigger callback for page loading time
571 }
572}
573
574void
576{
577 NS_LOG_FUNCTION(this << packet);
578
579 /* In a "real" HTTP message the message size is coded differently. The use of a header
580 * is to avoid the burden of doing a real message parser.
581 */
582 bool firstPacket = false;
583
585 {
586 // This is the first packet of the object.
587 firstPacket = true;
588
589 // Remove the header in order to calculate remaining data to be received.
590 ThreeGppHttpHeader httpHeader;
591 packet->RemoveHeader(httpHeader);
592
594 m_objectClientTs = httpHeader.GetClientTs();
595 m_objectServerTs = httpHeader.GetServerTs();
596
597 // Take a copy for constructed packet trace. Note that header is included.
598 m_constructedPacket = packet->Copy();
599 m_constructedPacket->AddHeader(httpHeader);
600 }
601 auto contentSize = packet->GetSize();
602 m_numberBytesPage += contentSize; // increment counter of page size
603
604 /* Note that the packet does not contain header at this point.
605 * The content is purely raw data, which was the only intended data to be received.
606 */
607 if (m_objectBytesToBeReceived < contentSize)
608 {
609 NS_LOG_WARN(this << " The received packet (" << contentSize << " bytes of content)"
610 << " is larger than the content that we expected to receive ("
611 << m_objectBytesToBeReceived << " bytes).");
612 // Stop expecting any more packet of this object.
614 m_constructedPacket = nullptr;
615 }
616 else
617 {
618 m_objectBytesToBeReceived -= contentSize;
619 if (!firstPacket)
620 {
621 auto packetCopy = packet->Copy();
622 m_constructedPacket->AddAtEnd(packetCopy);
623 }
624 }
625}
626
627void
629{
630 NS_LOG_FUNCTION(this);
631
633 {
634 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for EnterParsingTime().");
635 }
636
637 const auto parsingTime = m_httpVariables->GetParsingTime();
638 NS_LOG_INFO(this << " The parsing of this main object will complete in "
639 << parsingTime.As(Time::S) << ".");
643}
644
645void
647{
648 NS_LOG_FUNCTION(this);
649
651 {
652 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for ParseMainObject().");
653 }
654
655 m_embeddedObjectsToBeRequested = m_httpVariables->GetNumOfEmbeddedObjects();
656 // saving total number of embedded objects
658 NS_LOG_INFO(this << " Parsing has determined " << m_embeddedObjectsToBeRequested
659 << " embedded object(s) in the main object.");
660
662 {
663 /*
664 * Immediately request the first embedded object using the
665 * existing connection.
666 */
669 }
670 else
671 {
672 /*
673 * There is no embedded object in the main object. So sit back and
674 * enjoy the plain web page.
675 */
676 NS_LOG_INFO(this << " Finished receiving a web page.");
677 FinishReceivingPage(); // trigger callback for page loading time
679 }
680}
681
682void
684{
685 NS_LOG_FUNCTION(this);
686
688 {
689 NS_FATAL_ERROR("Invalid state " << GetStateString() << " for EnterReadingTime().");
690 }
691
692 const auto readingTime = m_httpVariables->GetReadingTime();
693 NS_LOG_INFO(this << " Client will finish reading this web page in " << readingTime.As(Time::S)
694 << ".");
695
696 // Schedule a request of another main object once the reading time expires.
700}
701
702void
704{
705 NS_LOG_FUNCTION(this);
706
708 {
709 NS_LOG_INFO(this << " Canceling RequestMainObject() which is due in "
712 }
713
715 {
716 NS_LOG_INFO(this << " Canceling RequestEmbeddedObject() which is due in "
718 << ".");
720 }
721
723 {
724 NS_LOG_INFO(this << " Canceling ParseMainObject() which is due in "
727 }
728}
729
730void
732{
733 const auto oldState = GetStateString();
734 const auto newState = GetStateString(state);
735 NS_LOG_FUNCTION(this << oldState << newState);
736
737 if ((state == EXPECTING_MAIN_OBJECT) || (state == EXPECTING_EMBEDDED_OBJECT))
738 {
740 {
741 NS_FATAL_ERROR("Cannot start a new receiving session if the previous object ("
743 << " bytes) is not completely received yet.");
744 }
745 }
746
747 m_state = state;
748 NS_LOG_INFO(this << " HttpClient " << oldState << " --> " << newState << ".");
749 m_stateTransitionTrace(oldState, newState);
750}
751
752void
763
764} // namespace ns3
a polymophic address class
Definition address.h:111
bool IsInvalid() const
Definition address.cc:81
AttributeValue implementation for Address.
Definition address.h:357
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
static bool IsMatchingType(const Address &address)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
static bool IsMatchingType(const Address &address)
static bool IsMatchingType(const Address &address)
If the Address matches the type.
AttributeValue implementation for Pointer.
Definition pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:561
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition simulator.cc:274
static bool IsFinished()
Check if the simulation should finish.
Definition simulator.cc:160
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static bool IsExpired(const EventId &id)
Check if an event has already run or been cancelled.
Definition simulator.cc:284
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition simulator.h:595
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition simulator.cc:206
@ ERROR_NOTERROR
Definition socket.h:74
TypeId m_protocolTid
Protocol TypeId value.
SourceApplication(bool allowPacketSocket=true)
Constructor.
Ptr< Socket > m_socket
Socket.
void DoDispose() override
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
Address m_peer
Peer address.
bool CloseSocket()
Close the socket.
Model application which simulates the traffic of a web browser.
ns3::TracedCallback< const Time &, const Address & > m_rxRttTrace
The RxRtt trace source.
Time m_pageLoadStartTs
The time stamp when the page started loading.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, const Time &, uint32_t, uint32_t > m_rxPageTrace
The RxPage trace source.
void SetPort(uint16_t port)
set the remote port (temporary function until deprecated attributes are removed)
void ReceiveMainObject(Ptr< Packet > packet, const Address &from)
Receive a packet of main object from the destination web server.
void DoConnectionFailed(Ptr< Socket > socket) override
Application specific code for child subclasses upon a Connection Failed event.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionClosedTrace
The ConnectionClosed trace source.
std::optional< uint16_t > m_peerPort
The RemoteServerPort attribute.
ns3::TracedCallback< const Time &, const Address & > m_rxDelayTrace
The RxDelay trace source.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxEmbeddedObjectTrace
The TxEmbeddedObject trace source.
void DoStartApplication() override
Application specific startup code for child subclasses.
Ptr< ThreeGppHttpVariables > m_httpVariables
The Variables attribute.
uint32_t m_embeddedObjectsToBeRequested
Determined after parsing the main object.
EventId m_eventParseMainObject
An event of ParseMainObject(), scheduled to trigger after parsing time has elapsed.
void SwitchToState(State_t state)
Change the state of the client.
uint32_t m_numberEmbeddedObjectsRequested
Number of embedded objects to requested in the current page.
ThreeGppHttpClient()
Creates a new instance of HTTP client application.
ns3::TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
The Rx trace source.
void EnterParsingTime()
Becomes idle for a randomly determined amount of time, and then triggers ParseMainObject().
State_t m_state
The current state of the client application. Begins with NOT_STARTED.
void FinishReceivingPage()
Finish receiving a page.
void RequestEmbeddedObject()
Send a request object for an embedded object to the destination web server.
void CancelEvents() override
Cancel all pending events.
void ParseMainObject()
Randomly determines the number of embedded objects in the main object.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient >, Ptr< const Packet > > m_rxMainObjectTrace
The TxMainObject trace source.
State_t GetState() const
Returns the current state of the application.
void EnterReadingTime()
Becomes idle for a randomly determined amount of time, and then triggers RequestMainObject().
void DoDispose() override
Destructor implementation.
void DoConnectionSucceeded(Ptr< Socket > socket) override
Application specific code for child subclasses upon a Connection Succeed event.
Ptr< Packet > m_constructedPacket
The packet constructed of one or more parts with ThreeGppHttpHeader.
uint32_t m_objectBytesToBeReceived
According to the content length specified by the ThreeGppHttpHeader.
static TypeId GetTypeId()
Returns the object TypeId.
void ErrorCloseCallback(Ptr< Socket > socket)
Invoked when connection between m_socket and the web sever is terminated.
EventId m_eventRequestMainObject
An event of either RequestMainObject() or OpenConnection(), scheduled to trigger after a connection h...
uint32_t m_numberBytesPage
Number of bytes received for the current page.
Time m_objectClientTs
The client time stamp of the ThreeGppHttpHeader from the last received packet.
State_t
The possible states of the application.
@ CONNECTING
Sent the server a connection request and waiting for the server to be accept it.
@ NOT_STARTED
Before StartApplication() is invoked.
@ READING
User reading a web page that has just been received.
@ EXPECTING_MAIN_OBJECT
Sent the server a request for a main object and waiting to receive the packets.
@ STOPPED
After StopApplication() is invoked.
@ PARSING_MAIN_OBJECT
Parsing a main object that has just been received.
@ EXPECTING_EMBEDDED_OBJECT
Sent the server a request for an embedded object and waiting to receive the packets.
ns3::TracedCallback< Ptr< const Packet > > m_txMainObjectRequestTrace
The TxMainObjectRequest trace source.
ns3::TracedCallback< Ptr< const Packet > > m_rxMainObjectPacketTrace
The TxMainObjectPacket trace source.
void SetRemote(const Address &addr) override
set the remote address
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
void RequestMainObject()
Send a request object for a main object to the destination web server.
void DoStopApplication() override
Application specific shutdown code for child subclasses.
Time m_objectServerTs
The server time stamp of the ThreeGppHttpHeader from the last received packet.
void NormalCloseCallback(Ptr< Socket > socket)
Invoked when connection between m_socket and the web sever is terminated.
ns3::TracedCallback< Ptr< const ThreeGppHttpClient > > m_connectionEstablishedTrace
The ConnectionEstablished trace source.
ns3::TracedCallback< Ptr< const Packet > > m_txEmbeddedObjectRequestTrace
The TxEmbeddedObjectRequest trace source.
void ReceivedDataCallback(Ptr< Socket > socket)
Invoked when m_socket receives some packet data.
ns3::TracedCallback< Ptr< const Packet > > m_rxEmbeddedObjectPacketTrace
The TxEmbeddedObjectPacket trace source.
void Receive(Ptr< Packet > packet)
Simulate a consumption of the received packet by subtracting the packet size from the internal counte...
void ReceiveEmbeddedObject(Ptr< Packet > packet, const Address &from)
Receive a packet of embedded object from the destination web server.
void OpenConnection()
Initialize m_socket to connect to the destination web server at m_peer and m_peerPort and set up call...
std::string GetStateString() const
Returns the current state of the application in string format.
EventId m_eventRequestEmbeddedObject
An event of either RequestEmbeddedObject() or OpenConnection().
Header used by web browsing applications to transmit information about content type,...
void SetContentLength(uint32_t contentLength)
void SetContentType(ContentType_t contentType)
@ EMBEDDED_OBJECT
Integer equivalent = 2.
@ MAIN_OBJECT
Integer equivalent = 1.
Container of various random variables to assist in generating web browsing traffic pattern.
@ S
second
Definition nstime.h:107
a unique identifier for an interface.
Definition type-id.h:49
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition type-id.cc:872
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
Definition type-id.h:65
Hold an unsigned integer type.
Definition uinteger.h:34
uint16_t port
Definition dsdv-manet.cc:33
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeChecker > MakeAddressChecker()
Definition address.cc:193
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition address.h:357
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:249
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:270
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
Callback< R, Args... > MakeNullCallback()
Definition callback.h:727
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:439
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1381
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Address ConvertToSocketAddress(const Address &address, uint16_t port)
Convert IPv4/IPv6 address with port to a socket address.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
static const uint32_t packetSize
Packet size generated at the AP.