View | Details | Raw Unified | Return to bug 1172
Collapse All | Expand All

(-)8359b3ac1ab0 (+67 lines)
Added Link Here 
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: John Abraham<john.abraham@gatech.edu>
17
 */
18
19
// Animation Interface helpers
20
21
#include "ns3/animation-interface-helper.h"
22
namespace ns3 {
23
AnimPacketInfo::AnimPacketInfo()
24
  : m_nd (0), m_nRx (0), m_nDrop (0), m_nRxEnd (0), m_fbTx (0), m_lbTx (0)
25
{
26
}
27
28
AnimPacketInfo::AnimPacketInfo(Ptr<const NetDevice> nd, uint32_t nRx,
29
                               const Time& fbTx, const Time& lbTx)
30
  : m_nd (nd), m_nRx (nRx), m_nDrop (0), m_nRxEnd (0),
31
    m_fbTx (fbTx.GetSeconds ()), m_lbTx (lbTx.GetSeconds ())
32
{
33
}
34
35
void AnimPacketInfo::AddRxBegin (Ptr<const NetDevice> nd, const Time& fbRx)
36
{
37
  m_rx.push_back (AnimRxInfo (nd, fbRx));
38
}
39
40
bool AnimPacketInfo::AddRxEnd (Ptr<const NetDevice> nd, const Time& lbRx)
41
42
{
43
  // Find the RxInfo
44
  for (uint32_t i = 0; i < m_rx.size (); ++i)
45
    {
46
      if (m_rx[i].m_nd == nd)
47
        { // Found it
48
          m_rx[i].m_lbRx = lbRx.GetSeconds ();
49
          m_nRxEnd++;
50
          if ((m_nRxEnd + m_nDrop) == m_nRx) return true;  // Got them all
51
          return false; // Still more rxEnd expected
52
        }
53
    }
54
  // This should not happen, but if so we just bump the drop count
55
  m_nDrop++;
56
  if ((m_nRxEnd + m_nDrop) == m_nRx) return true;  // Got them all
57
  return false; // Still more rxEnd expected
58
59
}
60
61
void AnimPacketInfo::AddRxDrop ()
62
{
63
  m_nDrop++;
64
}
65
66
67
} // namespace ns3
(-)8359b3ac1ab0 (+64 lines)
Added Link Here 
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: John Abraham <john.abraham@gatech.edu>
17
 */
18
19
// Animation Interface helpers
20
21
#ifndef _ANIMATION_INTERFACE_HELPER_H_
22
#define _ANIMATION_INTERFACE_HELPER_H_
23
24
#include "ns3/node.h"
25
#include "ns3/mobility-model.h"
26
#include "ns3/packet.h"
27
#include "ns3/simulator.h"
28
#include <vector>
29
30
31
namespace ns3 {
32
// We use a PacketInfo structure for wireless traces to keep up
33
// when each receiver has received packets.  Also a PacketRxInfo
34
// to keep up with each receiver and the time it received the packet
35
struct AnimRxInfo
36
37
{
38
  AnimRxInfo(Ptr<const NetDevice> nd, const Time& fbRx)
39
    : m_nd (nd), m_fbRx (fbRx.GetSeconds ()), m_lbRx (0) {}
40
  Ptr<const NetDevice> m_nd; // The receiving net device
41
  double m_fbRx;             // First bit rx time
42
  double m_lbRx;             // Last bit rx time
43
};
44
45
struct AnimPacketInfo
46
47
{
48
  AnimPacketInfo ();
49
  AnimPacketInfo(Ptr<const NetDevice> nd, uint32_t nRx,
50
                 const Time& fbTx, const Time& lbTx);
51
  void AddRxBegin (Ptr<const NetDevice> nd, const Time& fbRx);
52
  bool AddRxEnd (Ptr<const NetDevice> nd, const Time& fbRx);
53
  void AddRxDrop ();
54
  Ptr<const NetDevice> m_nd;
55
  uint32_t m_nRx;       // Number of receivers expected
56
  uint32_t m_nDrop;     // Number of drops
57
  uint32_t m_nRxEnd;    // Number of rxEnd callbacks
58
  double   m_fbTx;      // Time of first bit tx
59
  double   m_lbTx;      // Time of first bit tx
60
  std::vector<AnimRxInfo> m_rx;
61
};
62
} // namespace ns3
63
64
#endif
(-)a/src/netanim/model/animation-interface.cc (-15 / +291 lines)
 Lines 20-25    Link Here 
20
20
21
#include <stdio.h>
21
#include <stdio.h>
22
#include <sstream>
22
#include <sstream>
23
#include <string>
24
#include <iomanip>
25
#include <map>
23
26
24
// Socket related includes
27
// Socket related includes
25
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H)
28
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H)
 Lines 37-42    Link Here 
37
#include "ns3/mobility-model.h"
40
#include "ns3/mobility-model.h"
38
#include "ns3/packet.h"
41
#include "ns3/packet.h"
39
#include "ns3/simulator.h"
42
#include "ns3/simulator.h"
43
#include "ns3/animation-interface-helper.h"
40
44
41
using namespace std;
45
using namespace std;
42
46
 Lines 45-56    Link Here 
45
namespace ns3 {
49
namespace ns3 {
46
50
47
AnimationInterface::AnimationInterface ()
51
AnimationInterface::AnimationInterface ()
48
  : m_fHandle (STDOUT_FILENO), m_model (0)
52
  : m_fHandle (STDOUT_FILENO), m_xml (false),m_model (0)
49
{
53
{
50
}
54
}
51
55
52
AnimationInterface::~AnimationInterface ()
56
AnimationInterface::~AnimationInterface ()
53
{
57
{
58
  StopAnimation ();
59
}
60
61
void AnimationInterface::SetXMLOutput ()
62
{
63
  m_xml = true;
54
}
64
}
55
65
56
bool AnimationInterface::SetOutputFile (const std::string& fn)
66
bool AnimationInterface::SetOutputFile (const std::string& fn)
 Lines 93-112    Link Here 
93
103
94
void AnimationInterface::StartAnimation ()
104
void AnimationInterface::StartAnimation ()
95
{
105
{
106
  // Find the min/max x/y for the xml topology element
107
  double minX = 0;
108
  double minY = 0;
109
  double maxX = 0;
110
  double maxY = 0;
111
  bool   first = true;
112
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
113
    {
114
      Ptr<Node> n = *i;
115
      Ptr<MobilityModel> loc = n->GetObject<MobilityModel> ();
116
      Vector v;
117
      if (!loc) continue;
118
      if (loc)
119
        {
120
          v = loc->GetPosition ();
121
        }
122
      if (first)
123
        {
124
          minX = v.x;
125
          minY = v.y;
126
          maxX = v.x;
127
          maxY = v.y;
128
          first = false;
129
        }
130
      else
131
        {
132
          minX = min (minX, v.x);
133
          minY = min (minY, v.y);
134
          maxX = max (maxX, v.x);
135
          maxY = max (maxY, v.y);
136
        }
137
    }
138
139
  if (m_xml)
140
    { // output the xml headers
141
      // Compute width/height, and add a small margin
142
      double w = maxX - minX;
143
      double h = maxY - minY;
144
      minX -= w * 0.05;
145
      minY -= h * 0.05;
146
      maxX = minX + w * 1.10;
147
      maxY = minY + h * 1.10;
148
      ostringstream oss;
149
      oss << GetXMLOpen_anim (0);
150
      oss << GetXMLOpen_topology (minX,minY,maxX,maxY);
151
      WriteN (m_fHandle, oss.str ());
152
    }
96
  // Dump the topology
153
  // Dump the topology
97
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
154
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
98
    {
155
    {
99
      Ptr<Node> n = *i;
156
      Ptr<Node> n = *i;
100
      Ptr<MobilityModel> loc = n->GetObject<MobilityModel> ();
157
      Ptr<MobilityModel> loc = n->GetObject<MobilityModel> ();
101
      if (loc)
158
      if (!loc) continue;  // Can't find a position
159
      ostringstream oss;
160
      if (m_xml)
161
        {
162
          Vector v = loc->GetPosition ();
163
          oss << GetXMLOpenClose_node (0,n->GetId (),v.x,v.y);
164
        }
165
      else
102
        {
166
        {
103
          // Location exists, dump it
167
          // Location exists, dump it
104
          Vector v = loc->GetPosition ();
168
          Vector v = loc->GetPosition ();
105
          ostringstream oss;
106
          oss << "0.0 N " << n->GetId () 
169
          oss << "0.0 N " << n->GetId () 
107
              << " " << v.x << " " << v.y << endl;
170
              << " " << v.x << " " << v.y << endl;
108
          WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ());
109
        }
171
        }
172
173
      WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ());
110
    }
174
    }
111
  // Now dump the p2p links
175
  // Now dump the p2p links
112
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
176
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
 Lines 134-142    Link Here 
134
                  if (n1Id < n2Id)
198
                  if (n1Id < n2Id)
135
                    { // ouptut the p2p link
199
                    { // ouptut the p2p link
136
                      ostringstream oss;
200
                      ostringstream oss;
137
                      oss << "0.0 L "  << n1Id << " " << n2Id << endl;
201
                      if (m_xml)
138
                      WriteN (m_fHandle, oss.str ().c_str (),
202
                        {
139
                              oss.str ().length ());
203
                          oss << GetXMLOpenClose_link (0,n1Id,0,n2Id);
204
                        }
205
                      else
206
                        {
207
                          oss << "0.0 L "  << n1Id << " " << n2Id << endl;
208
                        }
209
                      WriteN (m_fHandle, oss.str ());
210
140
                    }
211
                    }
141
                }
212
                }
142
            }
213
            }
 Lines 146-165    Link Here 
146
            }
217
            }
147
        }
218
        }
148
    }
219
    }
220
  if (m_xml)
221
    {
222
      WriteN (m_fHandle, GetXMLClose ("topology"));
223
    }
149
224
150
  // Connect the callback for packet tx events
225
  // Connect the callback for packet tx events
151
  Config::Connect ("/ChannelList/*/TxRxPointToPoint",
226
  Config::Connect ("/ChannelList/*/TxRxPointToPoint",
152
                   MakeCallback (&AnimationInterface::DevTxTrace, this));
227
                   MakeCallback (&AnimationInterface::DevTxTrace, this));
228
#if 0 // To be implemented after trace sources are installed
229
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
230
                   MakeCallback (&AnimationInterface::PhyTxBeginTrace, this));
231
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxEnd",
232
                   MakeCallback (&AnimationInterface::PhyTxEndTrace, this));
233
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
234
                   MakeCallback (&AnimationInterface::PhyRxBeginTrace, this));
235
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
236
                   MakeCallback (&AnimationInterface::PhyRxEndTrace, this));
237
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
238
                   MakeCallback (&AnimationInterface::PhyRxDropTrace, this));
239
#endif
240
153
}
241
}
154
242
155
void AnimationInterface::StopAnimation ()
243
void AnimationInterface::StopAnimation ()
156
{
244
{
157
  if (m_fHandle > 0) 
245
  if (m_fHandle > 0) 
158
    {
246
    {
247
      if (m_xml)
248
        { // Terminate the anim element
249
          WriteN (m_fHandle, GetXMLClose ("anim"));
250
        }
159
      close (m_fHandle);
251
      close (m_fHandle);
252
      m_fHandle = 0;
160
    }
253
    }
161
}
254
}
162
255
256
int AnimationInterface::WriteN (int h, const string& st)
257
{
258
  return WriteN (h, st.c_str (), st.length ());
259
}
260
163
261
164
// Private methods
262
// Private methods
165
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
263
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
 Lines 167-173    Link Here 
167
  uint32_t    nLeft   = count;
265
  uint32_t    nLeft   = count;
168
  const char* p       = data;
266
  const char* p       = data;
169
  uint32_t    written = 0;
267
  uint32_t    written = 0;
170
171
  while (nLeft)
268
  while (nLeft)
172
    {
269
    {
173
      int n = write (h, p, nLeft);
270
      int n = write (h, p, nLeft);
 Lines 188-200    Link Here 
188
{
285
{
189
  Time now = Simulator::Now ();
286
  Time now = Simulator::Now ();
190
  ostringstream oss;
287
  ostringstream oss;
191
  oss << now.GetSeconds () << " P "
288
  double fbTx = now.GetSeconds ();
192
      << tx->GetNode ()->GetId () << " "
289
  double lbTx = (now + txTime).GetSeconds ();
193
      << rx->GetNode ()->GetId () << " "
290
  double fbRx = (now + rxTime - txTime).GetSeconds ();
194
      << (now + txTime).GetSeconds () << " " // last bit tx time
291
  double lbRx = (now + rxTime).GetSeconds ();
195
      << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time
292
  if (m_xml)
196
      << (now + rxTime).GetSeconds () << endl;         // last bit rx time
293
    {
197
  WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ());
294
      oss << GetXMLOpen_packet (0,tx->GetNode ()->GetId (),fbTx,lbTx);
295
      oss << GetXMLOpenClose_rx (0,rx->GetNode ()->GetId (),fbRx,lbRx); 
296
      oss << GetXMLClose ("packet");
297
    }
298
  else
299
    {
300
      oss << setprecision (10);
301
      oss << now.GetSeconds () << " P "
302
          << tx->GetNode ()->GetId () << " "
303
          << rx->GetNode ()->GetId () << " "
304
          << (now + txTime).GetSeconds () << " " // last bit tx time
305
          << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time
306
          << (now + rxTime).GetSeconds () << endl;         // last bit rx time
307
    }
308
  WriteN (m_fHandle, oss.str ());
198
}
309
}
199
310
311
312
void AnimationInterface::PhyTxBeginTrace (std::string context,
313
                                          Ptr<const Packet> p,
314
                                          Ptr<const NetDevice> nd, 
315
                                          const Time& txTime, 
316
                                          uint32_t nReceivers)
317
{
318
  // Add a new pending wireless
319
  pendingWirelessPackets[p->GetUid ()] =
320
    AnimPacketInfo (nd, nReceivers, Simulator::Now (), Simulator::Now () + txTime);
321
}
322
323
324
void AnimationInterface::PhyTxEndTrace (std::string context,
325
                                        Ptr<const Packet> p,
326
                                        Ptr<const NetDevice> nd)
327
{
328
}
329
330
331
void AnimationInterface::PhyRxBeginTrace (std::string context,
332
                                          Ptr<const Packet> p,
333
                                          Ptr<const NetDevice> nd)
334
{
335
  pendingWirelessPackets[p->GetUid ()].AddRxBegin (nd, Simulator::Now ());
336
}
337
338
339
void AnimationInterface::PhyRxEndTrace (std::string context,
340
                                        Ptr<const Packet> p,
341
                                        Ptr<const NetDevice> nd)
342
{
343
344
  uint32_t uid = p->GetUid ();
345
  AnimPacketInfo& pkt = pendingWirelessPackets[uid];
346
  if (pkt.AddRxEnd (nd, Simulator::Now ()))
347
    {
348
      //cout << "Packet " << uid << " complete" << endl;
349
      OutputWirelessPacket (uid, pkt);
350
      pendingWirelessPackets.erase (pendingWirelessPackets.find (uid));;
351
    }
352
}
353
354
355
void AnimationInterface::PhyRxDropTrace (std::string context,
356
                                         Ptr<const Packet> p,
357
                                         Ptr<const NetDevice> nd)
358
{
359
  pendingWirelessPackets[p->GetUid ()].AddRxDrop ();
360
361
}
362
363
// Helper to output a wireless packet.
364
// For now, only the XML interface is supported
365
366
void AnimationInterface::OutputWirelessPacket (uint32_t uid, AnimPacketInfo& pktInfo)
367
368
{
369
  if (!m_xml) return;
370
  ostringstream oss;
371
  uint32_t nodeId = pktInfo.m_nd->GetNode ()->GetId ();
372
  double lbTx = pktInfo.m_lbTx;
373
374
#if 0 // To be tested
375
376
  // This is a hack until the notify tx end is working
377
  if (lbTx == 0)
378
    {
379
      if (pktInfo.m_rx.empty ())
380
        {
381
          lbTx = pktInfo.m_fbTx + 100E-6; // 100 microsec
382
        }
383
      else
384
        {
385
          lbTx = pktInfo.m_fbTx +
386
            pktInfo.m_rx[0].m_lbRx - pktInfo.m_rx[0].m_fbRx;
387
        }
388
    }
389
390
#endif
391
392
  // Oops, need to figure out about range
393
  oss << GetXMLOpen_wpacket (0,nodeId,pktInfo.m_fbTx,lbTx,500);
394
  // Now add each rx
395
  for (uint32_t i = 0; i < pktInfo.m_rx.size (); ++i)
396
    {
397
      AnimRxInfo& rx = pktInfo.m_rx[i];
398
      uint32_t rxId = rx.m_nd->GetNode ()->GetId ();
399
      oss << GetXMLOpenClose_rx (0,rxId,rx.m_fbRx,rx.m_lbRx);
400
    }
401
  oss << GetXMLClose ("wpacket");
402
  WriteN (m_fHandle, oss.str ());
403
}
404
405
406
// XML Private Helpers
407
408
std::string AnimationInterface::GetXMLOpen_anim (uint32_t lp)
409
{
410
  ostringstream oss;
411
  oss <<"<anim lp = \"" << lp << "\" >\n";
412
  return oss.str ();
413
}
414
std::string AnimationInterface::GetXMLOpen_topology (double minX,double minY,double maxX,double maxY)
415
{
416
  ostringstream oss;
417
  oss <<"<topology minX = \"" << minX << "\" minY = \"" << minY
418
      << "\" maxX = \"" << maxX << "\" maxY = \"" << maxY
419
      << "\">" << endl;
420
  return oss.str ();
421
422
}
423
424
std::string AnimationInterface::GetXMLOpenClose_node (uint32_t lp,uint32_t id,double locX,double locY)
425
{
426
  ostringstream oss;
427
  oss <<"<node lp = \"" << lp << "\" id = \"" << id << "\"" << " locX = \"" 
428
      << locX << "\" " << "locY = \"" << locY << "\" \n />";
429
  return oss.str ();
430
}
431
std::string AnimationInterface::GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId)
432
{
433
  ostringstream oss;
434
  oss << "<link fromLP = \"0\" fromId = \"" << fromId
435
      << "\" toLp = \"0\" toId = \"" << toId
436
      << "\"/>" << endl;
437
  return oss.str ();
438
}
439
440
441
std::string AnimationInterface::GetXMLOpen_packet (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx)
442
{
443
  ostringstream oss;
444
  oss << setprecision (10);
445
  oss << "<packet fromLp = \"" << fromLp << "\" fromId = \"" << fromId
446
      << "\" fbTx = \"" << fbTx
447
      << "\" lbTx = \"" << lbTx
448
      << "\">" << endl;
449
  return oss.str ();
450
}
451
452
std::string AnimationInterface::GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx, double range)
453
{
454
  ostringstream oss;
455
  oss << setprecision (10);
456
  oss << "<wpacket fromLp = \"" << fromLp << "\" fromId = \"" << fromId
457
      << "\" fbTx = \"" << fbTx
458
      << "\" lbTx = \"" << lbTx
459
      << "\" range = \"" << range << "\">" << endl;
460
  return oss.str ();
461
462
}
463
464
std::string AnimationInterface::GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx)
465
{
466
  ostringstream oss;
467
  oss << setprecision (10);
468
  oss << "<rx toLp = \"" << toLp <<"\" toId = \"" << toId
469
      << "\" fbRx = \"" << fbRx
470
      << "\" lbRx = \"" << lbRx
471
      << "\"/>" << endl;
472
  return oss.str ();
473
}
474
475
200
} // namespace ns3
476
} // namespace ns3
(-)a/src/netanim/model/animation-interface.h (-7 / +56 lines)
 Lines 22-39    Link Here 
22
#define ANIMATION_INTERFACE__H
22
#define ANIMATION_INTERFACE__H
23
23
24
#include <string>
24
#include <string>
25
25
#include <stdio.h>
26
#include <map>
26
#include "ns3/ptr.h"
27
#include "ns3/ptr.h"
27
#include "ns3/net-device.h"
28
#include "ns3/net-device.h"
28
#include "ns3/nstime.h"
29
#include "ns3/nstime.h"
29
#include "ns3/log.h"
30
#include "ns3/log.h"
30
#include "ns3/node-list.h"
31
#include "ns3/node-list.h"
31
32
#include "ns3/simulator.h"
33
#include "ns3/config.h"
34
#include "ns3/animation-interface-helper.h"
32
35
33
namespace ns3 {
36
namespace ns3 {
34
37
35
class NetModel;
38
class NetModel;
36
39
//class AnimPacketInfo;
37
/**
40
/**
38
 * \defgroup netanim Netanim
41
 * \defgroup netanim Netanim
39
 *
42
 *
 Lines 72-77    Link Here 
72
  bool SetOutputFile (const std::string& fn);
75
  bool SetOutputFile (const std::string& fn);
73
76
74
/**
77
/**
78
 * @brief Specify that animation commands are to be written
79
 * in XML format.
80
 *
81
 * @returns none
82
 */
83
84
  void SetXMLOutput ();
85
86
/**
75
 * @brief Specify that animation commands are to be written to
87
 * @brief Specify that animation commands are to be written to
76
 * a socket.
88
 * a socket.
77
 *
89
 *
 Lines 103-120    Link Here 
103
 */
115
 */
104
  void StopAnimation ();
116
  void StopAnimation ();
105
117
106
107
private:
118
private:
108
  // Packet tx animation callback
119
  // Packet tx animation callback
109
  void DevTxTrace (std::string context, Ptr<const Packet> p,
120
  void DevTxTrace (std::string context,
110
                   Ptr<NetDevice> tx, Ptr<NetDevice> rx,
121
                   Ptr<const Packet> p,
111
                   Time txTime, Time rxTime);
122
                   Ptr<NetDevice> tx,
123
                   Ptr<NetDevice> rx,
124
                   Time txTime,
125
                   Time rxTime);
126
  void PhyTxBeginTrace (std::string context,
127
                        Ptr<const Packet> p,
128
                        Ptr<const NetDevice> nd,
129
                        const Time& txTime, 
130
                        uint32_t nReceivers);
131
  void PhyTxEndTrace (std::string context,
132
                      Ptr<const Packet> p,
133
                      Ptr<const NetDevice> nd);
134
  void PhyRxBeginTrace (std::string context,
135
                        Ptr<const Packet> p,
136
                        Ptr<const NetDevice> nd);
137
  void PhyRxEndTrace (std::string context,
138
                      Ptr<const Packet> p,
139
                      Ptr<const NetDevice> nd);
140
  void PhyRxDropTrace (std::string context,
141
                       Ptr<const Packet> p,
142
                       Ptr<const NetDevice> nd);
112
  // Write specified amount of data to the specified handle
143
  // Write specified amount of data to the specified handle
113
  int  WriteN (int, const char*, uint32_t);
144
  int  WriteN (int, const char*, uint32_t);
145
  // Write a string to the specified handle;
146
  int  WriteN (int, const std::string&);
147
  //Helper to output xml wireless packet
148
  void OutputWirelessPacket (uint32_t, AnimPacketInfo&);
114
private:
149
private:
115
  int       m_fHandle;  // File handle for output (-1 if none)
150
  int       m_fHandle;  // File handle for output (-1 if none)
151
  bool      m_xml;      // True if xml format desired
116
  NetModel* m_model;    // If non nil, points to the internal network model
152
  NetModel* m_model;    // If non nil, points to the internal network model
117
                        // for the interlan animator
153
                        // for the interlan animator
154
  std::map<uint32_t, AnimPacketInfo> pendingWirelessPackets;
155
156
// XML helpers
157
158
  std::string GetXMLOpen_anim (uint32_t lp);
159
  std::string GetXMLOpen_topology (double minX,double minY,double maxX,double maxY);
160
  std::string GetXMLOpenClose_node (uint32_t lp,uint32_t id,double locX,double locY);
161
  std::string GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId);
162
  std::string GetXMLOpen_packet (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx);
163
  std::string GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx);
164
  std::string GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx, double range);
165
  std::string GetXMLClose (std::string name) {return "</" + name + ">\n"; }
166
118
};
167
};
119
}
168
}
120
#endif
169
#endif
(-)a/src/netanim/wscript (-16 / +18 lines)
 Lines 1-25    Link Here 
1
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
1
## -*-Mode : python; py-indent-offset : 4; indent-tabs-mode : nil; coding : utf-8; -*-
2
2
3
def build(bld):
3
def build (bld) :
4
    module = bld.create_ns3_module('netanim', ['internet', 'mobility'])
4
  module = bld.create_ns3_module ('netanim', ['internet', 'mobility'])
5
    module.includes = '.'
5
    module.includes = '.'
6
    module.source = [
6
      module.source = [
7
        'model/animation-interface.cc',
7
    'model/animation-interface.cc',
8
        ]
8
    'helper/animation-interface-helper.cc',
9
  ]
9
10
10
    headers = bld.new_task_gen('ns3header')
11
  headers = bld.new_task_gen ('ns3header')
11
    headers.module = 'netanim'
12
    headers.module = 'netanim'
12
    headers.source = [
13
      headers.source = [
13
        'model/animation-interface.h',
14
    'model/animation-interface.h',
14
        ]
15
    'helper/animation-interface-helper.h',
16
  ]
15
17
16
    if (bld.env['ENABLE_EXAMPLES']):
18
  if (bld.env['ENABLE_EXAMPLES']) :
17
        bld.add_subdirs('examples')
19
    bld.add_subdirs ('examples')
18
20
19
    bld.ns3_python_bindings()
21
    bld.ns3_python_bindings ()
20
22
21
23
22
def configure(conf):
24
    def configure (conf) :
23
    conf.check(header_name='sys/socket.h', define_name='HAVE_SYS_SOCKET_H')
25
      conf.check (header_name='sys/socket.h', define_name='HAVE_SYS_SOCKET_H')
24
    conf.check(header_name='netinet/in.h', define_name='HAVE_NETINET_IN_H')
26
      conf.check (header_name='netinet/in.h', define_name='HAVE_NETINET_IN_H')
25
27

Return to bug 1172