How to Start Wireless Attacks Projects Using NS3

To Simulate the wireless attacks in NS-3 has includes the configuration a wireless network environment in which attackers attempt to exploit the vulnerabilities in wireless communication medium. Wireless attacks can be target confidentiality, integrity, or availability, like as jamming, eavesdropping, replay attacks, and extra.

Here’s a step-by-step guide to starting a wireless attack project in NS-3:

Steps to Start Wireless Attacks Projects Using NS3

  1. Set Up NS-3
  • Install and build NS-3:

./waf configure

./waf build

  • Test the installation:

./waf –run hello-simulator

  1. Understand Wireless Attacks
  • Common Wireless Attacks:
    • Eavesdropping: Interrupting the wireless signals we extract the important data.
    • Jamming: Transmitting the noise to interrupt their communication.
    • Replay Attack: Rerunning the earlier captured packets.
    • Man-in-the-Middle (MITM): Interrupting and altering their communication among devices.
    • Deauthentication Attack: we disconnect from the network for forcing the devices.
  1. Define the Wireless Network Topology
  • Build a wireless network by:
    • Access Point (AP): The central device for wireless communication.
    • Wireless Clients: AP communicating through the devices.
    • Attacker Node: targeting the network for malicious node.
  • Sample Topology:

NodeContainer wifiApNode, wifiStaNodes, attackerNode;

wifiApNode.Create(1);      // Access Point

wifiStaNodes.Create(2);    // Two legitimate clients

attackerNode.Create(1);    // One attacker

YansWifiChannelHelper channel = YansWifiChannelHelper::Default();

YansWifiPhyHelper phy = YansWifiPhyHelper::Default();

phy.SetChannel(channel.Create());

WifiHelper wifi;

wifi.SetStandard(WIFI_PHY_STANDARD_80211g);

WifiMacHelper mac;

Ssid ssid = Ssid(“ns3-wifi”);

// Configure AP

mac.SetType(“ns3::ApWifiMac”, “Ssid”, SsidValue(ssid));

NetDeviceContainer apDevice = wifi.Install(phy, mac, wifiApNode);

// Configure STA nodes

mac.SetType(“ns3::StaWifiMac”, “Ssid”, SsidValue(ssid));

NetDeviceContainer staDevices = wifi.Install(phy, mac, wifiStaNodes);

// Configure attacker node

NetDeviceContainer attackerDevice = wifi.Install(phy, mac, attackerNode);

// Install Internet stack

InternetStackHelper stack;

stack.Install(wifiApNode);

stack.Install(wifiStaNodes);

stack.Install(attackerNode);

// Assign IP addresses

Ipv4AddressHelper address;

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

address.Assign(apDevice);

address.Assign(staDevices);

address.Assign(attackerDevice);

  1. Simulate Normal Traffic
  • Enhance the legitimate traffic among the clients and the AP.
  • Sample: UDP Echo Traffic

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApp = echoServer.Install(wifiApNode.Get(0));

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(Ipv4Address(“192.168.1.1”), 9);

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

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

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

ApplicationContainer clientApps = echoClient.Install(wifiStaNodes);

clientApps.Start(Seconds(2.0));

clientApps.Stop(Seconds(10.0));

  1. Implement the Wireless Attack

5.1 Jamming Attack

  • Replicate a jamming attack through continuously transmitting noise.

void JammingAttack(Ptr<Node> attacker) {

Ptr<NetDevice> device = attacker->GetDevice(0);

Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice>(device);

Ptr<WifiPhy> phy = wifiDevice->GetPhy();

phy->SendNoiseBurst(Simulator::Now(), Seconds(10.0), 1e6);  // 10 seconds, 1 MHz power

}

Simulator::Schedule(Seconds(3.0), &JammingAttack, attackerNode.Get(0));

5.2 Eavesdropping

  • Seizure their packets established through the attacker node.

void PacketSniffer(Ptr<const Packet> packet) {

NS_LOG_UNCOND(“Captured Packet: ” << *packet);

}

attackerDevice.Get(0)->TraceConnectWithoutContext(“PhyRxEnd”, MakeCallback(&PacketSniffer));

5.3 Replay Attack

  • Rerun the seized packets from the attacker to the AP.

void ReplayAttack(Ptr<Node> attacker, Ptr<Packet> capturedPacket) {

Ptr<Socket> socket = Socket::CreateSocket(attacker, TypeId::LookupByName(“ns3::UdpSocketFactory”));

InetSocketAddress apAddress = InetSocketAddress(Ipv4Address(“192.168.1.1”), 9);

socket->Connect(apAddress);

socket->Send(capturedPacket);

}

5.4 Deauthentication Attack

  • Send deauthentication frames to disconnect clients.

void DeauthenticationAttack(Ptr<Node> attacker, Mac48Address victimMac) {

Ptr<NetDevice> device = attacker->GetDevice(0);

Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice>(device);

wifiDevice->GetMac()->SendDeauthFrame(victimMac, WifiMacHeader::ReasonCode::CLASS3_FRAME_RECEIVED_FROM_NONASSOCIATED_STA);

}

  1. Enable Packet Capturing
  • Utilizing their PCAP we seizure their traffic for analysis with Wireshark.

phy.EnablePcap(“wireless-attack”, attackerDevice);

  1. Run the Simulation
  • We build and execute the simulation:

./waf –run wireless-attack

  • Analyze the generated .pcap file.
  1. Analyze Captured Packets
  • Open the .pcap file in Wireshark:

wireshark wireless-attack-0-0.pcap

  • Used this filter we effect the particular congestion:
    • UDP Packets: udp
    • Deauthentication Frames: wlan.fc.type_subtype == 12
  1. Optional: Implement Countermeasures
  • Enhance the security measures we implement the attacks:
    • Encryption: The secure the wireless traffic utilizing their WPA2.
    • Signal Strength Monitoring: We detect the abnormal noise levels such as jamming.
    • Authentication: Validate the device characteristics we avoid spoofing.
  1. Evaluate Metrics
  • Estimate the effect of the attack:
    • Throughput: Checked for degradation.
    • Packet Loss: Amount of increased packet drops.
    • Latency: Estimate the delays caused by the attack.
  • Utilized their FlowMonitor:

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll();

  1. Example Scenarios
  • Replicate and associate the effects of different wireless attacks.
  • Estimate the effectiveness of mitigation techniques such as encode, intrusion detection.

This setup provides a foundation for simulating wireless attacks in NS-3. Let me know if you need further assistance!

We provide  complete procedures to simulate the wireless attacks project which were simulated and analyse the outcomes using the tool of NS3. Additional information with certain details on these wireless attacks will be provided in upcoming manual. Drop us a message we will guide you with best simulation results.