author | Mitch Watrous |
Mon, 13 Aug 2012 16:08:13 -0700 | |
changeset 8966 | 060dba23e9bb |
parent 7385 | 10beb0e53130 |
child 10453 | ab7eaf3e1af0 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7353
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6690 | 2 |
/* |
3 |
* Copyright (c) 2010 Georgia Institute of Technology |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: George F. Riley <riley@ece.gatech.edu> |
|
19 |
*/ |
|
20 |
||
7353
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
6847
diff
changeset
|
21 |
#ifndef BULK_SEND_APPLICATION_H |
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
6847
diff
changeset
|
22 |
#define BULK_SEND_APPLICATION_H |
6690 | 23 |
|
24 |
#include "ns3/address.h" |
|
25 |
#include "ns3/application.h" |
|
26 |
#include "ns3/event-id.h" |
|
27 |
#include "ns3/ptr.h" |
|
28 |
#include "ns3/traced-callback.h" |
|
29 |
||
30 |
namespace ns3 { |
|
31 |
||
32 |
class Address; |
|
33 |
class Socket; |
|
34 |
||
35 |
/** |
|
36 |
* \ingroup applications |
|
37 |
* \defgroup bulksend BulkSendApplication |
|
38 |
* |
|
39 |
* This traffic generator simply sends data |
|
40 |
* as fast as possible up to MaxBytes or until |
|
41 |
* the appplication is stopped if MaxBytes is |
|
42 |
* zero. Once the lower layer send buffer is |
|
43 |
* filled, it waits until space is free to |
|
44 |
* send more data, essentially keeping a |
|
45 |
* constant flow of data. Only SOCK_STREAM |
|
46 |
* and SOCK_SEQPACKET sockets are supported. |
|
47 |
* For example, TCP sockets can be used, but |
|
48 |
* UDP sockets can not be used. |
|
49 |
*/ |
|
50 |
class BulkSendApplication : public Application |
|
51 |
{ |
|
52 |
public: |
|
53 |
static TypeId GetTypeId (void); |
|
54 |
||
55 |
BulkSendApplication (); |
|
56 |
||
57 |
virtual ~BulkSendApplication (); |
|
58 |
||
59 |
/** |
|
60 |
* \param maxBytes the upper bound of bytes to send |
|
61 |
* |
|
62 |
* Set the upper bound for the total number of bytes to send. Once |
|
63 |
* this bound is reached, no more application bytes are sent. If the |
|
64 |
* application is stopped during the simulation and restarted, the |
|
65 |
* total number of bytes sent is not reset; however, the maxBytes |
|
66 |
* bound is still effective and the application will continue sending |
|
67 |
* up to maxBytes. The value zero for maxBytes means that |
|
68 |
* there is no upper bound; i.e. data is sent until the application |
|
69 |
* or simulation is stopped. |
|
70 |
*/ |
|
71 |
void SetMaxBytes (uint32_t maxBytes); |
|
72 |
||
73 |
/** |
|
74 |
* \return pointer to associated socket |
|
75 |
*/ |
|
76 |
Ptr<Socket> GetSocket (void) const; |
|
77 |
||
78 |
protected: |
|
79 |
virtual void DoDispose (void); |
|
80 |
private: |
|
81 |
// inherited from Application base class. |
|
82 |
virtual void StartApplication (void); // Called at time specified by Start |
|
83 |
virtual void StopApplication (void); // Called at time specified by Stop |
|
84 |
||
85 |
void SendData (); |
|
86 |
||
87 |
Ptr<Socket> m_socket; // Associated socket |
|
88 |
Address m_peer; // Peer address |
|
89 |
bool m_connected; // True if connected |
|
90 |
uint32_t m_sendSize; // Size of data to send each time |
|
91 |
uint32_t m_maxBytes; // Limit total number of bytes sent |
|
92 |
uint32_t m_totBytes; // Total bytes sent so far |
|
93 |
TypeId m_tid; |
|
94 |
TracedCallback<Ptr<const Packet> > m_txTrace; |
|
95 |
||
96 |
private: |
|
97 |
void ConnectionSucceeded (Ptr<Socket> socket); |
|
98 |
void ConnectionFailed (Ptr<Socket> socket); |
|
99 |
void DataSend (Ptr<Socket>, uint32_t); // for socket's SetSendCallback |
|
100 |
void Ignore (Ptr<Socket> socket); |
|
101 |
}; |
|
102 |
||
103 |
} // namespace ns3 |
|
104 |
||
7353
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
6847
diff
changeset
|
105 |
#endif /* BULK_SEND_APPLICATION_H */ |