Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Implement Low earth orbit satellite in ns3

To implement Low Earth Orbit (LEO) satellites in ns3, we need to create a simulation environment in which that with the help of realistic orbital mechanics and network communication capabilities model LEO satellites.

If you’re having trouble with the Low Earth Orbit satellite setup in ns3tool after following the steps above, you can reach out to ns3simulation.com for extra assistance. We provide excellent networking comparison analysis and can help you achieve the best simulation results!

The following steps will guide on how to setup a basic simulation of a LEO satellite network in ns3.

Step-by-step guide to implement LEO satellite network in ns3:

Step 1: Setup ns3 Environment

Make sure 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 LEO Satellite Simulation Script

We will create a script that sets up LEO satellites, configures their mobility, and simulates data transmission between them and ground stations.

#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(“LeoSatelliteExample”);

int main(int argc, char *argv[])

{

CommandLine cmd;

cmd.Parse(argc, argv);

// Create satellite nodes

NodeContainer satelliteNodes;

satelliteNodes.Create(3); // Three LEO satellites

// Create ground station nodes

NodeContainer groundStationNodes;

groundStationNodes.Create(1); // One ground station

// Set up point-to-point links representing satellite links

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“20ms”)); // Optical link delay for inter-satellite

NetDeviceContainer satelliteDevices;

satelliteDevices = p2p.Install(satelliteNodes.Get(0), satelliteNodes.Get(1));

satelliteDevices.Add(p2p.Install(satelliteNodes.Get(1), satelliteNodes.Get(2)));

// Set up point-to-point link for ground station to satellite

p2p.SetChannelAttribute(“Delay”, StringValue(“40ms”)); // Higher delay for ground to satellite

NetDeviceContainer groundDevices = p2p.Install(groundStationNodes.Get(0), satelliteNodes.Get(0));

// Install the internet stack

InternetStackHelper stack;

stack.Install(satelliteNodes);

stack.Install(groundStationNodes);

// Assign IP addresses to the satellite links

Ipv4AddressHelper address;

address.SetBase(“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer satelliteInterfaces = address.Assign(satelliteDevices);

address.SetBase(“10.2.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer groundInterfaces = address.Assign(groundDevices);

// Set up mobility model for satellites in LEO

MobilityHelper mobility;

mobility.SetMobilityModel(“ns3::ConstantVelocityMobilityModel”);

mobility.Install(satelliteNodes.Get(0));

Ptr<ConstantVelocityMobilityModel> pos0 = satelliteNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>();

pos0->SetPosition(Vector(0.0, 0.0, 500.0));

pos0->SetVelocity(Vector(0.0, 7.5, 0.0));

mobility.Install(satelliteNodes.Get(1));

Ptr<ConstantVelocityMobilityModel> pos1 = satelliteNodes.Get(1)->GetObject<ConstantVelocityMobilityModel>();

pos1->SetPosition(Vector(1000.0, 0.0, 500.0));

pos1->SetVelocity(Vector(0.0, 7.5, 0.0));

mobility.Install(satelliteNodes.Get(2));

Ptr<ConstantVelocityMobilityModel> pos2 = satelliteNodes.Get(2)->GetObject<ConstantVelocityMobilityModel>();

pos2->SetPosition(Vector(2000.0, 0.0, 500.0));

pos2->SetVelocity(Vector(0.0, 7.5, 0.0));

// Set up mobility for ground station (fixed)

mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

mobility.Install(groundStationNodes.Get(0));

Ptr<ConstantPositionMobilityModel> posGround = groundStationNodes.Get(0)->GetObject<ConstantPositionMobilityModel>();

posGround->SetPosition(Vector(0.0, 0.0, 0.0));

// Install applications to generate traffic

uint16_t port = 9;

// Ground station will send data to Satellite 2

OnOffHelperonoff(“ns3::UdpSocketFactory”, Address(InetSocketAddress(satelliteInterfaces.GetAddress(2), 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 Satellite 2 to receive packets

PacketSinkHelpersink(“ns3::UdpSocketFactory”, Address(InetSocketAddress(Ipv4Address::GetAny(), port)));

apps = sink.Install(satelliteNodes.Get(2));

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

  1. Compile the Simulation:

./waf configure –enable-examples

./waf build

Run the Simulation:

./waf –run scratch/leo-satellite-example

Step 4: Analyze Results

The simulation script sets up a LEO satellite network with ground stations and simulates data transmission. 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 your LEO satellite network simulation, consider the following:

1. Advanced Mobility Models

Implement more realistic mobility models to simulate the actual orbits of LEO satellites, including circular and elliptical trajectories.

2. Dynamic Routing

Integrate dynamic routing protocols to manage the changing topology of a satellite network as satellites 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 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.

On the conclusion we had learnt about the implementation process of Low earth orbit satellite in ns3 which involves creating a simulation environment in that LEO satellites are modelled and using the mobility model the simulation process executed.