aboutsummaryrefslogtreecommitdiffstats
path: root/emu-radio/lte-emulator/src
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@email.com>2017-02-24 14:58:01 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2017-02-24 18:36:29 +0000
commit85a341d645b57b7cd88a26ed2ea0a314704240ea (patch)
treebdda2b35003aae20103a796f86daced160b8a730 /emu-radio/lte-emulator/src
parent9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff)
Initial commit: vICN
Change-Id: I7ce66c4e84a6a1921c63442f858b49e083adc7a7 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'emu-radio/lte-emulator/src')
-rw-r--r--emu-radio/lte-emulator/src/lte-emulator.cc184
-rw-r--r--emu-radio/lte-emulator/src/lte-emulator.h61
2 files changed, 245 insertions, 0 deletions
diff --git a/emu-radio/lte-emulator/src/lte-emulator.cc b/emu-radio/lte-emulator/src/lte-emulator.cc
new file mode 100644
index 00000000..b43fcb75
--- /dev/null
+++ b/emu-radio/lte-emulator/src/lte-emulator.cc
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "lte-emulator.h"
+#include <ns3/mobility-module.h>
+
+namespace ns3
+{
+namespace emulator
+{
+
+LteEmulator::LteEmulator (std::unordered_map <std::string, ns3::Ptr<ns3::Node>> &mapNameNode, Ptr <LteTapHelper> ltehelper)
+ : m_mapNameNs3node (mapNameNode),
+ m_lteTapHelper (ltehelper)
+{
+}
+
+bool LteEmulator::getTransmissionRate (const std::string &station, double *transmissionRate)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ int nodeId = (m_mapNameNs3node[station])->GetId ();
+ *transmissionRate = m_lteTapHelper->GetLtePhyTxRate (nodeId);
+
+ return true;
+ }
+
+ return false;
+}
+
+bool LteEmulator::setStationCoordinates (const std::string &station, double x, double y)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ staMobilityModel->SetPosition (Vector (x, y, 0.0));
+ return true;
+ }
+
+ return false;
+}
+
+bool LteEmulator::setStationXCoordinate (const std::string &station, double x)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ staMobilityModel->SetPosition (Vector (x, staMobilityModel->GetPosition ()
+ .y, 0.0));
+ return true;
+ }
+
+ return false;
+}
+
+bool LteEmulator::setStationYCoordinate (const std::string &station, double y)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ staMobilityModel->SetPosition (Vector (staMobilityModel->GetPosition ()
+ .x, y, 0.0));
+ return true;
+ }
+
+ return false;
+}
+
+std::pair<double, double> LteEmulator::getStationCoordinates (const std::string &station)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ return {staMobilityModel->GetPosition ()
+ .x, staMobilityModel->GetPosition ()
+ .y};
+ }
+
+ return {};
+}
+
+bool LteEmulator::getStationXCoordinate (const std::string &station, double *x)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ *x = staMobilityModel->GetPosition ()
+ .x;
+ return true;
+ }
+
+ return false;
+}
+
+bool LteEmulator::getStationYCoordinate (const std::string &station, double *y)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <MobilityModel> staMobilityModel = sta_ptr->GetObject<MobilityModel> ();
+ *y = staMobilityModel->GetPosition ()
+ .y;
+ return true;
+ }
+
+ return false;
+}
+
+LteEmulator &
+LteEmulator::moveStationAlongSegment (const std::string &station, double start_x, double start_y, double end_x, double end_y, double duration)
+{
+ if (m_mapNameNs3node.find (station) == m_mapNameNs3node.end ())
+ {
+ std::cerr << "The station [" << station << "] does not exist in this simulation!" << std::endl;
+ }
+ else
+ {
+ Ptr <Node> sta_ptr = m_mapNameNs3node[station];
+ Ptr <WaypointMobilityModel> staMobilityModel = sta_ptr->GetObject<WaypointMobilityModel> ();
+
+ if (staMobilityModel)
+ {
+
+ staMobilityModel->SetPosition (Vector (start_x, start_y, 0.0));
+ staMobilityModel->AddWaypoint (Waypoint (Seconds (Simulator::Now ().GetSeconds ()), Vector3D (start_x, start_y, 0.0)));
+ staMobilityModel->AddWaypoint (Waypoint (
+ Seconds (Simulator::Now ().GetSeconds ()) + Seconds (duration), Vector3D (end_x, end_y, 0.0)));
+ }
+ else
+ {
+ std::cerr << "Access point has a constant position mobility model. Impossible to move it" << std::endl;
+ }
+ }
+
+ return *this;
+}
+
+} // End namespace ns3
+} // End namespace emulator
diff --git a/emu-radio/lte-emulator/src/lte-emulator.h b/emu-radio/lte-emulator/src/lte-emulator.h
new file mode 100644
index 00000000..a602a612
--- /dev/null
+++ b/emu-radio/lte-emulator/src/lte-emulator.h
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2016, Cisco Systems
+ *
+ * @author Mauro Sardara (msardara@cisco.com)
+ */
+
+#ifndef Lte_EMULATOR_LteEMULATOR_H
+#define Lte_EMULATOR_LteEMULATOR_H
+
+#include "../extensions/lte-tap-helper.h"
+#include <unordered_map>
+
+#include "emulator.h"
+
+#define CONSTANT_POSITION "constant_position"
+#define RANDOM_WAYPOINT "random_waypoint"
+
+//NS_LOG_COMPONENT_DEFINE ("Lte-emulator");
+
+#define SSID "ns-3-ssid"
+
+namespace ns3
+{
+namespace emulator
+{
+
+class LteEmulator : public Emulator {
+
+ public:
+ explicit LteEmulator (std::unordered_map <std::string, ns3::Ptr<ns3::Node>> &mapNameNode, Ptr <LteTapHelper> ltehelper);
+
+ std::pair<double, double> getStationCoordinates (const std::string &station);
+
+ bool setStationCoordinates (const std::string &station, double x, double y);
+
+ bool setStationXCoordinate (const std::string &station, double x);
+
+ bool getStationYCoordinate (const std::string &station, double *y);
+
+ bool getStationXCoordinate (const std::string &station, double *x);
+
+ bool setStationYCoordinate (const std::string &station, double y);
+
+ LteEmulator &
+ moveStationAlongSegment (const std::string &station, double start_x, double start_y, double end_x, double end_y, double duration);
+
+ bool getTransmissionRate (const std::string &station, double *transmissionRate);
+
+ private:
+
+ std::unordered_map <std::string, ns3::Ptr<ns3::Node>> m_mapNameNs3node;
+
+ Ptr <LteTapHelper> m_lteTapHelper;
+
+};
+
+} // End namespace emulator
+
+} // End namespace ns3
+
+#endif //Lte_EMULATOR_LteEMULATOR_H