sat-markov-logic-example.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Frans Laakso <frans.laakso@magister.fi>
19  *
20  */
21 
22 #include "ns3/core-module.h"
23 #include "ns3/satellite-module.h"
24 
25 using namespace ns3;
26 
36 NS_LOG_COMPONENT_DEFINE("sat-markov-logic-example");
37 
38 static double g_elevation = 45;
39 static double g_velocity = 0;
40 
41 static double
43 {
44  return g_elevation;
45 }
46 
47 static void
48 SetElevation(double elevation)
49 {
50  g_elevation = elevation;
51 }
52 
53 static double
55 {
56  return g_velocity;
57 }
58 
59 static void
60 SetVelocity(double velocity)
61 {
62  g_velocity = velocity;
63 }
64 
65 int
66 main(int argc, char* argv[])
67 {
69  LogComponentEnable("sat-markov-logic-example", LOG_LEVEL_INFO);
70  LogComponentEnable("SatMarkovContainer", LOG_LEVEL_INFO);
71  LogComponentEnable("SatMarkovModel", LOG_LEVEL_INFO);
72  LogComponentEnable("SatMarkovConf", LOG_LEVEL_INFO);
73 
75  Config::SetDefault("ns3::SatEnvVariables::SimulationCampaignName",
76  StringValue("example-markov-logic"));
77  Config::SetDefault("ns3::SatEnvVariables::SimulationTag", StringValue(""));
78  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
79 
81  Ptr<SatMarkovConf> markovConf = CreateObject<SatMarkovConf>();
82 
83  SatBaseFading::ElevationCallback elevationCb = MakeCallback(&GetElevation);
84  SatBaseFading::VelocityCallback velocityCb = MakeCallback(&GetVelocity);
85 
87  Ptr<SatMarkovContainer> markovContainer =
88  CreateObject<SatMarkovContainer>(markovConf, elevationCb, velocityCb);
89 
90  Address macAddress;
91 
93  Simulator::Schedule(Time("5ms"), &SetVelocity, 0);
94  Simulator::Schedule(Time("10ms"),
96  markovContainer,
97  macAddress,
99  Simulator::Schedule(Time("30ms"),
101  markovContainer,
102  macAddress,
104  Simulator::Schedule(Time("45ms"), &SetElevation, 55);
105  Simulator::Schedule(Time("50ms"),
107  markovContainer,
108  macAddress,
110  Simulator::Schedule(Time("60ms"),
112  markovContainer,
113  macAddress,
115  Simulator::Schedule(Time("90ms"),
117  markovContainer,
118  macAddress,
120  Simulator::Schedule(Time("95ms"), &SetElevation, 75);
121  Simulator::Schedule(Time("100ms"),
123  markovContainer,
124  macAddress,
126  Simulator::Schedule(Time("130ms"),
128  markovContainer,
129  macAddress,
131  Simulator::Schedule(Time("200ms"),
133  markovContainer,
134  macAddress,
136 
137  Simulator::Run();
138  Simulator::Destroy();
139 
140  return 0;
141 }
Callback< double > VelocityCallback
Gets velocity in m/s.
Callback< double > ElevationCallback
Gets elevation angle in degrees.
double DoGetFading(Address macAddress, SatEnums::ChannelType_t channeltype)
Function for getting the fading.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static double g_velocity
static void SetElevation(double elevation)
static double g_elevation
static double GetVelocity()
static void SetVelocity(double velocity)
static double GetElevation()