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 last bit tx
60
  std::vector<AnimRxInfo> m_rx;
61
};
62
} // namespace ns3
63
64
#endif
(-)a/src/netanim/model/animation-interface.cc (-16 / +336 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), mobilitypollinterval (Seconds(0.25))
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
  topo_minX = 0;
108
  topo_minY = 0;
109
  topo_maxX = 0;
110
  topo_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
          topo_minX = v.x;
125
          topo_minY = v.y;
126
          topo_maxX = v.x;
127
          topo_maxY = v.y;
128
          first = false;
129
        }
130
      else
131
        {
132
          topo_minX = min (topo_minX, v.x);
133
          topo_minY = min (topo_minY, v.y);
134
          topo_maxX = max (topo_maxX, v.x);
135
          topo_maxY = max (topo_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 = topo_maxX - topo_minX;
143
      double h = topo_maxY - topo_minY;
144
      topo_minX -= w * 0.05;
145
      topo_minY -= h * 0.05;
146
      topo_maxX = topo_minX + w * 1.10;
147
      topo_maxY = topo_minY + h * 1.10;
148
      ostringstream oss;
149
      oss << GetXMLOpen_anim (0);
150
      oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_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-165    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
            }
143
          else
214
          else
144
            {
215
            {
145
              NS_FATAL_ERROR ("Net animation currently only supports point-to-point links.");
216
              //NS_FATAL_ERROR ("Net animation currently only supports point-to-point links.");
146
            }
217
            }
147
        }
218
        }
148
    }
219
    }
220
  if (m_xml)
221
    {
222
      WriteN (m_fHandle, GetXMLClose ("topology"));
223
      Simulator::Schedule (mobilitypollinterval, &AnimationInterface::MobilityAutoCheck, this);
224
    }
149
225
150
  // Connect the callback for packet tx events
226
  // Connect the callback for packet tx events
151
  Config::Connect ("/ChannelList/*/TxRxPointToPoint",
227
  Config::Connect ("/ChannelList/*/TxRxPointToPoint",
152
                   MakeCallback (&AnimationInterface::DevTxTrace, this));
228
                   MakeCallback (&AnimationInterface::DevTxTrace, this));
229
//#if 0 // To be implemented after trace sources are installed
230
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
231
                   MakeCallback (&AnimationInterface::PhyTxBeginTrace, this));
232
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxEnd",
233
                   MakeCallback (&AnimationInterface::PhyTxEndTrace, this));
234
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
235
                   MakeCallback (&AnimationInterface::PhyRxBeginTrace, this));
236
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
237
                   MakeCallback (&AnimationInterface::PhyRxEndTrace, this));
238
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
239
                   MakeCallback (&AnimationInterface::PhyRxDropTrace, this));
240
  Config::ConnectWithoutContext ("/NodeList/1/$ns3::MobilityModel/CourseChange",
241
                   MakeCallback (&AnimationInterface::MobilityCourseChangeTrace, this));
242
243
//#endif
244
153
}
245
}
154
246
155
void AnimationInterface::StopAnimation ()
247
void AnimationInterface::StopAnimation ()
156
{
248
{
157
  if (m_fHandle > 0) 
249
  if (m_fHandle > 0) 
158
    {
250
    {
251
      if (m_xml)
252
        { // Terminate the anim element
253
          WriteN (m_fHandle, GetXMLClose ("anim"));
254
        }
159
      close (m_fHandle);
255
      close (m_fHandle);
256
      m_fHandle = 0;
160
    }
257
    }
161
}
258
}
162
259
260
int AnimationInterface::WriteN (int h, const string& st)
261
{
262
  return WriteN (h, st.c_str (), st.length ());
263
}
264
163
265
164
// Private methods
266
// Private methods
165
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
267
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
 Lines 167-173    Link Here 
167
  uint32_t    nLeft   = count;
269
  uint32_t    nLeft   = count;
168
  const char* p       = data;
270
  const char* p       = data;
169
  uint32_t    written = 0;
271
  uint32_t    written = 0;
170
171
  while (nLeft)
272
  while (nLeft)
172
    {
273
    {
173
      int n = write (h, p, nLeft);
274
      int n = write (h, p, nLeft);
 Lines 188-200    Link Here 
188
{
289
{
189
  Time now = Simulator::Now ();
290
  Time now = Simulator::Now ();
190
  ostringstream oss;
291
  ostringstream oss;
191
  oss << now.GetSeconds () << " P "
292
  double fbTx = now.GetSeconds ();
192
      << tx->GetNode ()->GetId () << " "
293
  double lbTx = (now + txTime).GetSeconds ();
193
      << rx->GetNode ()->GetId () << " "
294
  double fbRx = (now + rxTime - txTime).GetSeconds ();
194
      << (now + txTime).GetSeconds () << " " // last bit tx time
295
  double lbRx = (now + rxTime).GetSeconds ();
195
      << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time
296
  if (m_xml)
196
      << (now + rxTime).GetSeconds () << endl;         // last bit rx time
297
    {
197
  WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ());
298
      oss << GetXMLOpen_packet (0,tx->GetNode ()->GetId (),fbTx,lbTx);
299
      oss << GetXMLOpenClose_rx (0,rx->GetNode ()->GetId (),fbRx,lbRx); 
300
      oss << GetXMLClose ("packet");
301
    }
302
  else
303
    {
304
      oss << setprecision (10);
305
      oss << now.GetSeconds () << " P "
306
          << tx->GetNode ()->GetId () << " "
307
          << rx->GetNode ()->GetId () << " "
308
          << (now + txTime).GetSeconds () << " " // last bit tx time
309
          << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time
310
          << (now + rxTime).GetSeconds () << endl;         // last bit rx time
311
    }
312
  WriteN (m_fHandle, oss.str ());
198
}
313
}
199
314
315
316
void AnimationInterface::PhyTxBeginTrace (std::string context,
317
                                          Ptr<const Packet> p,
318
                                          Ptr<const Object> nd, 
319
                                          const Time& txTime, 
320
                                          uint32_t nReceivers)
321
{
322
  // Add a new pending wireless
323
  Ptr<const NetDevice> ndev =  DynamicCast<const NetDevice>(nd);
324
  NS_ASSERT (ndev);
325
  pendingWirelessPackets[p->GetUid ()] =
326
  AnimPacketInfo (ndev, nReceivers, Simulator::Now (), Simulator::Now () + txTime);
327
}
328
329
330
void AnimationInterface::PhyTxEndTrace (std::string context,
331
                                        Ptr<const Packet> p,
332
                                        Ptr<const Object> nd)
333
{
334
}
335
336
337
void AnimationInterface::PhyRxBeginTrace (std::string context,
338
                                          Ptr<const Packet> p,
339
                                          Ptr<const Object> nd)
340
{
341
  Ptr<const NetDevice> ndev =  DynamicCast<const NetDevice>(nd);
342
  NS_ASSERT (ndev);
343
  pendingWirelessPackets[p->GetUid ()].AddRxBegin (ndev, Simulator::Now ());
344
}
345
346
347
void AnimationInterface::PhyRxEndTrace (std::string context,
348
                                        Ptr<const Packet> p,
349
                                        Ptr<const Object> nd)
350
{
351
  Ptr<const NetDevice> ndev =  DynamicCast<const NetDevice>(nd);
352
  NS_ASSERT (ndev);
353
  uint32_t uid = p->GetUid ();
354
  AnimPacketInfo& pkt = pendingWirelessPackets[uid];
355
  if (pkt.AddRxEnd (ndev, Simulator::Now ()))
356
    {
357
      //cout << "Packet " << uid << " complete" << endl;
358
      OutputWirelessPacket (uid, pkt);
359
      pendingWirelessPackets.erase (pendingWirelessPackets.find (uid));;
360
    }
361
}
362
363
364
void AnimationInterface::PhyRxDropTrace (std::string context,
365
                                         Ptr<const Packet> p,
366
                                         Ptr<const Object> nd)
367
{
368
  pendingWirelessPackets[p->GetUid ()].AddRxDrop ();
369
}
370
371
372
void AnimationInterface::MobilityCourseChangeTrace (Ptr <const MobilityModel> mobility)
373
374
{
375
  Ptr <Node> n = mobility->GetObject <Node> ();
376
  if (!n) return;
377
  if (!mobility) return; 
378
  Vector v ;
379
  v = mobility->GetPosition ();
380
  ostringstream oss; 
381
  oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_maxY);
382
  oss << GetXMLOpenClose_node (0,n->GetId (),v.x,v.y);
383
  oss << GetXMLClose ("topology");
384
  WriteN (m_fHandle, oss.str ());
385
}
386
387
void AnimationInterface::MobilityAutoCheck ()
388
{
389
  Simulator::Schedule (mobilitypollinterval, &AnimationInterface::MobilityAutoCheck, this);
390
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
391
    {
392
      Ptr <Node> n = *i;
393
      if (!n) continue;
394
      Ptr <MobilityModel> mobility = n->GetObject <MobilityModel> ();
395
      if (!mobility) continue;
396
      Vector v ;
397
      v = mobility->GetPosition ();
398
      ostringstream oss;
399
      oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_maxY);
400
      oss << GetXMLOpenClose_node (0,n->GetId (),v.x,v.y);
401
      oss << GetXMLClose ("topology");
402
      WriteN (m_fHandle, oss.str ());
403
    }
404
}
405
406
407
// Helper to output a wireless packet.
408
// For now, only the XML interface is supported
409
410
void AnimationInterface::OutputWirelessPacket (uint32_t uid, AnimPacketInfo& pktInfo)
411
412
{
413
  if (!m_xml) return;
414
  ostringstream oss;
415
  uint32_t nodeId = pktInfo.m_nd->GetNode ()->GetId ();
416
  double lbTx = pktInfo.m_lbTx;
417
418
#if 0 // To be tested
419
420
  // This is a hack until the notify tx end is working
421
  if (lbTx == 0)
422
    {
423
      if (pktInfo.m_rx.empty ())
424
        {
425
          lbTx = pktInfo.m_fbTx + 100E-6; // 100 microsec
426
        }
427
      else
428
        {
429
          lbTx = pktInfo.m_fbTx +
430
            pktInfo.m_rx[0].m_lbRx - pktInfo.m_rx[0].m_fbRx;
431
        }
432
    }
433
434
#endif
435
436
  // Oops, need to figure out about range
437
  oss << GetXMLOpen_wpacket (0,nodeId,pktInfo.m_fbTx,lbTx,500);
438
  // Now add each rx
439
  for (uint32_t i = 0; i < pktInfo.m_rx.size (); ++i)
440
    {
441
      AnimRxInfo& rx = pktInfo.m_rx[i];
442
      uint32_t rxId = rx.m_nd->GetNode ()->GetId ();
443
      oss << GetXMLOpenClose_rx (0,rxId,rx.m_fbRx,rx.m_lbRx);
444
    }
445
  oss << GetXMLClose ("wpacket");
446
  WriteN (m_fHandle, oss.str ());
447
}
448
449
450
// XML Private Helpers
451
452
std::string AnimationInterface::GetXMLOpen_anim (uint32_t lp)
453
{
454
  ostringstream oss;
455
  oss <<"<anim lp = \"" << lp << "\" >\n";
456
  return oss.str ();
457
}
458
std::string AnimationInterface::GetXMLOpen_topology (double minX,double minY,double maxX,double maxY)
459
{
460
  ostringstream oss;
461
  oss <<"<topology minX = \"" << minX << "\" minY = \"" << minY
462
      << "\" maxX = \"" << maxX << "\" maxY = \"" << maxY
463
      << "\">" << endl;
464
  return oss.str ();
465
466
}
467
468
std::string AnimationInterface::GetXMLOpenClose_node (uint32_t lp,uint32_t id,double locX,double locY)
469
{
470
  ostringstream oss;
471
  oss <<"<node lp = \"" << lp << "\" id = \"" << id << "\"" << " locX = \"" 
472
      << locX << "\" " << "locY = \"" << locY << "\" />\n";
473
  return oss.str ();
474
}
475
std::string AnimationInterface::GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId)
476
{
477
  ostringstream oss;
478
  oss << "<link fromLP = \"0\" fromId = \"" << fromId
479
      << "\" toLp = \"0\" toId = \"" << toId
480
      << "\"/>" << endl;
481
  return oss.str ();
482
}
483
484
485
std::string AnimationInterface::GetXMLOpen_packet (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx)
486
{
487
  ostringstream oss;
488
  oss << setprecision (10);
489
  oss << "<packet fromLp = \"" << fromLp << "\" fromId = \"" << fromId
490
      << "\" fbTx = \"" << fbTx
491
      << "\" lbTx = \"" << lbTx
492
      << "\">" << endl;
493
  return oss.str ();
494
}
495
496
std::string AnimationInterface::GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx, double range)
497
{
498
  ostringstream oss;
499
  oss << setprecision (10);
500
  oss << "<wpacket fromLp = \"" << fromLp << "\" fromId = \"" << fromId
501
      << "\" fbTx = \"" << fbTx
502
      << "\" lbTx = \"" << lbTx
503
      << "\" range = \"" << range << "\">" << endl;
504
  return oss.str ();
505
506
}
507
508
std::string AnimationInterface::GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx)
509
{
510
  ostringstream oss;
511
  oss << setprecision (10);
512
  oss << "<rx toLp = \"" << toLp <<"\" toId = \"" << toId
513
      << "\" fbRx = \"" << fbRx
514
      << "\" lbRx = \"" << lbRx
515
      << "\"/>" << endl;
516
  return oss.str ();
517
}
518
519
200
} // namespace ns3
520
} // namespace ns3
(-)a/src/netanim/model/animation-interface.h (-7 / +67 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 Object> nd,
129
                        const Time& txTime, 
130
                        uint32_t nReceivers);
131
  void PhyTxEndTrace (std::string context,
132
                      Ptr<const Packet> p,
133
                      Ptr<const Object> nd);
134
  void PhyRxBeginTrace (std::string context,
135
                        Ptr<const Packet> p,
136
                        Ptr<const Object> nd);
137
  void PhyRxEndTrace (std::string context,
138
                      Ptr<const Packet> p,
139
                      Ptr<const Object> nd);
140
  void PhyRxDropTrace (std::string context,
141
                       Ptr<const Packet> p,
142
                       Ptr<const Object> nd);
143
  void MobilityCourseChangeTrace (Ptr <const MobilityModel> mob);
144
112
  // Write specified amount of data to the specified handle
145
  // Write specified amount of data to the specified handle
113
  int  WriteN (int, const char*, uint32_t);
146
  int  WriteN (int, const char*, uint32_t);
147
  // Write a string to the specified handle;
148
  int  WriteN (int, const std::string&);
149
  //Helper to output xml wireless packet
150
  void OutputWirelessPacket (uint32_t, AnimPacketInfo&);
151
  void MobilityAutoCheck ();
152
  void SetMobilityPollInterval (Time t) {mobilitypollinterval = t;}
114
private:
153
private:
115
  int       m_fHandle;  // File handle for output (-1 if none)
154
  int       m_fHandle;  // File handle for output (-1 if none)
155
  bool      m_xml;      // True if xml format desired
116
  NetModel* m_model;    // If non nil, points to the internal network model
156
  NetModel* m_model;    // If non nil, points to the internal network model
117
                        // for the interlan animator
157
                        // for the interlan animator
158
  std::map<uint32_t, AnimPacketInfo> pendingWirelessPackets;
159
160
// XML helpers
161
162
  // Topology element dimensions
163
  double topo_minX;
164
  double topo_minY;
165
  double topo_maxX;
166
  double topo_maxY;
167
168
  std::string GetXMLOpen_anim (uint32_t lp);
169
  std::string GetXMLOpen_topology (double minX,double minY,double maxX,double maxY);
170
  std::string GetXMLOpenClose_node (uint32_t lp,uint32_t id,double locX,double locY);
171
  std::string GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId);
172
  std::string GetXMLOpen_packet (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx);
173
  std::string GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx);
174
  std::string GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx, double range);
175
  std::string GetXMLClose (std::string name) {return "</" + name + ">\n"; }
176
  Time mobilitypollinterval;
177
118
};
178
};
119
}
179
}
120
#endif
180
#endif
(-)a/src/wifi/model/wifi-phy.cc (-18 / +25 lines)
 Lines 300-340    Link Here 
300
  return MicroSeconds (duration);
300
  return MicroSeconds (duration);
301
}
301
}
302
302
303
304
void
303
void
305
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet)
304
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet, 
305
                        Ptr<const Object> nd,
306
                        const Time& duration,
307
                        uint32_t    nReceivers)
306
{
308
{
307
  m_phyTxBeginTrace (packet);
309
  m_phyTxBeginTrace (packet, nd, duration, nReceivers);
308
}
310
}
309
311
310
void
312
void 
311
WifiPhy::NotifyTxEnd (Ptr<const Packet> packet)
313
WifiPhy::NotifyTxEnd (Ptr<const Packet> packet,
314
                      Ptr<const Object> nd)
312
{
315
{
313
  m_phyTxEndTrace (packet);
316
  m_phyTxEndTrace (packet, nd);
314
}
317
}
315
318
316
void
319
void 
317
WifiPhy::NotifyTxDrop (Ptr<const Packet> packet)
320
WifiPhy::NotifyTxDrop (Ptr<const Packet> packet,
321
                      Ptr<const Object> nd)
318
{
322
{
319
  m_phyTxDropTrace (packet);
323
  m_phyTxDropTrace (packet, nd);
320
}
324
}
321
325
322
void
326
void 
323
WifiPhy::NotifyRxBegin (Ptr<const Packet> packet)
327
WifiPhy::NotifyRxBegin (Ptr<const Packet> packet,
328
                        Ptr<const Object> nd) 
324
{
329
{
325
  m_phyRxBeginTrace (packet);
330
  m_phyRxBeginTrace (packet, nd);
326
}
331
}
327
332
328
void
333
void 
329
WifiPhy::NotifyRxEnd (Ptr<const Packet> packet)
334
WifiPhy::NotifyRxEnd (Ptr<const Packet> packet,
335
                      Ptr<const Object> nd) 
330
{
336
{
331
  m_phyRxEndTrace (packet);
337
  m_phyRxEndTrace (packet, nd);
332
}
338
}
333
339
334
void
340
void 
335
WifiPhy::NotifyRxDrop (Ptr<const Packet> packet)
341
WifiPhy::NotifyRxDrop (Ptr<const Packet> packet,
342
                      Ptr<const Object> nd) 
336
{
343
{
337
  m_phyRxDropTrace (packet);
344
  m_phyRxDropTrace (packet, nd);
338
}
345
}
339
346
340
void
347
void
(-)a/src/wifi/model/wifi-phy.h (-23 / +44 lines)
 Lines 380-418    Link Here 
380
  /**
380
  /**
381
   * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
381
   * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
382
   * purposes.
382
   * purposes.
383
   * \param Ptr to packet to be transmitted
384
   * \param Ptr to device used to transmit
385
   * \param Duration for Transmission
386
   * \param Number of reeivers for the transmission
383
   */
387
   */
384
  void NotifyTxBegin (Ptr<const Packet> packet);
388
  void NotifyTxBegin (Ptr<const Packet> packet, 
385
389
                      Ptr<const Object> nd,
390
                      const Time& duration,
391
                      uint32_t    nReceivers);
386
  /**
392
  /**
387
   * Public method used to fire a PhyTxEnd trace.  Implemented for encapsulation
393
   * Public method used to fire a PhyTxEnd trace.  Implemented for encapsulation
388
   * purposes.
394
   * purposes.
395
   * \param Ptr to packet transmitted
396
   * \param Ptr to device used to transmit
389
   */
397
   */
390
  void NotifyTxEnd (Ptr<const Packet> packet);
398
  void NotifyTxEnd (Ptr<const Packet> packet, Ptr<const Object> nd);
391
392
  /**
399
  /**
393
   * Public method used to fire a PhyTxDrop trace.  Implemented for encapsulation
400
   * Public method used to fire a PhyTxDrop trace.  Implemented for encapsulation
394
   * purposes.
401
   * purposes.
402
   * \param Ptr to packet to be dropped before transmission
403
   * \param Ptr to device used to transmit
395
   */
404
   */
396
  void NotifyTxDrop (Ptr<const Packet> packet);
405
  void NotifyTxDrop (Ptr<const Packet> packet, Ptr<const Object> nd);
397
398
  /**
406
  /**
399
   * Public method used to fire a PhyRxBegin trace.  Implemented for encapsulation
407
   * Public method used to fire a PhyRxBegin trace.  Implemented for encapsulation
400
   * purposes.
408
   * purposes.
409
   * \param Ptr to packet to be received
410
   * \param Ptr to device used to receive
401
   */
411
   */
402
  void NotifyRxBegin (Ptr<const Packet> packet);
412
  void NotifyRxBegin (Ptr<const Packet> packet, Ptr<const Object> nd);
403
404
  /**
413
  /**
405
   * Public method used to fire a PhyRxEnd trace.  Implemented for encapsulation
414
   * Public method used to fire a PhyRxEnd trace.  Implemented for encapsulation
406
   * purposes.
415
   * purposes.
416
   * \param Ptr to packet received
417
   * \param Ptr to device used to receive
407
   */
418
   */
408
  void NotifyRxEnd (Ptr<const Packet> packet);
419
  void NotifyRxEnd (Ptr<const Packet> packet, Ptr<const Object> nd);
409
410
  /**
420
  /**
411
   * Public method used to fire a PhyRxDrop trace.  Implemented for encapsulation
421
   * Public method used to fire a PhyRxDrop trace.  Implemented for encapsulation
412
   * purposes.
422
   * purposes.
423
   * \param Ptr to packet to be dropped on reception
424
   * \param Ptr to device used to receive
413
   */
425
   */
414
  void NotifyRxDrop (Ptr<const Packet> packet);
426
  void NotifyRxDrop (Ptr<const Packet> packet, Ptr<const Object> nd);
415
416
  /**
427
  /**
417
   *
428
   *
418
   * Public method used to fire a PromiscSniffer trace for a wifi packet being received.  Implemented for encapsulation
429
   * Public method used to fire a PromiscSniffer trace for a wifi packet being received.  Implemented for encapsulation
 Lines 456-505    Link Here 
456
  /**
467
  /**
457
   * The trace source fired when a packet begins the transmission process on
468
   * The trace source fired when a packet begins the transmission process on
458
   * the medium.
469
   * the medium.
459
   *
470
   * \param Ptr to packet to be transmitted
471
   * \param Ptr to device used to transmit
472
   * \param Duration for Transmission
473
   * \param Number of reeivers for the transmission
474
   * 
460
   * \see class CallBackTraceSource
475
   * \see class CallBackTraceSource
461
   */
476
   */
462
  TracedCallback<Ptr<const Packet> > m_phyTxBeginTrace;
477
  TracedCallback<Ptr<const Packet>, Ptr<const Object>, const Time&, uint32_t> m_phyTxBeginTrace;
463
478
464
  /**
479
  /**
465
   * The trace source fired when a packet ends the transmission process on
480
   * The trace source fired when a packet ends the transmission process on
466
   * the medium.
481
   * the medium.
482
   * \param Ptr to packet transmitted
483
   * \param Ptr to device used to transmit
467
   *
484
   *
468
   * \see class CallBackTraceSource
485
   * \see class CallBackTraceSource
469
   */
486
   */
470
  TracedCallback<Ptr<const Packet> > m_phyTxEndTrace;
487
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyTxEndTrace;
471
488
472
  /**
489
  /**
473
   * The trace source fired when the phy layer drops a packet as it tries
490
   * The trace source fired when the phy layer drops a packet as it tries
474
   * to transmit it.
491
   * to transmit it.
492
   * \param Ptr to packet to be dropped before transmission
493
   * \param Ptr to device used to transmit
475
   *
494
   *
476
   * \see class CallBackTraceSource
495
   * \see class CallBackTraceSource
477
   */
496
   */
478
  TracedCallback<Ptr<const Packet> > m_phyTxDropTrace;
497
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyTxDropTrace;
479
480
  /**
498
  /**
481
   * The trace source fired when a packet begins the reception process from
499
   * The trace source fired when a packet begins the reception process from
482
   * the medium.
500
   * the medium.
501
   * \param Ptr to packet to be received
502
   * \param Ptr to device used to receive
483
   *
503
   *
484
   * \see class CallBackTraceSource
504
   * \see class CallBackTraceSource
485
   */
505
   */
486
  TracedCallback<Ptr<const Packet> > m_phyRxBeginTrace;
506
  TracedCallback<Ptr<const Packet>, Ptr<const Object> > m_phyRxBeginTrace;
487
488
  /**
507
  /**
489
   * The trace source fired when a packet ends the reception process from
508
   * The trace source fired when a packet ends the reception process from
490
   * the medium.
509
   * the medium.
510
   * \param Ptr to packet received
511
   * \param Ptr to device used to receive
491
   *
512
   *
492
   * \see class CallBackTraceSource
513
   * \see class CallBackTraceSource
493
   */
514
   */
494
  TracedCallback<Ptr<const Packet> > m_phyRxEndTrace;
515
  TracedCallback<Ptr<const Packet> , Ptr<const Object> > m_phyRxEndTrace;
495
496
  /**
516
  /**
497
   * The trace source fired when the phy layer drops a packet it has received.
517
   * The trace source fired when the phy layer drops a packet it has received.
518
   * \param Ptr to packet to be dropped on reception
519
   * \param Ptr to device used to receive
498
   *
520
   *
499
   * \see class CallBackTraceSource
521
   * \see class CallBackTraceSource
500
   */
522
   */
501
  TracedCallback<Ptr<const Packet> > m_phyRxDropTrace;
523
  TracedCallback<Ptr<const Packet> , Ptr<const Object> > m_phyRxDropTrace;
502
503
  /**
524
  /**
504
   * A trace source that emulates a wifi device in monitor mode
525
   * A trace source that emulates a wifi device in monitor mode
505
   * sniffing a packet being received.
526
   * sniffing a packet being received.
(-)a/src/wifi/model/yans-wifi-channel.cc (-1 / +4 lines)
 Lines 74-86    Link Here 
74
  m_delay = delay;
74
  m_delay = delay;
75
}
75
}
76
76
77
void
77
uint32_t
78
YansWifiChannel::Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
78
YansWifiChannel::Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
79
                       WifiMode wifiMode, WifiPreamble preamble) const
79
                       WifiMode wifiMode, WifiPreamble preamble) const
80
{
80
{
81
  Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();
81
  Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();
82
  NS_ASSERT (senderMobility != 0);
82
  NS_ASSERT (senderMobility != 0);
83
  uint32_t j = 0;
83
  uint32_t j = 0;
84
  uint32_t nReceivers = 0;
84
  for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
85
  for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
85
    {
86
    {
86
      if (sender != (*i))
87
      if (sender != (*i))
 Lines 107-117    Link Here 
107
            {
108
            {
108
              dstNode = dstNetDevice->GetObject<NetDevice> ()->GetNode ()->GetId ();
109
              dstNode = dstNetDevice->GetObject<NetDevice> ()->GetNode ()->GetId ();
109
            }
110
            }
111
          nReceivers++;
110
          Simulator::ScheduleWithContext (dstNode,
112
          Simulator::ScheduleWithContext (dstNode,
111
                                          delay, &YansWifiChannel::Receive, this,
113
                                          delay, &YansWifiChannel::Receive, this,
112
                                          j, copy, rxPowerDbm, wifiMode, preamble);
114
                                          j, copy, rxPowerDbm, wifiMode, preamble);
113
        }
115
        }
114
    }
116
    }
117
  return nReceivers;
115
}
118
}
116
119
117
void
120
void
(-)a/src/wifi/model/yans-wifi-channel.h (-1 / +10 lines)
 Lines 76-89    Link Here 
76
   * \param wifiMode the tx mode associated to the packet
76
   * \param wifiMode the tx mode associated to the packet
77
   * \param preamble the preamble associated to the packet
77
   * \param preamble the preamble associated to the packet
78
   *
78
   *
79
   * returns the number of receivers that will receive the packet
79
   * This method should not be invoked by normal users. It is
80
   * This method should not be invoked by normal users. It is
80
   * currently invoked only from WifiPhy::Send. YansWifiChannel
81
   * currently invoked only from WifiPhy::Send. YansWifiChannel
81
   * delivers packets only between PHYs with the same m_channelNumber,
82
   * delivers packets only between PHYs with the same m_channelNumber,
82
   * e.g. PHYs that are operating on the same channel.
83
   * e.g. PHYs that are operating on the same channel.
83
   */
84
   */
84
  void Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
85
  uint32_t Send (Ptr<YansWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm,
85
             WifiMode wifiMode, WifiPreamble preamble) const;
86
             WifiMode wifiMode, WifiPreamble preamble) const;
86
87
88
  /**
89
   * returns the size of m_phyList (number of nodes in range in this channel)
90
   *
91
   */
92
  uint32_t GetPhyListCount () 
93
    { 
94
      return m_phyList.size ();
95
    }
87
private:
96
private:
88
  YansWifiChannel& operator = (const YansWifiChannel &);
97
  YansWifiChannel& operator = (const YansWifiChannel &);
89
  YansWifiChannel (const YansWifiChannel &);
98
  YansWifiChannel (const YansWifiChannel &);
(-)a/src/wifi/model/yans-wifi-phy.cc (-9 / +9 lines)
 Lines 418-424    Link Here 
418
    {
418
    {
419
    case YansWifiPhy::SWITCHING:
419
    case YansWifiPhy::SWITCHING:
420
      NS_LOG_DEBUG ("drop packet because of channel switching");
420
      NS_LOG_DEBUG ("drop packet because of channel switching");
421
      NotifyRxDrop (packet);
421
      NotifyRxDrop (packet, GetDevice ());
422
      /*
422
      /*
423
       * Packets received on the upcoming channel are added to the event list
423
       * Packets received on the upcoming channel are added to the event list
424
       * during the switching state. This way the medium can be correctly sensed
424
       * during the switching state. This way the medium can be correctly sensed
 Lines 437-443    Link Here 
437
    case YansWifiPhy::RX:
437
    case YansWifiPhy::RX:
438
      NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
438
      NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
439
                    rxPowerW << "W)");
439
                    rxPowerW << "W)");
440
      NotifyRxDrop (packet);
440
      NotifyRxDrop (packet, GetDevice ());
441
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
441
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
442
        {
442
        {
443
          // that packet will be noise _after_ the reception of the
443
          // that packet will be noise _after_ the reception of the
 Lines 448-454    Link Here 
448
    case YansWifiPhy::TX:
448
    case YansWifiPhy::TX:
449
      NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
449
      NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
450
                    rxPowerW << "W)");
450
                    rxPowerW << "W)");
451
      NotifyRxDrop (packet);
451
      NotifyRxDrop (packet, GetDevice ());
452
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
452
      if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
453
        {
453
        {
454
          // that packet will be noise _after_ the transmission of the
454
          // that packet will be noise _after_ the transmission of the
 Lines 464-470    Link Here 
464
          // sync to signal
464
          // sync to signal
465
          m_state->SwitchToRx (rxDuration);
465
          m_state->SwitchToRx (rxDuration);
466
          NS_ASSERT (m_endRxEvent.IsExpired ());
466
          NS_ASSERT (m_endRxEvent.IsExpired ());
467
          NotifyRxBegin (packet);
467
          NotifyRxBegin (packet, GetDevice ());
468
          m_interference.NotifyRxStart ();
468
          m_interference.NotifyRxStart ();
469
          m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
469
          m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
470
                                              packet,
470
                                              packet,
 Lines 474-480    Link Here 
474
        {
474
        {
475
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
475
          NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
476
                        rxPowerW << "<" << m_edThresholdW << ")");
476
                        rxPowerW << "<" << m_edThresholdW << ")");
477
          NotifyRxDrop (packet);
477
          NotifyRxDrop (packet, GetDevice ());
478
          goto maybeCcaBusy;
478
          goto maybeCcaBusy;
479
        }
479
        }
480
      break;
480
      break;
 Lines 513-524    Link Here 
513
      m_endRxEvent.Cancel ();
513
      m_endRxEvent.Cancel ();
514
      m_interference.NotifyRxEnd ();
514
      m_interference.NotifyRxEnd ();
515
    }
515
    }
516
  NotifyTxBegin (packet);
517
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
516
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
518
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
517
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
519
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
518
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
520
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
519
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
521
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
520
  uint32_t nReceivers = m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
521
  NotifyTxBegin (packet, GetDevice (), txDuration, nReceivers);
522
}
522
}
523
523
524
uint32_t
524
uint32_t
 Lines 782-788    Link Here 
782
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
782
                ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
783
  if (m_random.GetValue () > snrPer.per)
783
  if (m_random.GetValue () > snrPer.per)
784
    {
784
    {
785
      NotifyRxEnd (packet);
785
      NotifyRxEnd (packet, GetDevice ());
786
      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;
786
      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;
787
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
787
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
788
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
788
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
 Lines 793-799    Link Here 
793
  else
793
  else
794
    {
794
    {
795
      /* failure. */
795
      /* failure. */
796
      NotifyRxDrop (packet);
796
      NotifyRxDrop (packet, GetDevice ());
797
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
797
      m_state->SwitchFromRxEndError (packet, snrPer.snr);
798
    }
798
    }
799
}
799
}

Return to bug 1172