author | Mitch Watrous <watrous@u.washington.edu> |
Wed, 18 May 2011 17:24:04 -0700 | |
changeset 7241 | 0a7a16b599e8 |
parent 7181 | 7ff8011cf487 |
child 7243 | ea3d634af9cf |
permissions | -rw-r--r-- |
5776 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* This program is free software; you can redistribute it and/or modify |
|
4 |
* it under the terms of the GNU General Public License version 2 as |
|
5 |
* published by the Free Software Foundation; |
|
6 |
* |
|
7 |
* This program is distributed in the hope that it will be useful, |
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 |
* GNU General Public License for more details. |
|
11 |
* |
|
12 |
* You should have received a copy of the GNU General Public License |
|
13 |
* along with this program; if not, write to the Free Software |
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
* |
|
16 |
* Author: George F. Riley<riley@ece.gatech.edu> |
|
17 |
*/ |
|
18 |
||
19 |
// Interface between ns3 and the network animator |
|
20 |
||
21 |
#ifndef ANIMATION_INTERFACE__H |
|
22 |
#define ANIMATION_INTERFACE__H |
|
23 |
||
24 |
#include <string> |
|
25 |
||
26 |
#include "ns3/ptr.h" |
|
27 |
#include "ns3/net-device.h" |
|
28 |
#include "ns3/nstime.h" |
|
29 |
#include "ns3/log.h" |
|
30 |
#include "ns3/node-list.h" |
|
31 |
||
32 |
||
33 |
namespace ns3 { |
|
7241
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
34 |
|
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
35 |
/** |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
36 |
* \defgroup netanim Animation |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
37 |
* |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
38 |
*/ |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
39 |
|
5776 | 40 |
class NetModel; |
41 |
||
42 |
/** |
|
7241
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
43 |
* \ingroup netanim |
0a7a16b599e8
Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents:
7181
diff
changeset
|
44 |
* |
5776 | 45 |
* \brief Interface to network animator |
46 |
* |
|
47 |
* Provides functions that facilitate communications with an |
|
48 |
* external or internal network animator. |
|
49 |
*/ |
|
50 |
class AnimationInterface |
|
51 |
{ |
|
52 |
public: |
|
53 |
/** |
|
54 |
* @brief Construct the animator interface. No arguments needed. |
|
55 |
*/ |
|
56 |
AnimationInterface (); |
|
57 |
/** |
|
58 |
* @brief Destructor for the animator interface. |
|
59 |
*/ |
|
60 |
~AnimationInterface (); |
|
61 |
/** |
|
62 |
* @brief Specify that animation commands are to be written |
|
63 |
* to the specified output file. |
|
64 |
* |
|
65 |
* This call is used to write the animation information to a text |
|
66 |
* file that can later be used as input to the network animator tool. |
|
67 |
* |
|
68 |
* @param fn The name of the output file. |
|
69 |
* @returns true if successful open. |
|
70 |
*/ |
|
71 |
bool SetOutputFile (const std::string& fn); |
|
72 |
||
73 |
/** |
|
74 |
* @brief Specify that animation commands are to be written to |
|
75 |
* a socket. |
|
76 |
* |
|
77 |
* This call is used to set the ns3 process in server mode, waiting |
|
78 |
* for a TCP connection from the animator. This call will not |
|
79 |
* return until the animator connects in, or if the bind to the |
|
80 |
* specified port fails. |
|
81 |
* |
|
82 |
* @param port Port number to bind to. |
|
83 |
* @returns true if connection created, false if bind failed. |
|
84 |
*/ |
|
85 |
bool SetServerPort (uint16_t port); |
|
86 |
||
87 |
/** |
|
88 |
* @brief Writes the topology information and sets up the appropriate |
|
89 |
* animation packet tx callback |
|
90 |
* |
|
91 |
* Writes the topology information to the appropriate output, depending |
|
92 |
* on prior calls to SetOutputFile, SetServerPort, or SetInternalAnimation. |
|
93 |
* Then creates the callbacks needed for the animator to start processing |
|
94 |
* packets. |
|
95 |
* |
|
96 |
*/ |
|
97 |
void StartAnimation (); |
|
98 |
||
99 |
/** |
|
100 |
* @brief Closes the interface to the animator. |
|
101 |
* |
|
102 |
*/ |
|
103 |
void StopAnimation (); |
|
104 |
||
105 |
||
106 |
private: |
|
107 |
// Packet tx animation callback |
|
108 |
void DevTxTrace (std::string context, Ptr<const Packet> p, |
|
7181
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6864
diff
changeset
|
109 |
Ptr<NetDevice> tx, Ptr<NetDevice> rx, |
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6864
diff
changeset
|
110 |
Time txTime, Time rxTime); |
5776 | 111 |
// Write specified amount of data to the specified handle |
112 |
int WriteN (int, const char*, uint32_t); |
|
113 |
private: |
|
114 |
int m_fHandle; // File handle for output (-1 if none) |
|
115 |
NetModel* m_model; // If non nil, points to the internal network model |
|
116 |
// for the interlan animator |
|
117 |
}; |
|
118 |
} |
|
119 |
#endif |
|
120 |