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

How to Implement network probe attack in ns3

To implement network probe attack in ns3, we need to simulate a node that sends probe requests to other nodes in the network for discovering available hosts and services. ns3simulation.com  provide more related comparative analysis and detailed information on network probe attack based on your project.

Here is the complete guide to implement network probe attack in ns3.

Steps for implementation

  1. Set up your ns3 :
  • Make sure that ns3 is installed in the computer. If not, install it.
  1. Create a new ns3 script :
  • In the scratch directory of ns3, create a new script.
  1. Include necessary libraries :
  • In your script, include the necessary libraries.
  1. Define network topology :
  • For your network topology, create multiple nodes and one attacker node.
  1. Implement the Network probe logic :
  • To the probe requests (e.g., ICMP Echo Request or TCP SYN), use raw sockets or existing applications from the attacker node.
  1. Enable packet capturing :
  • Enable pcap tracing to capture packets for analysis with Wireshark.
  1. Run the Simulation :
  • Define the simulation parameters and run it.

Example for implementing Network probe attack

Here is the example for the implementation of Network probe :

#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/ipv4-raw-socket-factory.h”

#include “ns3/ipv4-header.h”

#include “ns3/icmpv4-header.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“NetworkProbeAttack”);

void SendProbe (Ptr<Node> probeNode, Ipv4Address destination)

{

Ptr<Socket> socket = Socket::CreateSocket (probeNode, Ipv4RawSocketFactory::GetTypeId ());

socket->SetAttribute (“Protocol”, UintegerValue (1)); // ICMP protocol number

Ptr<Packet> packet = Create<Packet> (100); // Create a packet of 100 bytes

// Create and add ICMP header

Icmpv4Echo echo;

echo.SetSequenceNumber (1);

echo.SetIdentifier (1);

packet->AddHeader (echo);

// Create and add IP header

Ipv4Header ipHeader;

ipHeader.SetDestination (destination);

ipHeader.SetProtocol (1); // ICMP

ipHeader.SetPayloadSize (100);

packet->AddHeader (ipHeader);

socket->Send (packet);

}

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

{

// Set up logging

LogComponentEnable (“NetworkProbeAttack”, LOG_LEVEL_INFO);

// Create nodes

NodeContainer nodes;

nodes.Create (4); // Three legitimate nodes and one attacker node

// Create point-to-point links

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));

pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

NetDeviceContainer devices;

for (uint32_t i = 0; i < nodes.GetN () – 1; ++i)

{

devices.Add (pointToPoint.Install (nodes.Get (i), nodes.Get (i + 1)));

}

// Install the internet stack

InternetStackHelper stack;

stack.Install (nodes);

// Assign IP addresses

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer interfaces = address.Assign (devices);

// Install applications on legitimate nodes

uint16_t port = 9; // Discard port (RFC 863)

// Server application

UdpEchoServerHelper echoServer (port);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// Client application

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), port);

echoClient.SetAttribute (“MaxPackets”, UintegerValue (100));

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (0.1)));

echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Enable packet capture

pointToPoint.EnablePcapAll (“network_probe_attack”);

// Schedule network probe attack

for (uint32_t i = 1; i < nodes.GetN (); ++i)

{

Simulator::Schedule (Seconds (i), &SendProbe, nodes.Get (3), interfaces.GetAddress (i));

}

// Run simulation

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation

  1. Nodes and links :

Four nodes are created : three for legitimate communication and one for attacker. Point-to-point links between nodes are configured.

  1. Applications :

On one of the legitimate node, a UDP echo server is installed. and On another legitimate node, a UDP echo server is installed to generate traffic.

  1. Network probe attack logic :

To create and send ICMP Echo Request packets using raw sockets,  SendProbe is implemented. To send ICMP packets to each node, we scheduled the network probe attack.

  1. Packet Capture :

To capture the traffic for analysis with Wireshark, pcap tracing on all nodes is enabled.

  1. Running the Simulation :

The simulation runs with attacker node sending packets with a spoofed source address to the victim node, and the traffic is captured in pcap files.

Overall, we had successfully implemented network probe attack in ns3 by simulating a node that sends probe requests to other nodes in the network to discover available hosts and services. Enquire us for best results on Network Probe Attack with programming ideas.