How to Start VLAN Trunking Protocol Projects Using NS2

To start a VLAN Trunking Protocol (VTP) project in Network Simulator 2 (NS2) is doesn’t directly VLANs or VTP support but we will want to replicate their behavior or execute a custom module. Following is a step-by-step procedure to get started.

Steps to Start VLAN Trucking Protocol Projects in NS2

Step 1: Understand VLAN Trunking Protocol (VTP)

  1. What is VTP?
    • VTP is a Layer 2 protocol which is often utilised in VLAN environments for handling and coordinating VLAN data through switches.
    • Key Modules:
      • Server Mode: It supports to make and handle the VLANs.
      • Client Mode: Inherits VLAN modernizes from the servers.
      • Transparent Mode: It sends VTP update however does not utilise them.
  2. Why Use VTP?
    • Minimising administrative overhead including several switches in large networks.
    • To make sure that consistent VLAN set up over the network.
  3. VTP Features:
    • VTP domains set switches.
    • VTP advertisements broadcast the VLAN data.
    • Set up revision volumes of track modifications.

Step 2: Set Up NS2 Environment

  1. Install NS2:
    • We can download and install the new version of NS2 on the system.
    • Confirm installation by running:

ns -version

  1. Understand NS2 Basics:
    • Study the basic Tcl script to make nodes, links, and traffic within NS2.

Step 3: Design Network Topology

  1. Simulate VLAN Trunking:
    • Make switches (nodes) and specify the trunk links among them.

set ns [new Simulator]

# Create nodes (representing switches)

set sw1 [$ns node]

set sw2 [$ns node]

set sw3 [$ns node]

# Define links

$ns duplex-link $sw1 $sw2 100Mb 5ms DropTail

$ns duplex-link $sw2 $sw3 100Mb 5ms DropTail

$ns duplex-link $sw1 $sw3 100Mb 10ms DropTail

  1. Simulate VLAN Traffic:
    • Allocate the VLAN IDs to packets for replicating VLAN segmentation.
    • Make use of tags like 802.1Q to detect the VLAN traffic.

Step 4: Implement VTP Logic

In NS2, VTP doesn’t support by default however we will want to replicate their behavior.

Option 1: Tcl-Based Simulation

  1. Simulate VLAN Configuration:
    • Describe VLAN IDs and connect them including switches.

set vlanTable(sw1) {10 20 30}

set vlanTable(sw2) {10 20}

set vlanTable(sw3) {30}

  1. Simulate VTP Advertisements:
    • Make a procedure transmitting VLAN data from the server to clients.

proc sendVTPUpdate {server clients vlanInfo} {

foreach client $clients {

puts “Sending VTP update from $server to $client: $vlanInfo”

# Simulate VLAN update propagation

}

}

  1. Trigger Updates:
    • Broadcast VLAN modifications whenever there is a set up update.

set vtpServer sw1

set clients {sw2 sw3}

set newVLAN {40}

sendVTPUpdate $vtpServer $clients $newVLAN

Option 2: Custom VTP Module in C++

  1. Extend the Agent Class:
    • Extend the custom agent to execute VTP logic.
    • Sustain revision numbers and VLAN tables.

Example:

class VTPAgent : public Agent {

public:

VTPAgent();

void recv(Packet* p, Handler* h);

void sendVTPAdvertisement();

private:

std::map<int, std::vector<int>> vlanTable; // Switch -> VLANs

int revisionNumber;

};

  1. Implement Core Functions:
    • VTP Advertisements: Propagate the VLAN data to clients.
    • Configuration Updates: According to the advertisements, modernize VLAN tables.
  2. Compile and Link:
    • Integrate the custom VTP agent to Makefile of NS2.
    • Recompile NS2:

make clean && make

Step 5: Add Traffic Sources

  1. Define VLAN-Aware Traffic:
    • Connect the traffic agents for replicating VLAN-tagged packets.

set udp1 [new Agent/UDP]

$ns attach-agent $sw1 $udp1

set sink1 [new Agent/Null]

$ns attach-agent $sw3 $sink1

$ns connect $udp1 $sink1

# Add VLAN tag to traffic

$udp1 set VLAN_ 10

  1. Monitor VLAN Segmentation:
    • Make sure that packets are distributed only in the similar VLAN.

Step 6: Simulate and Analyze

  1. Run the Simulation:
    • We need to save the script like vtp_simulation.tcl and then run the simulation:

ns vtp_simulation.tcl

  1. Visualize in NAM:
  • Envision VTP advertisements and VLAN-specific traffic to utilise NAM (Network Animator):

nam vtp_simulation.nam

  1. Analyze Trace File:
    • Estimate:
      • Latency and packet delivery ratio.
      • VLAN traffic segmentation.
      • VTP advertisement propagation.

Step 7: Enhance the Project

  1. Dynamic Updates:
    • Replicate the VLAN addition or erasure and also monitor the synchronization of VTP.

set newVLAN {50}

sendVTPUpdate $vtpServer $clients $newVLAN

  1. VTP Modes:
    • We want to execute the VTP modes like server, client, and transparent modes.
    • Permit transparent switches to send however it does not utilise updates.
  2. Performance Metrics:
    • For VLAN updates, we estimate the convergence time.
    • Experiment scalability including a large volume of switches and VLANs.
  3. Compare with Other Mechanisms:
    • Measure the VTP versus VLAN set up manually like overhead and consistency.

Example Script Outline

Below is a simple script to replicate the VLAN Trunking and VTP using NS2:

set ns [new Simulator]

# Nodes

set sw1 [$ns node]

set sw2 [$ns node]

set sw3 [$ns node]

# Links

$ns duplex-link $sw1 $sw2 100Mb 5ms DropTail

$ns duplex-link $sw2 $sw3 100Mb 5ms DropTail

$ns duplex-link $sw1 $sw3 100Mb 10ms DropTail

# VLAN Tables

set vlanTable(sw1) {10 20}

set vlanTable(sw2) {10 30}

set vlanTable(sw3) {20 30}

# Traffic

set udp1 [new Agent/UDP]

$ns attach-agent $sw1 $udp1

set sink1 [new Agent/Null]

$ns attach-agent $sw3 $sink1

$ns connect $udp1 $sink1

$udp1 set VLAN_ 10

# Run simulation

$ns at 1.0 “$udp1 start”

$ns at 5.0 “finish”

$ns run

We had illustrated the procedures, which will help you to simulate and analyse the VLAN Trunking Protocol Projects using NS2 simulation environment. Further required details will be updated later.