NS3 Simulator Code

NS3 Simulator Code

Delay Tolerant Network.

Peer to Peer Network

NS3 Tutorial

In this ns3 simulator code we are going to discuss about the delay tolerant and peer-to-peer network concepts with their simulation result.

We will discuss on two important network aspects.

  1. Delay Tolerant Network – NS3 Simulator Code.
  2. Peer to Peer Network – NS3 Simulator Code.

Ns3 Video Tutorial

Ns3 Video Tutorial – Latest NS3 Projects Output

Ns3 Tutorial

Ns3 Tutorial – Guide to Various Network Projects

Journal Support

Paper Publication for NS3 Simulation Projects

Contact Form

Contact Us- Customized Ns3 Simulator Projects

Delay tolerant network:

  • A communications network designed to withstand long delays or outages. It is capable of storing packets in intermediate nodes until such time as an end-to-end route can be established.

 

Characteristics of delay tolerant network:

  • High error rate.
  • Long delay.
  • Asymmetric data rate.
  • Limited resources.
  • Dynamic topology.
  • Low signal to noise ratio.
  • Intermittent connection.

Internal connectivity.

 

 

NS Simulator code

Research scope of delay tolerant network:

  • Congestion control
  • Security
  • Reliability transmission

 

Applications of delay tolerant network:

  • Rural communication
  • Deep space exploration
  • Lake quality monitoring
  • Studies of wild zebra

Sample code for delay tolerant network: NS3 Simulator Code.
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (PropagationDelayModel);
TypeId
PropagationDelayModel::GetTypeId (void)
{
static TypeId tid = TypeId (“ns3::PropagationDelayModel”)
.SetParent().SetGroupName (“Propagation”);return tid;}PropagationDelayModel::~PropagationDelayModel (){}int64_tPropagationDelayModel::AssignStreams (int64_t stream){return DoAssignStreams (stream);}NS_OBJECT_ENSURE_REGISTERED (RandomPropagationDelayModel);TypeIdRandomPropagationDelayModel::GetTypeId (void){static TypeId tid = TypeId (“ns3::RandomPropagationDelayModel”).SetParent ().SetGroupName (“Propagation”).AddConstructor ().AddAttribute (“Variable”,”The random variable which generates random delays (s).”,StringValue (“ns3::UniformRandomVariable”),MakePointerAccessor (&RandomPropagationDelayModel::m_variable),MakePointerChecker ());return tid;}RandomPropagationDelayModel::RandomPropagationDelayModel (){}RandomPropagationDelayModel::~RandomPropagationDelayModel (){}TimeRandomPropagationDelayModel::GetDelay (Ptr a, Ptr b) const{return Seconds (m_variable->GetValue ());}int64_tRandomPropagationDelayModel::DoAssignStreams (int64_t stream){m_variable->SetStream (stream);return 1;}NS_OBJECT_ENSURE_REGISTERED (ConstantSpeedPropagationDelayModel);TypeIdConstantSpeedPropagationDelayModel::GetTypeId (void){static TypeId tid = TypeId (“ns3::ConstantSpeedPropagationDelayModel”).SetParent ().SetGroupName (“Propagation”).AddConstructor ().AddAttribute (“Speed”, “The propagation speed (m/s) in the propagation medium being considered. The default value is the propagation speed of light in the vacuum.”,DoubleValue (299792458),MakeDoubleAccessor (&ConstantSpeedPropagationDelayModel::m_speed),MakeDoubleChecker ());return tid;}ConstantSpeedPropagationDelayModel::ConstantSpeedPropagationDelayModel (){}TimeConstantSpeedPropagationDelayModel::GetDelay (Ptr a, Ptr b) const{double distance = a->GetDistanceFrom (b);double seconds = distance / m_speed;return Seconds (seconds);}voidConstantSpeedPropagationDelayModel::SetSpeed (double speed){m_speed = speed;}doubleConstantSpeedPropagationDelayModel::GetSpeed (void) const{return m_speed;}int64_tConstantSpeedPropagationDelayModel::DoAssignStreams (int64_t stream){return 0;}

 

Peer-to-peer network:

  • Peer to peer is an approach to computer networking where all computers share equivalent responsibility for processing data
  • Files can be shared directly between systems on the network without the need of a central server.

 

Advantages of peer-to-peer network:

  • P2p network is that each time a new node is connected to the network the total capacity of the system increases
  • Pure p2p network is that there is no single point of failure in the network
  • In pure p2p network side if any one of the nodes fails the rest of the nodes are able to continue relaying information
NS Simulator code

Applications of p2p network:

  • Streaming media
  • Instant messaging
  • File sharing
  • Voice over internet protocol

Grid computing is a peer-to-peer application that is gaining massive popularity, which shares processing power over a networking to accomplish some type of goal.

 

Sample Code for Peer to Peer Network : NS3 Simulator Code

NS_LOG_COMPONENT_DEFINE (“p2p”);
p2p::p2p (uint32_t numSpokes,
PointToPointHelper p2pHelper)
{
m_hub.Create (1);
m_spokes.Create (numSpokes);
for (uint32_t i = 0; i < m_spokes.GetN (); ++i)
{
NetDeviceContainer nd = p2pHelper.Install (m_hub.Get (0), m_spokes.Get (i));
m_hubDevices.Add (nd.Get (0));
m_spokeDevices.Add (nd.Get (1));
}
}
p2p::~p2p ()
{
}

Ptr
p2p::GetHub () const
{
return m_hub.Get (0);
}
Ptr
p2p::GetSpokeNode (uint32_t i) const
{
return m_spokes.Get (i);
}
Ipv4Address
p2p::GetHubIpv4Address (uint32_t i) const
{
return m_hubInterfaces.GetAddress (i);
}

Ipv4Address
p2p::GetSpokeIpv4Address (uint32_t i) const
{
return m_spokeInterfaces.GetAddress (i);
}

Ipv6Address
p2p::GetHubIpv6Address (uint32_t i) const
{
return m_hubInterfaces6.GetAddress (i, 1);
}

Ipv6Address
p2p::GetSpokeIpv6Address (uint32_t i) const
{
return m_spokeInterfaces6.GetAddress (i, 1);
}

uint32_t
p2p::SpokeCount () const
{
return m_spokes.GetN ();
}

void
p2p::InstallStack (InternetStackHelper stack)
{
stack.Install (m_hub);
stack.Install (m_spokes);
}

void
p2p::AssignIpv4Addresses (Ipv4AddressHelper address)
{
for (uint32_t i = 0; i < m_spokes.GetN (); ++i)
{
m_hubInterfaces.Add (address.Assign (m_hubDevices.Get (i)));
m_spokeInterfaces.Add (address.Assign (m_spokeDevices.Get (i)));
address.NewNetwork ();
}
}

void
p2p::AssignIpv6Addresses (Ipv6Address addrBase, Ipv6Prefix prefix)
{
Ipv6AddressGenerator::Init (addrBase, prefix);
Ipv6Address v6network;
Ipv6AddressHelper addressHelper;

for (uint32_t i = 0; i < m_spokes.GetN (); ++i)
{
v6network = Ipv6AddressGenerator::GetNetwork (prefix);
addressHelper.SetBase (v6network, prefix);

Ipv6InterfaceContainer ic = addressHelper.Assign (m_hubDevices.Get (i));
m_hubInterfaces6.Add (ic);
ic = addressHelper.Assign (m_spokeDevices.Get (i));
m_spokeInterfaces6.Add (ic);

Ipv6AddressGenerator::NextNetwork (prefix);
}
}