Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Georgia Institute of Technology | 3 * Copyright (c) 2010 Georgia Institute of Technology |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 16 matching lines...) Expand all Loading... | |
27 #include "ns3/ptr.h" | 27 #include "ns3/ptr.h" |
28 #include "ns3/traced-callback.h" | 28 #include "ns3/traced-callback.h" |
29 | 29 |
30 namespace ns3 { | 30 namespace ns3 { |
31 | 31 |
32 class Address; | 32 class Address; |
33 class RandomVariable; | 33 class RandomVariable; |
34 class Socket; | 34 class Socket; |
35 | 35 |
36 /** | 36 /** |
37 * \ingroup applications | 37 * \ingroup applications |
38 * \defgroup bulksend BulkSendApplication | 38 * \defgroup bulksend BulkSendApplication |
39 * | 39 * |
40 * This traffic generator simply sends data | 40 * This traffic generator simply sends data |
41 * as fast as possible up to MaxBytes or until | 41 * as fast as possible up to MaxBytes or until |
42 * the appplication is stopped if MaxBytes is | 42 * the appplication is stopped if MaxBytes is |
43 * zero. Once the lower layer send buffer is | 43 * zero. Once the lower layer send buffer is |
44 * filled, it waits until space is free to | 44 * filled, it waits until space is free to |
45 * send more data, essentially keeping a | 45 * send more data, essentially keeping a |
46 * constant flow of data. | 46 * constant flow of data. Only SOCK_STREAM |
47 * and SOCK_SEQPACKET sockets are supported.· | |
48 * For example, TCP sockets can be used, but· | |
49 * UDP sockets can not be used. | |
47 */ | 50 */ |
48 class BulkSendApplication : public Application | 51 class BulkSendApplication : public Application |
49 { | 52 { |
50 public: | 53 public: |
51 static TypeId GetTypeId (void); | 54 static TypeId GetTypeId (void); |
52 | 55 |
53 BulkSendApplication (); | 56 BulkSendApplication (); |
54 | 57 |
55 virtual ~BulkSendApplication(); | 58 virtual ~BulkSendApplication (); |
56 | 59 |
57 /** | 60 /** |
58 * \param maxBytes the total number of bytes to send | 61 * \param maxBytes the upper bound of bytes to send |
59 * | 62 * |
60 * Set the total number of bytes to send. Once these bytes are sent, no packet · | 63 * Set the upper bound for the total number of bytes to send. Once· |
61 * is sent again, even in on state. The value zero means that there is no· | 64 * this bound is reached, no more application bytes are sent. If the· |
62 * limit. | 65 * application is stopped during the simulation and restarted, the· |
Tom Henderson
2010/10/13 04:47:48
Clarify the interaction with StopApplication(). If
Josh Pelkey
2010/10/13 17:10:41
Done.
| |
66 * total number of bytes sent is not reset; however, the maxBytes· | |
67 * bound is still effective and the application will continue sending· | |
68 * up to maxBytes. The value zero for maxBytes means that· | |
69 * there is no upper bound; i.e. data is sent until the application· | |
70 * or simulation is stopped. | |
63 */ | 71 */ |
64 void SetMaxBytes (uint32_t maxBytes); | 72 void SetMaxBytes (uint32_t maxBytes); |
73 | |
74 /** | |
75 * \return pointer to associated socket | |
76 */ | |
77 Ptr<Socket> GetSocket (void) const; | |
65 | 78 |
Tom Henderson
2010/10/13 04:47:48
It would be very helpful to provide a public: Ptr<
Josh Pelkey
2010/10/13 17:10:41
Done.
| |
66 protected: | 79 protected: |
67 virtual void DoDispose (void); | 80 virtual void DoDispose (void); |
68 private: | 81 private: |
69 // inherited from Application base class. | 82 // inherited from Application base class. |
70 virtual void StartApplication (void); // Called at time specified by Start | 83 virtual void StartApplication (void); // Called at time specified by Start |
71 virtual void StopApplication (void); // Called at time specified by Stop | 84 virtual void StopApplication (void); // Called at time specified by Stop |
72 | 85 |
73 //helpers | |
74 void CancelEvents (); | |
75 | |
76 void Construct (Ptr<Node> n, | |
77 const Address &remote, | |
78 std::string tid, | |
79 uint32_t size); | |
80 void SendData (); | 86 void SendData (); |
81 | 87 |
82 Ptr<Socket> m_socket; // Associated socket | 88 Ptr<Socket> m_socket; // Associated socket |
83 Address m_peer; // Peer address | 89 Address m_peer; // Peer address |
84 bool m_connected; // True if connected | 90 bool m_connected; // True if connected |
85 uint32_t m_sendSize; // Size of data to send each time | 91 uint32_t m_sendSize; // Size of data to send each time |
86 uint32_t m_maxBytes; // Limit total number of bytes sent | 92 uint32_t m_maxBytes; // Limit total number of bytes sent |
87 uint32_t m_totBytes; // Total bytes sent so far | 93 uint32_t m_totBytes; // Total bytes sent so far |
88 TypeId m_tid; | 94 TypeId m_tid; |
89 TracedCallback<Ptr<const Packet> > m_txTrace; | 95 TracedCallback<Ptr<const Packet> > m_txTrace; |
90 | 96 |
91 private: | 97 private: |
92 void ConnectionSucceeded(Ptr<Socket>); | 98 void ConnectionSucceeded (Ptr<Socket> socket); |
93 void ConnectionFailed(Ptr<Socket>); | 99 void ConnectionFailed (Ptr<Socket> socket); |
94 void DataSend(Ptr<Socket>, uint32_t); | 100 void DataSend (Ptr<Socket>, uint32_t); // for socket's SetSendCallback |
95 void Ignore(Ptr<Socket>); | 101 void Ignore (Ptr<Socket> socket); |
96 }; | 102 }; |
97 | 103 |
98 } // namespace ns3 | 104 } // namespace ns3 |
99 | 105 |
100 #endif | 106 #endif |
101 | 107 |
LEFT | RIGHT |