To implement a hybrid satellite-terrestrial relay network in ns3, we need to create a simulation environment. In that data transmission, aided with terrestrial relays while communication occurs between ground stations and satellites. To represent ground stations, satellites, and terrestrial relays, and establishing communication links between them we need to configure the nodes for setting up the network. The following steps will guide on setting up the Hybrid satellite terrestrial relay network in ns3.
Step-by-step guide to set-up hybrid satellite-terrestrial relay network in ns3.
Step 1: Setup ns3 Environment
Ensure that ns3 installed and properly configured.
git clone https://gitlab.com/nsnam/ns-3-dev.git
cd ns-3-dev
./waf configure
./waf build
Step 2: Create the Hybrid Satellite-Terrestrial Relay Network Simulation Script
We will create a script that sets up ground stations, satellites, terrestrial relays, and simulates data transmission between them.
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/point-to-point-module.h”
#include “ns3/applications-module.h”
#include “ns3/mobility-module.h”
#include “ns3/flow-monitor-module.h”
using namespace ns3;
NS_LOG_COMPONENT_DEFINE(“HybridSatelliteTerrestrialRelayNetworkExample”);
int main(int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse(argc, argv);
// Create ground station nodes
NodeContainer groundStationNodes;
groundStationNodes.Create(2); // Two ground stations
// Create satellite nodes
NodeContainer satelliteNodes;
satelliteNodes.Create(1); // One satellite
// Create terrestrial relay nodes
NodeContainer relayNodes;
relayNodes.Create(2); // Two terrestrial relays
// Set up point-to-point links for the ground-to-satellite and satellite-to-relay communication
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“300ms”)); // High delay for satellite communication
NetDeviceContainer devices;
devices = p2p.Install(groundStationNodes.Get(0), satelliteNodes.Get(0));
devices.Add(p2p.Install(satelliteNodes.Get(0), groundStationNodes.Get(1)));
// Set up point-to-point links for relay communication
p2p.SetChannelAttribute(“Delay”, StringValue(“10ms”)); // Lower delay for terrestrial communication
devices.Add(p2p.Install(relayNodes.Get(0), relayNodes.Get(1)));
devices.Add(p2p.Install(groundStationNodes.Get(0), relayNodes.Get(0)));
devices.Add(p2p.Install(relayNodes.Get(1), groundStationNodes.Get(1)));
// Install the internet stack
InternetStackHelper stack;
stack.Install(groundStationNodes);
stack.Install(satelliteNodes);
stack.Install(relayNodes);
// Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign(devices);
// Set up mobility model for the ground stations and relays (fixed)
MobilityHelper mobility;
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobility.Install(groundStationNodes);
mobility.Install(relayNodes);
// Set up mobility model for the satellite (fixed for simplicity)
mobility.Install(satelliteNodes);
Ptr<ConstantPositionMobilityModel> posSatellite = satelliteNodes.Get(0)->GetObject<ConstantPositionMobilityModel>();
posSatellite->SetPosition(Vector(0.0, 0.0, 35786.0)); // Geostationary orbit altitude
// Install applications to generate traffic
uint16_t port = 9;
// Ground station 0 will send data to Ground station 1 via the satellite and relays
OnOffHelperonoff(“ns3::UdpSocketFactory”, Address(InetSocketAddress(interfaces.GetAddress(3), port)));
onoff.SetConstantRate(DataRate(“500Mbps”));
ApplicationContainer apps = onoff.Install(groundStationNodes.Get(0));
apps.Start(Seconds(1.0));
apps.Stop(Seconds(10.0));
// Install packet sink on Ground station 1 to receive packets
PacketSinkHelpersink(“ns3::UdpSocketFactory”, Address(InetSocketAddress(Ipv4Address::GetAny(), port)));
apps = sink.Install(groundStationNodes.Get(1));
apps.Start(Seconds(0.0));
apps.Stop(Seconds(10.0));
// Enable FlowMonitor to measure performance metrics
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
// Run the simulation
Simulator::Stop(Seconds(10.0));
Simulator::Run();
// Print per-flow statistics
monitor->CheckForLostPackets();
Ptr<Ipv4FlowClassifier>classifier = DynamicCast<Ipv4FlowClassifier>(flowmon.GetClassifier());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats();
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin(); i != stats.end(); ++i)
{
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
NS_LOG_UNCOND(“Flow ” << i->first << ” (” << t.sourceAddress << ” -> ” << t.destinationAddress << “)”);
NS_LOG_UNCOND(” Tx Packets: ” << i->second.txPackets);
NS_LOG_UNCOND(” Tx Bytes: ” << i->second.txBytes);
NS_LOG_UNCOND(” Rx Packets: ” << i->second.rxPackets);
NS_LOG_UNCOND(” Rx Bytes: ” << i->second.rxBytes);
NS_LOG_UNCOND(” Lost Packets: ” << i->second.lostPackets);
NS_LOG_UNCOND(” Throughput: ” << i->second.rxBytes * 8.0 / (i->second.timeLastRxPacket.GetSeconds() – i->second.timeFirstTxPacket.GetSeconds()) / 1024 / 1024 << ” Mbps”);
}
// Clean up
Simulator::Destroy();
return 0;
}
Step 3: Compile and Run the Simulation
- Compile the Simulation:
./waf configure –enable-examples
./waf build
Run the Simulation:
./waf –run scratch/hybrid-satellite-terrestrial-relay-network-example
Step 4: Analyze Results
The simulation script sets up a hybrid satellite-terrestrial relay network with ground stations, a satellite, and terrestrial relays, and simulates data transmission between them. FlowMonitor is used to collect and print out statistics about the traffic flows, such as packet loss, throughput, and delay.
Additional Considerations
To extend the functionality of hybrid satellite-terrestrial relay network simulation, consider the following:
1. Advanced Mobility Models
Implement more realistic mobility models to simulate the movement of satellites and devices, including LEO, MEO, and GEO satellites.
2. Dynamic Routing
Integrate dynamic routing protocols to manage the changing topology of the network as satellites and relays move.
3. Fault Tolerance
Implement fault tolerance mechanisms to handle link failures and satellite outages, ensuring continuous communication.
4. Traffic Patterns
Simulate different types of traffic patterns, such as IoT data, VoIP, video streaming, and bulk data transfer, to study their impact on the network.
5. Quality of Service (QoS)
Implement QoS mechanisms to prioritize certain types of traffic and ensure that critical data flows receive the necessary bandwidth and low latency.
6. Performance Metrics
Collect and analyze additional metrics such as jitter, packet delay variation, and error rates to evaluate the network performance more comprehensively.
Finally, we all get to know how to implement Hybrid satellite terrestrial relay network in ns3. Here we had configures the nodes for representing the ground station, satellites, and terrestrial relays and establishing communication links by this we can simulate the network.
Facing challenges while implementing the Hybrid satellite-terrestrial relay network in the ns3 tool after following the steps mentioned above, feel free to reach out to our team for additional assistance. We’re here to share some great project ideas with you!