src/netanim/model/animation-interface.cc
author John Abraham <john.abraham@gatech.edu>
Thu, 18 Aug 2011 19:36:00 -0400
changeset 7454 e1bbc514be33
parent 7443 32635b529440
child 7461 31a035594f68
permissions -rw-r--r--
NetAnim: Simple Write callback
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     2
/*
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     6
 *
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    11
 *
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    15
 *
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    16
 * Author: George F. Riley<riley@ece.gatech.edu>
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    17
 * Modified by: John Abraham <john.abraham@gatech.edu>
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    18
 */
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    19
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    20
// Interface between ns3 and the network animator
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    21
7368
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    22
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    23
// ns3 includes
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    24
#include "ns3/animation-interface.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    25
#include "ns3/netanim-config.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    26
#include "ns3/channel.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    27
#include "ns3/config.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    28
#include "ns3/node.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    29
#include "ns3/mobility-model.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    30
#include "ns3/packet.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    31
#include "ns3/simulator.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    32
#include "ns3/animation-interface-helper.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    33
#include "ns3/wifi-mac-header.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    34
#include "ns3/wimax-mac-header.h"
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
    35
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    36
#include <stdio.h>
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    37
#include <sstream>
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    38
#include <fstream>
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    39
#include <string>
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    40
#include <iomanip>
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    41
#include <map>
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    42
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    43
// Socket related includes
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    44
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    45
#include <sys/socket.h>
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    46
#include <netinet/in.h>
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    47
#else
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    48
#include <fcntl.h>
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    49
#endif
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    50
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    51
NS_LOG_COMPONENT_DEFINE ("AnimationInterface");
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    52
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    53
namespace ns3 {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    54
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    55
AnimationInterface::AnimationInterface ()
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    56
  : m_fHandle (STDOUT_FILENO), m_xml (false), mobilitypollinterval (Seconds(0.25)),
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    57
    usingSockets (false), mport (0), outputfilename (""),
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    58
    OutputFileSet (false), ServerPortSet (false), gAnimUid (0), m_writeCallback (0)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    59
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    60
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    61
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    62
AnimationInterface::AnimationInterface (const std::string fn, bool usingXML)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    63
  : m_fHandle (STDOUT_FILENO), m_xml (usingXML), mobilitypollinterval (Seconds(0.25)), 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    64
    usingSockets (false), mport (0), outputfilename (fn),
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    65
    OutputFileSet (false), ServerPortSet (false), gAnimUid (0), m_writeCallback (0)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    66
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    67
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    68
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    69
AnimationInterface::AnimationInterface (const uint16_t port, bool usingXML)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    70
  : m_fHandle (STDOUT_FILENO), m_xml (usingXML), mobilitypollinterval (Seconds(0.25)), 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    71
    usingSockets (true), mport (port), outputfilename (""),
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    72
    OutputFileSet (false), ServerPortSet (false), gAnimUid (0), m_writeCallback (0)
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    73
{
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    74
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    75
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    76
AnimationInterface::~AnimationInterface ()
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    77
{
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    78
  StopAnimation ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    79
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    80
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    81
void AnimationInterface::SetXMLOutput ()
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    82
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    83
  NS_LOG_INFO ("XML output set");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    84
  m_xml = true;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    85
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    86
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    87
bool AnimationInterface::SetOutputFile (const std::string& fn)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    88
{
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
    89
  if (OutputFileSet)
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    90
    {
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    91
      return true;
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    92
    }
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    93
  if (fn == "")
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    94
    {
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    95
      OutputFileSet = true;
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    96
      return true;
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
    97
    }
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    98
  FILE* f = fopen (fn.c_str (), "w");
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
    99
  if (!f)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   100
    {
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   101
      NS_FATAL_ERROR ("Unable to open Animation output file");
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   102
      return false; // Can't open
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   103
    }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   104
  m_fHandle = fileno (f); // Set the file handle
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   105
  usingSockets = false;
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   106
  outputfilename = fn;
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   107
  OutputFileSet = true;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   108
  return true;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   109
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   110
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   111
void AnimationInterface::SetAnimWriteCallback (AnimWriteCallback cb)
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   112
{
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   113
  m_writeCallback = cb;
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   114
}
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   115
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   116
void AnimationInterface::ResetAnimWriteCallback ()
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   117
{
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   118
  m_writeCallback = 0;
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   119
}
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   120
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   121
bool AnimationInterface::SetServerPort (uint16_t port)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   122
{
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   123
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   124
  if (ServerPortSet)
7368
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
   125
    {
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
   126
      return true;
eaf06b48cb5c Missing header files since modularization for socket cases
John Abraham <john.abraham@gatech.edu>
parents: 7362
diff changeset
   127
    }
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   128
  int s = socket (AF_INET, SOCK_STREAM, 0);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   129
  struct sockaddr_in addr;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   130
  addr.sin_family = AF_INET;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   131
  addr.sin_port = htons (port);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   132
  addr.sin_addr.s_addr = htonl (INADDR_ANY);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   133
  if (bind (s, (struct sockaddr*)&addr, sizeof (addr)) < 0)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   134
    {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   135
      NS_LOG_WARN ("Can't bind to port " << port << ", exiting.");
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   136
      return false;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   137
    }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   138
  listen (s, 1);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   139
  NS_LOG_INFO ("Waiting for animator connection");
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   140
  // Now wait for the animator to connect in
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   141
  m_fHandle = accept (s, 0, 0);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   142
  NS_LOG_INFO ("Got animator connection from remote");
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   143
  // set the linger socket option
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   144
  int t = 1;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   145
  setsockopt (s, SOL_SOCKET, SO_LINGER, &t, sizeof(t));
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   146
  usingSockets = true;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   147
  ServerPortSet = true;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   148
  return true;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   149
#endif
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   150
  return false; // never reached unless the above is disabled
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   151
                // which is done to support a platform like MinGW
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   152
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   153
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   154
bool AnimationInterface::WifiPacketIsPending (uint64_t AnimUid)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   155
{
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   156
  return (pendingWifiPackets.find (AnimUid) != pendingWifiPackets.end ());
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   157
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   158
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   159
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   160
bool AnimationInterface::WimaxPacketIsPending (uint64_t AnimUid)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   161
{
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   162
  return (pendingWimaxPackets.find (AnimUid) != pendingWimaxPackets.end ());
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   163
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   164
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   165
void AnimationInterface::SetMobilityPollInterval (Time t)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   166
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   167
  mobilitypollinterval = t;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   168
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   169
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   170
Vector AnimationInterface::UpdatePosition (Ptr <Node> n)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   171
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   172
  Ptr<MobilityModel> loc = n->GetObject<MobilityModel> ();
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   173
  Vector v(100,100,0);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   174
  if (loc)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   175
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   176
      v = loc->GetPosition ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   177
    }
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   178
  else
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   179
   {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   180
     NS_LOG_WARN ( "Node:" << n->GetId () << " Does not have a mobility model");
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   181
   }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   182
  nodeLocation[n->GetId ()] = v;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   183
  return v;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   184
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   185
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   186
Vector AnimationInterface::UpdatePosition (Ptr <Node> n, Vector v)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   187
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   188
  nodeLocation[n->GetId ()] = v;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   189
  return v;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   190
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   191
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   192
Vector AnimationInterface::GetPosition (Ptr <Node> n)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   193
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   194
  #ifdef NS_LOG
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   195
  if (nodeLocation.find (n->GetId()) == nodeLocation.end ())
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   196
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   197
      NS_FATAL_ERROR ("Node:" <<n->GetId() << " not found in Location table");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   198
    }  
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   199
  #endif
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   200
  return nodeLocation[n->GetId ()];
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   201
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   202
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   203
void AnimationInterface::StartAnimation ()
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   204
{
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   205
  if (usingSockets)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   206
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   207
      SetServerPort (mport);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   208
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   209
  else
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   210
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   211
      SetOutputFile (outputfilename);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   212
    }      
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   213
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   214
  // Find the min/max x/y for the xml topology element
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   215
  topo_minX = 0;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   216
  topo_minY = 0;
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   217
  topo_maxX = 0;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   218
  topo_maxY = 0;
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   219
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   220
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   221
      Ptr<Node> n = *i;
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   222
      NS_LOG_INFO ("Update Position for Node: " << n->GetId ());
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   223
      Vector v = UpdatePosition (n); 
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   224
      topo_minX = std::min (topo_minX, v.x);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   225
      topo_minY = std::min (topo_minY, v.y);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   226
      topo_maxX = std::max (topo_maxX, v.x);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   227
      topo_maxY = std::max (topo_maxY, v.y);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   228
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   229
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   230
  AddMargin ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   231
  if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   232
    { // output the xml headers
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   233
      std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   234
      oss << GetXMLOpen_anim (0);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   235
      oss << GetPreamble ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   236
      oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_maxY);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   237
      WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   238
    }
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   239
  NS_LOG_INFO ("Setting topology for "<<NodeList::GetNNodes ()<<" Nodes");
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   240
  // Dump the topology
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   241
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   242
    {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   243
      Ptr<Node> n = *i;
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   244
      std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   245
      if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   246
        {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   247
          Vector v = GetPosition (n);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   248
          oss << GetXMLOpenClose_node (0,n->GetId (),v.x,v.y);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   249
        }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   250
      else
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   251
        {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   252
          // Location exists, dump it
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   253
          Vector v = GetPosition (n);
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   254
          oss << "0.0 N " << n->GetId () 
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   255
              << " " << v.x << " " << v.y << std::endl;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   256
        }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   257
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   258
      WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ());
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   259
    }
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   260
  NS_LOG_INFO ("Setting p2p links");
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   261
  // Now dump the p2p links
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   262
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   263
    {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   264
      Ptr<Node> n = *i;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   265
      uint32_t n1Id = n->GetId ();
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   266
      uint32_t nDev = n->GetNDevices ();  // Number of devices
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   267
      for (uint32_t i = 0; i < nDev; ++i)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   268
        {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   269
          Ptr<NetDevice> dev = n->GetDevice (i);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   270
 	  NS_ASSERT (dev);
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   271
          Ptr<Channel>   ch = dev->GetChannel ();
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   272
          if (!ch) 
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   273
            {
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   274
	      NS_LOG_DEBUG ("No channel can't be a p2p device");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   275
              continue;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   276
            }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   277
          std::string channelType = ch->GetInstanceTypeId ().GetName ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   278
          if (channelType == std::string ("ns3::PointToPointChannel"))
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   279
            { // Since these are duplex links, we only need to dump
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   280
              // if srcid < dstid
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   281
              uint32_t nChDev = ch->GetNDevices ();
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   282
              for (uint32_t j = 0; j < nChDev; ++j)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   283
                {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   284
                  Ptr<NetDevice> chDev = ch->GetDevice (j);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   285
                  uint32_t n2Id = chDev->GetNode ()->GetId ();
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   286
                  if (n1Id < n2Id)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   287
                    { // ouptut the p2p link
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   288
                      std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   289
                      if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   290
                        {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   291
                          oss << GetXMLOpenClose_link (0,n1Id,0,n2Id);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   292
                        }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   293
                      else
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   294
                        {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   295
                          oss << "0.0 L "  << n1Id << " " << n2Id << std::endl;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   296
                        }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   297
                      WriteN (m_fHandle, oss.str ());
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   298
                    }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   299
                }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   300
            }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   301
          else
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   302
            {
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   303
              //NS_FATAL_ERROR ("Net animation currently only supports point-to-point links.");
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   304
            }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   305
        }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   306
    }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   307
  if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   308
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   309
      WriteN (m_fHandle, GetXMLClose ("topology"));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   310
      Simulator::Schedule (mobilitypollinterval, &AnimationInterface::MobilityAutoCheck, this);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   311
    }
7181
7ff8011cf487 net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7089
diff changeset
   312
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   313
  // Connect the callbacks
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   314
  Config::Connect ("/ChannelList/*/TxRxPointToPoint",
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   315
                   MakeCallback (&AnimationInterface::DevTxTrace, this));
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   316
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   317
                   MakeCallback (&AnimationInterface::WifiPhyTxBeginTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   318
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxEnd",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   319
                   MakeCallback (&AnimationInterface::WifiPhyTxEndTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   320
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   321
                   MakeCallback (&AnimationInterface::WifiPhyRxBeginTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   322
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   323
                   MakeCallback (&AnimationInterface::WifiPhyRxEndTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   324
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   325
                   MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   326
  Config::ConnectWithoutContext ("/NodeList/*/$ns3::MobilityModel/CourseChange",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   327
                   MakeCallback (&AnimationInterface::MobilityCourseChangeTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   328
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Tx",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   329
                   MakeCallback (&AnimationInterface::WimaxTxTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   330
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Rx",
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   331
                   MakeCallback (&AnimationInterface::WimaxRxTrace, this));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   332
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   333
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   334
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   335
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   336
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   337
void AnimationInterface::StopAnimation ()
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   338
{
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   339
  NS_LOG_INFO ("Stopping Animation");
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   340
  if (m_fHandle > 0) 
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   341
    {
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   342
      if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   343
        { // Terminate the anim element
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   344
          WriteN (m_fHandle, GetXMLClose ("anim"));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   345
        }
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   346
      close (m_fHandle);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   347
      m_fHandle = 0;
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   348
    }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   349
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   350
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   351
int AnimationInterface::WriteN (int h, const std::string& st)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   352
{
7454
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   353
  if (m_writeCallback)
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   354
    {
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   355
      m_writeCallback (st.c_str ());
e1bbc514be33 NetAnim: Simple Write callback
John Abraham <john.abraham@gatech.edu>
parents: 7443
diff changeset
   356
    }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   357
  return WriteN (h, st.c_str (), st.length ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   358
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   359
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   360
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   361
// Private methods
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   362
void AnimationInterface::AddMargin ()
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   363
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   364
  // Compute width/height, and add a small margin
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   365
  double w = topo_maxX - topo_minX;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   366
  double h = topo_maxY - topo_minY;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   367
  topo_minX -= w * 0.05;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   368
  topo_minY -= h * 0.05;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   369
  topo_maxX = topo_minX + w * 1.5;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   370
  topo_maxY = topo_minY + h * 1.5;
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   371
  NS_LOG_INFO ("Added Canvas Margin:" << topo_minX << "," <<
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   372
               topo_minY << "," << topo_maxX << "," << topo_maxY);                 
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   373
}
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   374
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   375
std::vector <Ptr <Node> >  AnimationInterface::RecalcTopoBounds ()
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   376
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   377
  std::vector < Ptr <Node> > MovedNodes;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   378
  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   379
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   380
      Ptr<Node> n = *i;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   381
      NS_ASSERT (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   382
      Ptr <MobilityModel> mobility = n->GetObject <MobilityModel> ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   383
      Vector newLocation;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   384
      if (!mobility)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   385
        {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   386
          newLocation = GetPosition (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   387
        }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   388
      else
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   389
        {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   390
          newLocation = mobility->GetPosition ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   391
        }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   392
      if (!NodeHasMoved (n, newLocation))
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   393
        {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   394
          continue; //Location has not changed
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   395
        }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   396
      else
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   397
        {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   398
          UpdatePosition (n, newLocation);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   399
          RecalcTopoBounds (newLocation);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   400
          MovedNodes.push_back (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   401
        }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   402
    }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   403
  return MovedNodes;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   404
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   405
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   406
void AnimationInterface::RecalcTopoBounds (Vector v)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   407
{
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   408
  double oldminX = topo_minX;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   409
  double oldminY = topo_minY;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   410
  double oldmaxX = topo_maxX;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   411
  double oldmaxY = topo_maxY;
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   412
  topo_minX = std::min (topo_minX, v.x);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   413
  topo_minY = std::min (topo_minY, v.y);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   414
  topo_maxX = std::max (topo_maxX, v.x);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   415
  topo_maxY = std::max (topo_maxY, v.y);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   416
  
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   417
  if ((topo_minX != oldminX) || (topo_minY != oldminY) ||
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   418
      (topo_maxX != oldmaxX) || (topo_maxY != oldmaxY))
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   419
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   420
      AddMargin ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   421
    } 
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   422
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   423
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   424
int AnimationInterface::WriteN (int h, const char* data, uint32_t count)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   425
{ // Write count bytes to h from data
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   426
  uint32_t    nLeft   = count;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   427
  const char* p       = data;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   428
  uint32_t    written = 0;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   429
  while (nLeft)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   430
    {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   431
      int n = write (h, p, nLeft);
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   432
      if (n <= 0) 
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   433
        {
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   434
          return written;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   435
        }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   436
      written += n;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   437
      nLeft -= n;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   438
      p += n;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   439
    }
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   440
  return written;
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   441
}
7181
7ff8011cf487 net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7089
diff changeset
   442
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   443
void AnimationInterface::WriteDummyPacket ()
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   444
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   445
  Time now = Simulator::Now ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   446
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   447
  double fbTx = now.GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   448
  double lbTx = now.GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   449
  double fbRx = now.GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   450
  double lbRx = now.GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   451
  if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   452
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   453
      oss << GetXMLOpen_packet (0,0,fbTx,lbTx);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   454
      oss << GetXMLOpenClose_rx (0,0,fbRx,lbRx);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   455
      oss << GetXMLClose ("packet");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   456
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   457
  WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   458
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   459
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   460
}
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   461
void AnimationInterface::DevTxTrace (std::string context, Ptr<const Packet> p,
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   462
                                     Ptr<NetDevice> tx, Ptr<NetDevice> rx,
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   463
                                     Time txTime, Time rxTime)
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   464
{
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   465
  NS_ASSERT (tx);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   466
  NS_ASSERT (rx);
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   467
  Time now = Simulator::Now ();
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   468
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   469
  double fbTx = now.GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   470
  double lbTx = (now + txTime).GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   471
  double fbRx = (now + rxTime - txTime).GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   472
  double lbRx = (now + rxTime).GetSeconds ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   473
  if (m_xml)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   474
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   475
      oss << GetXMLOpen_packet (0,tx->GetNode ()->GetId (),fbTx,lbTx);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   476
      oss << GetXMLOpenClose_rx (0,rx->GetNode ()->GetId (),fbRx,lbRx); 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   477
      oss << GetXMLClose ("packet");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   478
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   479
  else
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   480
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   481
      oss << std::setprecision (10);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   482
      oss << now.GetSeconds () << " P "
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   483
          << tx->GetNode ()->GetId () << " "
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   484
          << rx->GetNode ()->GetId () << " "
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   485
          << (now + txTime).GetSeconds () << " " // last bit tx time
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   486
          << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   487
          << (now + rxTime).GetSeconds () << std::endl;         // last bit rx time
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   488
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   489
  WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   490
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   491
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   492
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   493
Ptr <NetDevice>
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   494
AnimationInterface::GetNetDeviceFromContext (std::string context)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   495
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   496
  // Use "NodeList/*/DeviceList/*/ as reference
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   497
  // where element [1] is the Node Id
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   498
  // element [2] is the NetDevice Id
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   499
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   500
  std::vector <std::string> elements = GetElementsFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   501
  Ptr <Node> n = NodeList::GetNode (atoi (elements[1].c_str ()));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   502
  NS_ASSERT (n);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   503
  return n->GetDevice (atoi (elements[3].c_str ()));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   504
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   505
                                  
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   506
void AnimationInterface::AddPendingWifiPacket (uint64_t AnimUid, AnimPacketInfo &pktinfo)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   507
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   508
  NS_ASSERT (pktinfo.m_txnd);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   509
  pendingWifiPackets[AnimUid] = pktinfo;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   510
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   511
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   512
void AnimationInterface::AddPendingWimaxPacket (uint64_t AnimUid, AnimPacketInfo &pktinfo)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   513
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   514
  NS_ASSERT (pktinfo.m_txnd);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   515
  pendingWimaxPackets[AnimUid] = pktinfo;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   516
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   517
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   518
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   519
uint64_t AnimationInterface::GetAnimUidFromPacket (Ptr <const Packet> p)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   520
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   521
  AnimByteTag tag;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   522
  if (p->FindFirstMatchingByteTag (tag))
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   523
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   524
      return tag.Get ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   525
    }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   526
  else
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   527
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   528
      return 0;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   529
    }
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   530
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   531
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   532
void AnimationInterface::WifiPhyTxBeginTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   533
                                          Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   534
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   535
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   536
  NS_ASSERT (ndev);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   537
  Ptr <Node> n = ndev->GetNode ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   538
  NS_ASSERT (n);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   539
  // Add a new pending wireless
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   540
  gAnimUid++;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   541
  NS_LOG_INFO ("TxBeginTrace for packet:" << gAnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   542
  AnimByteTag tag;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   543
  tag.Set (gAnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   544
  p->AddByteTag (tag);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   545
  AnimPacketInfo pktinfo (ndev, Simulator::Now (), Simulator::Now (), UpdatePosition (n));
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   546
  AddPendingWifiPacket (gAnimUid, pktinfo);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   547
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   548
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   549
void AnimationInterface::WifiPhyTxEndTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   550
                                            Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   551
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   552
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   553
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   554
void AnimationInterface::WifiPhyTxDropTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   555
                                             Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   556
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   557
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   558
  NS_ASSERT (ndev);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   559
  // Erase pending wifi
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   560
  uint64_t AnimUid = GetAnimUidFromPacket (p);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   561
  NS_LOG_INFO ("TxDropTrace for packet:" << AnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   562
  NS_ASSERT (WifiPacketIsPending (AnimUid) == true);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   563
  pendingWifiPackets.erase (pendingWifiPackets.find (AnimUid));
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   564
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   565
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   566
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   567
void AnimationInterface::WifiPhyRxBeginTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   568
                                              Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   569
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   570
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   571
  NS_ASSERT (ndev);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   572
  uint64_t AnimUid = GetAnimUidFromPacket (p);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   573
  NS_LOG_INFO ("RxBeginTrace for packet:" << AnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   574
  NS_ASSERT (WifiPacketIsPending (AnimUid) == true);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   575
  pendingWifiPackets[AnimUid].ProcessRxBegin (ndev, Simulator::Now ());
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   576
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   577
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   578
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   579
void AnimationInterface::WifiPhyRxEndTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   580
                                            Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   581
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   582
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   583
  NS_ASSERT (ndev);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   584
  Ptr <Node> n = ndev->GetNode ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   585
  NS_ASSERT (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   586
  uint64_t AnimUid = GetAnimUidFromPacket (p);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   587
  NS_ASSERT (WifiPacketIsPending (AnimUid) == true);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   588
  AnimPacketInfo& pktInfo = pendingWifiPackets[AnimUid];
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   589
  if (pktInfo.ProcessRxEnd (ndev, Simulator::Now (), UpdatePosition (n)))
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   590
    {
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   591
      AnimRxInfo pktrxInfo = pktInfo.GetRxInfo (ndev);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   592
      NS_LOG_INFO ("RxEndTrace for packet:" << AnimUid << " complete");
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   593
      OutputWirelessPacket (pktInfo, pktrxInfo);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   594
      pktInfo.RemoveRxInfo (ndev);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   595
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   596
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   597
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   598
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   599
void AnimationInterface::WifiPhyRxDropTrace (std::string context,
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   600
                                             Ptr<const Packet> p)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   601
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   602
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   603
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   604
void AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   605
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   606
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   607
  NS_ASSERT (ndev);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   608
  Ptr <Node> n = ndev->GetNode ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   609
  NS_ASSERT (n);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   610
  gAnimUid++;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   611
  NS_LOG_INFO ("WimaxTxTrace for packet:" << gAnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   612
  AnimPacketInfo pktinfo (ndev, Simulator::Now (), Simulator::Now () + Seconds (0.001), UpdatePosition (n));
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   613
  //TODO 0.0001 is used until Wimax implements TxBegin and TxEnd traces
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   614
  AnimByteTag tag;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   615
  tag.Set (gAnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   616
  p->AddByteTag (tag);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   617
  AddPendingWimaxPacket (gAnimUid, pktinfo);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   618
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   619
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   620
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   621
void AnimationInterface::WimaxRxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   622
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   623
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   624
  NS_ASSERT (ndev);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   625
  Ptr <Node> n = ndev->GetNode ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   626
  NS_ASSERT (n);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   627
  uint64_t AnimUid = GetAnimUidFromPacket (p);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   628
  NS_ASSERT (WimaxPacketIsPending (AnimUid) == true);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   629
  AnimPacketInfo& pktInfo = pendingWimaxPackets[AnimUid];
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   630
  pktInfo.ProcessRxBegin (ndev, Simulator::Now ());
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   631
  pktInfo.ProcessRxEnd (ndev, Simulator::Now () + Seconds (0.001), UpdatePosition (n));
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   632
  //TODO 0.001 is used until Wimax implements RxBegin and RxEnd traces
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   633
  AnimRxInfo pktrxInfo = pktInfo.GetRxInfo (ndev);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   634
  OutputWirelessPacket (pktInfo, pktrxInfo);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   635
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   636
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   637
void AnimationInterface::MobilityCourseChangeTrace (Ptr <const MobilityModel> mobility)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   638
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   639
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   640
  Ptr <Node> n = mobility->GetObject <Node> ();
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   641
  NS_ASSERT (n);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   642
  Vector v ;
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   643
  if (!mobility)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   644
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   645
      v = GetPosition (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   646
    } 
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   647
  else
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   648
    {
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   649
      v = mobility->GetPosition ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   650
    }
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   651
  UpdatePosition (n,v);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   652
  RecalcTopoBounds (v);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   653
  std::ostringstream oss; 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   654
  oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_maxY);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   655
  oss << GetXMLOpenClose_node (0,n->GetId (),v.x,v.y);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   656
  oss << GetXMLClose ("topology");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   657
  WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   658
  WriteDummyPacket ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   659
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   660
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   661
bool AnimationInterface::NodeHasMoved (Ptr <Node> n, Vector newLocation)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   662
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   663
  Vector oldLocation = GetPosition (n);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   664
  if ((ceil(oldLocation.x) == ceil(newLocation.x)) &&
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   665
    (ceil(oldLocation.y) == ceil(newLocation.y)))
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   666
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   667
     
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   668
      return false;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   669
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   670
  else
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   671
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   672
      return true;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   673
    }
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   674
}
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   675
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   676
void AnimationInterface::MobilityAutoCheck ()
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   677
{
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   678
  std::vector <Ptr <Node> > MovedNodes = RecalcTopoBounds ();
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   679
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   680
  oss << GetXMLOpen_topology (topo_minX,topo_minY,topo_maxX,topo_maxY);
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   681
  for (uint32_t i = 0; i < MovedNodes.size (); i++)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   682
    {
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   683
      Ptr <Node> n = MovedNodes [i];
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   684
      NS_ASSERT (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   685
      Vector v = GetPosition (n);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   686
      oss << GetXMLOpenClose_node (0,n->GetId (), v.x, v.y);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   687
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   688
  oss << GetXMLClose ("topology");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   689
  WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   690
  WriteDummyPacket ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   691
  if (!Simulator::IsFinished ())
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   692
    {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   693
      Simulator::Schedule (mobilitypollinterval, &AnimationInterface::MobilityAutoCheck, this);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   694
    }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   695
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   696
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   697
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   698
// Helper to output a wireless packet.
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   699
// For now, only the XML interface is supported
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   700
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   701
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   702
std::string AnimationInterface::GetPreamble ()
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   703
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   704
  std::string s = 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   705
    "<information><!-- \n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   706
    Description of attributes:\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   707
    =========================\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   708
    anim\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   709
    * lp = Logical Processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   710
    topology\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   711
    * minX = minimum X coordinate of the canvas\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   712
    * minY = minimum Y coordinate of the canvas\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   713
    * maxX = maximum X coordinate of the canvas\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   714
    * maxY = maximum Y coordinate of the canvas\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   715
    node\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   716
    * lp = Logical Processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   717
    * id = Node Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   718
    * locX = X coordinate\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   719
    * locY = Y coordinate\n\
7443
32635b529440 NetAnim minor comments
John Abraham <john.abraham@gatech.edu>
parents: 7368
diff changeset
   720
    link\n\
32635b529440 NetAnim minor comments
John Abraham <john.abraham@gatech.edu>
parents: 7368
diff changeset
   721
    * fromLp = From logical processor Id\n\
32635b529440 NetAnim minor comments
John Abraham <john.abraham@gatech.edu>
parents: 7368
diff changeset
   722
    * fromId = From Node Id\n\
32635b529440 NetAnim minor comments
John Abraham <john.abraham@gatech.edu>
parents: 7368
diff changeset
   723
    * toLp   = To logical processor Id\n\
32635b529440 NetAnim minor comments
John Abraham <john.abraham@gatech.edu>
parents: 7368
diff changeset
   724
    * toId   = To Node Id\n\
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   725
    packet\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   726
    * fromLp = From logical processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   727
    * fbTx = First bit transmit time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   728
    * lbTx = Last bit transmit time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   729
    rx\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   730
    * toLp = To logical processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   731
    * toId = To Node Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   732
    * fbRx = First bit Rx Time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   733
    * lbRx = Last bit Rx\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   734
    wpacket\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   735
    * fromLp = From logical processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   736
    * fromId = From Node Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   737
    * fbTx = First bit transmit time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   738
    * lbTx = Last bit transmit time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   739
    * range = Reception range\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   740
    rx\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   741
    * toLp = To logical processor Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   742
    * toId = To Node Id\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   743
    * fbRx = First bit Rx time\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   744
    * lbRx = Last bit Rx time-->\n\
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   745
    </information>\n";
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   746
return s;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   747
}
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   748
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   749
void AnimationInterface::OutputWirelessPacket (AnimPacketInfo &pktInfo, AnimRxInfo pktrxInfo)
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   750
{
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   751
  NS_ASSERT (m_xml);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   752
  std::ostringstream oss;
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   753
  NS_ASSERT (pktInfo.m_txnd);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   754
  uint32_t nodeId = pktInfo.m_txnd->GetNode ()->GetId ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   755
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   756
  double lbTx = pktInfo.firstlastbitDelta + pktInfo.m_fbTx;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   757
  oss << GetXMLOpen_wpacket (0, nodeId, pktInfo.m_fbTx, lbTx, pktrxInfo.rxRange);
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   758
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   759
  uint32_t rxId = pktrxInfo.m_rxnd->GetNode ()->GetId ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   760
  oss << GetXMLOpenClose_rx (0, rxId, pktrxInfo.m_fbRx, pktrxInfo.m_lbRx);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   761
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   762
  oss << GetXMLClose ("wpacket");
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   763
  WriteN (m_fHandle, oss.str ());
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   764
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   765
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   766
// XML Private Helpers
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   767
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   768
std::string AnimationInterface::GetXMLOpen_anim (uint32_t lp)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   769
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   770
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   771
  oss <<"<anim lp = \"" << lp << "\" >\n";
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   772
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   773
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   774
std::string AnimationInterface::GetXMLOpen_topology (double minX,double minY,double maxX,double maxY)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   775
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   776
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   777
  oss << "<topology minX = \"" << minX << "\" minY = \"" << minY
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   778
      << "\" maxX = \"" << maxX << "\" maxY = \"" << maxY
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   779
      << "\">" << std::endl;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   780
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   781
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   782
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   783
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   784
std::string AnimationInterface::GetXMLOpenClose_node (uint32_t lp,uint32_t id,double locX,double locY)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   785
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   786
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   787
  oss <<"<node lp = \"" << lp << "\" id = \"" << id << "\"" << " locX = \"" 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   788
      << locX << "\" " << "locY = \"" << locY << "\" />\n";
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   789
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   790
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   791
std::string AnimationInterface::GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   792
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   793
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   794
  oss << "<link fromLp=\"0\" fromId=\"" << fromId
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   795
      << "\" toLp=\"0\" toId=\"" << toId
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   796
      << "\"/>" << std::endl;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   797
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   798
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   799
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   800
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   801
std::string AnimationInterface::GetXMLOpen_packet (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   802
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   803
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   804
  oss << std::setprecision (10);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   805
  oss << "<packet fromLp=\"" << fromLp << "\" fromId=\"" << fromId
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   806
      << "\" fbTx=\"" << fbTx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   807
      << "\" lbTx=\"" << lbTx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   808
      << "\">";
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   809
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   810
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   811
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   812
std::string AnimationInterface::GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fromId, double fbTx, double lbTx, double range)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   813
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   814
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   815
  oss << std::setprecision (10);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   816
  oss << "<wpacket fromLp = \"" << fromLp << "\" fromId = \"" << fromId
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   817
      << "\" fbTx = \"" << fbTx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   818
      << "\" lbTx = \"" << lbTx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   819
      << "\" range = \"" << range << "\">" << std::endl;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   820
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   821
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   822
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   823
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   824
std::string AnimationInterface::GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   825
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   826
  std::ostringstream oss;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   827
  oss << std::setprecision (10);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   828
  oss << "<rx toLp=\"" << toLp <<"\" toId=\"" << toId
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   829
      << "\" fbRx=\"" << fbRx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   830
      << "\" lbRx=\"" << lbRx
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   831
      << "\"/>" << std::endl;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   832
  return oss.str ();
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   833
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   834
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   835
std::vector<std::string> AnimationInterface::GetElementsFromContext (std::string context)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   836
{
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   837
  std::vector <std::string> elements;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   838
  size_t pos1=0, pos2;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   839
  while (pos1 != context.npos)
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   840
  {
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   841
    pos1 = context.find ("/",pos1);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   842
    pos2 = context.find ("/",pos1+1);
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   843
    elements.push_back (context.substr (pos1+1,pos2-(pos1+1)));
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   844
    pos1 = pos2; 
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   845
    pos2 = context.npos;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   846
  }
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   847
  return elements;
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   848
}
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   849
7362
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   850
TypeId
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   851
AnimByteTag::GetTypeId (void)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   852
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   853
  static TypeId tid = TypeId ("ns3::AnimByteTag")
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   854
    .SetParent<Tag> ()
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   855
    .AddConstructor<AnimByteTag> ()
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   856
  ;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   857
  return tid;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   858
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   859
TypeId
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   860
AnimByteTag::GetInstanceTypeId (void) const
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   861
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   862
  return GetTypeId ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   863
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   864
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   865
uint32_t
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   866
AnimByteTag::GetSerializedSize (void) const
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   867
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   868
  return sizeof (uint64_t);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   869
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   870
void
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   871
AnimByteTag::Serialize (TagBuffer i) const
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   872
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   873
  i.WriteU64 (m_AnimUid);
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   874
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   875
void
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   876
AnimByteTag::Deserialize (TagBuffer i)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   877
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   878
  m_AnimUid = i.ReadU64 ();
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   879
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   880
void
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   881
AnimByteTag::Print (std::ostream &os) const
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   882
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   883
  os << "AnimUid=" << m_AnimUid;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   884
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   885
void
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   886
AnimByteTag::Set (uint64_t AnimUid)
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   887
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   888
  m_AnimUid = AnimUid;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   889
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   890
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   891
uint64_t
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   892
AnimByteTag::Get (void) const
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   893
{
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   894
  return m_AnimUid;
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   895
}
36b42a8b16d1 Bug 1172 Special case handling for duplicates,forwards and some doxygen fixes
John Abraham <john.abraham@gatech.edu>
parents: 7360
diff changeset
   896
7360
5949904cf955 Bug 1172 Implement trivial XML output feature for Animation Interface
John Abraham <john.abraham@gatech.edu>
parents: 7256
diff changeset
   897
5776
aae948449722 Moved net-anim from contrib
Josh Pelkey <jpelkey@gatech.edu>
parents:
diff changeset
   898
} // namespace ns3