diff --git a/SConstruct b/SConstruct index 96dad531d..cfd122700 100644 --- a/SConstruct +++ b/SConstruct @@ -531,10 +531,8 @@ ns3.add (common) common.add_sources ([ 'buffer.cc', 'mac-address-factory.cc', - 'static-position.cc', 'chunk.cc', 'mac-network-interface.cc', - 'static-speed-position.cc', 'chunk-constant-data.cc', 'packet.cc', 'tags.cc', @@ -543,10 +541,8 @@ common.add_sources ([ 'chunk-utils.cc', 'pcap-writer.cc', 'trace-container.cc', - 'population-analysis.cc', 'traced-variable-test.cc', 'ipv4-address.cc', - 'position.cc', 'trace-stream-test.cc', 'ipv4-network-interface.cc', 'utils.cc', @@ -572,18 +568,14 @@ common.add_inst_headers ([ 'chunk-utils.h', 'llc-snap-encapsulation.h', 'mac-network-interface.h', - 'population-analysis.h', - 'position.h', 'trace-stream.h', 'pcap-writer.h', 'mac-address-factory.h', - 'static-position.h', 'utils.h' ]) common.add_headers ([ 'chunk-llc-snap.h', 'ref-ptr.h', - 'static-speed-position.h' ]) diff --git a/src/common/population-analysis.cc b/src/common/population-analysis.cc deleted file mode 100644 index 69ade9b8b..000000000 --- a/src/common/population-analysis.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2005 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ - -#include -#include - -#include "population-analysis.h" - -/* This code is a C++ translation of Java code released under the GPLv2 - copyright Mathieu Lacage in treegrowth-stable: - http://cutebugs.net/code/treegrowth-stable. - */ - -namespace ns3 { - -PopulationAnalysis::PopulationAnalysis () -{ - reset (); -} -PopulationAnalysis::~PopulationAnalysis () -{} - -void -PopulationAnalysis::reset (void) -{ - m_n = 0; - m_square_sum = 0.0; - m_mean = 0.0; - m_sum = 0.0; -} - -void -PopulationAnalysis::add_term (double term) -{ - double d = (term - m_mean); - m_n++; - m_mean += d / m_n; - m_square_sum += d * (term - m_mean); - m_sum += term; -} - -uint32_t -PopulationAnalysis::get_n (void) -{ - return m_n; -} -double -PopulationAnalysis::get_total (void) -{ - return m_sum; -} -double -PopulationAnalysis::get_mean (void) -{ - return m_mean; -} -double -PopulationAnalysis::get_standard_deviation (void) -{ - if (m_n == 0) { - return 0.0; - } - assert (get_unbiased_variance () >= 0); - double deviation = sqrt (get_unbiased_variance ()); - return deviation; -} -double -PopulationAnalysis::get_unbiased_variance (void) -{ - if (m_n == 1 || m_n == 0) { - return 0.0; - } - return m_square_sum / (m_n - 1); -} - -}; // namespace ns3 diff --git a/src/common/population-analysis.h b/src/common/population-analysis.h deleted file mode 100644 index 37e20503d..000000000 --- a/src/common/population-analysis.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2005 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ - - -#ifndef POPULATION_ANALYSIS_H -#define POPULATION_ANALYSIS_H - -#include - -namespace ns3 { - -class PopulationAnalysis { -public: - PopulationAnalysis (); - ~PopulationAnalysis (); - - void reset (void); - - void add_term (double term); - - uint32_t get_n (void); - double get_total (void); - double get_mean (void); - double get_standard_deviation (void); - double get_unbiased_variance (void); - -private: - double m_mean; - double m_square_sum; - double m_sum; - uint32_t m_n; -}; - -}; // namespace ns3 - - -#endif /* POPULATION_ANALYSIS_H */ diff --git a/src/common/position.cc b/src/common/position.cc deleted file mode 100644 index f74279511..000000000 --- a/src/common/position.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "position.h" -#include - -namespace ns3 { - -Position::~Position () -{} - -void -Position::get (double &x, double &y, double &z) const -{ - real_get (x,y,z); -} -double -Position::get_distance_from (Position const*position) const -{ - double ox,oy,oz; - double x,y,z; - position->real_get (ox,oy,oz); - real_get (x,y,z); - double dx = ox - x; - double dy = oy - y; - double dz = oz - z; - return sqrt (dx*dx+dy*dy+dz*dz); -} - -}; // namespace ns3 diff --git a/src/common/position.h b/src/common/position.h deleted file mode 100644 index 566f4a639..000000000 --- a/src/common/position.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef POSITION_H -#define POSITION_H - -namespace ns3 { - -class Position { -public: - virtual ~Position () = 0; - - void get (double &x, double &y, double &z) const; - double get_distance_from (Position const*position) const; -private: - virtual void real_get (double &x, double &y, double &z) const = 0; -}; - -}; // namespace ns3 - -#endif /* POSITION_H */ diff --git a/src/common/static-position.cc b/src/common/static-position.cc deleted file mode 100644 index 5e4198083..000000000 --- a/src/common/static-position.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "static-position.h" - -namespace ns3 { - -StaticPosition::StaticPosition () - : m_x (0.0), m_y (0.0), m_z (0.0) -{} -StaticPosition::~StaticPosition () -{} - -void -StaticPosition::set (double x, double y, double z) -{ - m_x = x; - m_y = y; - m_z = z; -} -void -StaticPosition::real_get (double &x, double &y, double &z) const -{ - x = m_x; - y = m_y; - z = m_z; -} - -}; // namespace ns3 diff --git a/src/common/static-position.h b/src/common/static-position.h deleted file mode 100644 index 8b36b22e2..000000000 --- a/src/common/static-position.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef STATIC_POSITION_H -#define STATIC_POSITION_H - -#include "position.h" - -namespace ns3 { - -class StaticPosition : public Position { -public: - StaticPosition (); - virtual ~StaticPosition (); - - void set (double x, double y, double z); -private: - virtual void real_get (double &x, double &y, double &z) const; - double m_x; - double m_y; - double m_z; -}; - -}; // namespace ns3 - -#endif /* STATIC_POSITION_H */ diff --git a/src/common/static-speed-position.cc b/src/common/static-speed-position.cc deleted file mode 100644 index c1c16123c..000000000 --- a/src/common/static-speed-position.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include "static-speed-position.h" -#include "ns3/simulator.h" - -namespace ns3 { - -StaticSpeedPosition::StaticSpeedPosition () - : m_x (0.0), - m_y (0.0), - m_z (0.0), - m_dx (0.0), - m_dy (0.0), - m_dz (0.0), - m_prev_us (0) -{} -StaticSpeedPosition::~StaticSpeedPosition () -{} - -void -StaticSpeedPosition::set (double x, double y, double z) -{ - m_x = x; - m_y = y; - m_z = z; -} - -void -StaticSpeedPosition::set_delta (double dx, double dy, double dz) -{ - m_dx = dx / 1000000; - m_dy = dy / 1000000; - m_dz = dz / 1000000; -} - -void -StaticSpeedPosition::real_get (double &x, double &y, double &z) const -{ - uint64_t now_us = Simulator::now ().us (); - uint64_t delta_us = now_us - m_prev_us; - m_x += m_dx * delta_us; - m_y += m_dy * delta_us; - m_z += m_dz * delta_us; - m_prev_us = now_us; - x = m_x; - y = m_y; - z = m_z; -} - -}; // namespace ns3 diff --git a/src/common/static-speed-position.h b/src/common/static-speed-position.h deleted file mode 100644 index e8bce266c..000000000 --- a/src/common/static-speed-position.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef STATIC_SPEED_POSITION_H -#define STATIC_SPEED_POSITION_H - -#include -#include "position.h" - -namespace ns3 { - -class StaticSpeedPosition : public Position { -public: - StaticSpeedPosition (); - virtual ~StaticSpeedPosition (); - - // m - void set (double x, double y, double z); - // m/s - void set_delta (double dx, double dy, double dz); -private: - virtual void real_get (double &x, double &y, double &z) const; - mutable double m_x; - mutable double m_y; - mutable double m_z; - double m_dx; - double m_dy; - double m_dz; - mutable uint64_t m_prev_us; -}; - -}; // namespace ns3 - -#endif /* STATIC_SPEED_POSITION */ diff --git a/src/core/system-wall-clock-ms.h b/src/core/system-wall-clock-ms.h index 08f39292b..5b0c5e0c8 100644 --- a/src/core/system-wall-clock-ms.h +++ b/src/core/system-wall-clock-ms.h @@ -19,22 +19,22 @@ * Author: Mathieu Lacage */ -#ifndef WALL_CLOCK_MS_H -#define WALL_CLOCK_MS_H +#ifndef SYSTEM_WALL_CLOCK_MS_H +#define SYSTEM_WALL_CLOCK_MS_H namespace ns3 { -class WallClockMs { +class SystemWallClockMs { public: - WallClockMs (); - ~WallClockMs (); + SystemWallClockMs (); + ~SystemWallClockMs (); void start (void); unsigned long long end (void); private: - class WallClockMsPrivate *m_priv; + class SystemWallClockMsPrivate *m_priv; }; }; // namespace ns3 -#endif /* WALL_CLOCK_MS_H */ +#endif /* SYSTEM_WALL_CLOCK_MS_H */ diff --git a/src/core/unix-system-wall-clock-ms.cc b/src/core/unix-system-wall-clock-ms.cc index e4dd08df5..90bc53df0 100644 --- a/src/core/unix-system-wall-clock-ms.cc +++ b/src/core/unix-system-wall-clock-ms.cc @@ -19,12 +19,12 @@ * Author: Mathieu Lacage */ -#include "wall-clock-ms.h" +#include "system-wall-clock-ms.h" #include namespace ns3 { -class WallClockMsPrivate { +class SystemWallClockMsPrivate { public: void start (void); unsigned long long end (void); @@ -34,14 +34,14 @@ private: }; void -WallClockMsPrivate::start (void) +SystemWallClockMsPrivate::start (void) { struct timezone tz; gettimeofday (&m_start_tv, &tz); } unsigned long long -WallClockMsPrivate::end (void) +SystemWallClockMsPrivate::end (void) { struct timezone tz; gettimeofday (&m_end_tv, &tz); @@ -50,23 +50,23 @@ WallClockMsPrivate::end (void) return end - start; } -WallClockMs::WallClockMs () - : m_priv (new WallClockMsPrivate ()) +SystemWallClockMs::SystemWallClockMs () + : m_priv (new SystemWallClockMsPrivate ()) {} -WallClockMs::~WallClockMs () +SystemWallClockMs::~SystemWallClockMs () { delete m_priv; m_priv = 0; } void -WallClockMs::start (void) +SystemWallClockMs::start (void) { m_priv->start (); } unsigned long long -WallClockMs::end (void) +SystemWallClockMs::end (void) { return m_priv->end (); } diff --git a/src/core/win32-system-wall-clock-ms.cc b/src/core/win32-system-wall-clock-ms.cc index b7169e7f2..5503d124d 100644 --- a/src/core/win32-system-wall-clock-ms.cc +++ b/src/core/win32-system-wall-clock-ms.cc @@ -19,11 +19,11 @@ * Author: Mathieu Lacage */ -#include "wall-clock-ms.h" +#include "system-wall-clock-ms.h" namespace ns3 { -class WallClockMsPrivate { +class SystemWallClockMsPrivate { public: void start (void); unsigned long long end (void); @@ -31,33 +31,33 @@ private: }; void -WallClockMsPrivate::start (void) +SystemWallClockMsPrivate::start (void) { } unsigned long long -WallClockMsPrivate::end (void) +SystemWallClockMsPrivate::end (void) { return 0; } -WallClockMs::WallClockMs () - : m_priv (new WallClockMsPrivate ()) +SystemWallClockMs::SystemWallClockMs () + : m_priv (new SystemWallClockMsPrivate ()) {} -WallClockMs::~WallClockMs () +SystemWallClockMs::~SystemWallClockMs () { delete m_priv; m_priv = 0; } void -WallClockMs::start (void) +SystemWallClockMs::start (void) { m_priv->start (); } unsigned long long -WallClockMs::end (void) +SystemWallClockMs::end (void) { return m_priv->end (); } diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc index a575cd57c..c2c28081d 100644 --- a/utils/bench-simulator.cc +++ b/utils/bench-simulator.cc @@ -20,7 +20,7 @@ */ #include "ns3/simulator.h" -#include "ns3/wall-clock-ms.h" +#include "ns3/system-wall-clock-ms.h" #include #include #include @@ -68,7 +68,7 @@ Bench::read_distribution (std::istream &input) void Bench::bench (void) { - WallClockMs time; + SystemWallClockMs time; double init, simu; time.start (); for (std::vector::const_iterator i = m_distribution.begin ();