VLAN implementation using NS2
HARDWARE / SOFTWARE REQUIRED:
- Network Simulator-2
- Operating System – LINUX (UBUNTU)
THEORY
VLAN is a custom network that is created from one or more local area networks. It enables a group of devices available in multiple networks to be combined into one logical network. The result becomes a virtual LAN that is administered like a physical LAN. The full form of VLAN is defined as Virtual Local Area Network.
The below topology depicts a network having all hosts inside the same virtual LAN:
Without VLANs, a broadcast sent from a host can easily reach all network devices. Each and every device will process broadcast received frames. It can increase the CPU overhead on each device and reduce the overall network security.
In case if you place interfaces on both switches into separate VLANs, a broadcast from host A can reach only devices available inside the same VLAN. Hosts of VLANs will not even be aware that the communication took place. This is shown in the below picture:
VLAN in networking is a virtual extension of LAN. A LAN is a group of computer and peripheral devices that are connected in a limited area such as a school, laboratory, home, or office building. It is a widely useful network for sharing resources like files, printers, games, and other applications.
Here are step-by-step details of how VLAN works:
- VLANs in networking are identified by a number.
- A Valid range is 1-4094. On a VLAN switch, you assign ports with the proper VLAN number.
- The switch then allows data which needs to be sent between various ports having the same VLAN.
- Since almost all networks are larger than a single switch, there should be a way to send traffic between two switches.
- One simple and easy way to do this is to assign a port on each network switch with a VLAN and run a cable between them.
Difference between LAN and VLAN
LAN | VLAN |
LAN can be defined as a group of computer and peripheral devices that are connected in a limited area. | A VLAN can be defined as a custom network that is created from one or more local area networks. |
The full form of LAN is Local Area Network | The full form of VLAN is Virtual Local Area Network. |
The latency of the LAN is high. | The latency of VLAN is less. |
The cost of LAN is high. | The cost of a VLAN is less. |
In LAN, the network packet is advertised to each and every device. | In VLAN, the network packet is sent to only a specific broadcast domain. |
It uses a ring, and FDDI (Fiber Distributed Data Interface) is a protocol. | It uses ISP and VTP as a protocol. |
MULTIPLE VLANS AND SINGLE ROUTER
If you have a router that supports virtual LANs (VLANs), you can create multiple VLANs from that single router. This can be useful if you want to segment your network traffic for security or performance reasons.
A VLAN is a logical grouping of devices on a network. VLANs are used to segment a network into smaller, more manageable pieces. VLANs are created by configuring a router or switch to divide a physical network into multiple logical networks.
Creating a VLAN is a two-step process. First, you must create the VLAN itself. This is done by configuring a router or switch to create a new logical network. Second, you must add devices to the VLAN. This is done by configuring the router or switch to add devices to the VLAN.
Adding devices to a VLAN is a simple process. First, you must determine which devices you want to add to the VLAN. Second, you must configure the router or switch to add those devices to the VLAN.
Switches generate a VLAN as a broadcast domain. You, the administrator, set up some switch ports in a different VLAN than the default VLAN for the sake of convenience. VLANs are enabled in Cisco switches by default, and ALL devices are already connected to VLAN 1. If there were no additional configuration required, these devices would be unable to communicate. All devices on a switch can communicate with one another using the same ports as a single switch. Consider using VLANs if you’re having difficulty connecting to the Internet. A trunk port is shared by multiple switches or routers and is used to route traffic between them.
VLANs can be configured in a variety of Cisco switches, even if they are in different models. To communicate with other trunks, a trunk port must use a special trunk trunk protocol. Because VLANs limit the number of broadcasts, they provide a higher level of performance to large and medium LANs. As a result, they also provide security because you effectively have one group of devices connected to a VLAN.
MULTIPLE VLANS WITH SEPARATE MULTIPLE ROUTERS
It is possible to use multi-VLAN ports to conduct networking. These switches and routers can be used to separate groups of users, departments, and functions from one another without the need for separate switches or routers. There is a significant cost savings, improved network security and performance, and simplified management associated with this model.
PROCEDURE
- Create a simulator object
- Open a nam trace file and define the finish procedure then close the trace file, and execute nam on the trace file.
- Create VLANs with router(s) that form a logical network
- Create duplex links between the VLANs
- Schedule events and run the program.
Scheduling Events
NS is a discrete event-based simulation. The TCL script defines when the event should
occur. The initializing command set ns [new Simulator] creates an event scheduler, and events are then scheduled using the format:
The simulation can then begin using the command
$ns run
PROGRAM
set opt(tr) "vlandemo.tr"
set opt(namtr) "vlandemo.nam"
set opt(seed) 0
set opt(stop) 1.0
set opt(node) 4
set opt(qsize) 100
set opt(bw) 10Mb
set opt(delay) 1ms
set opt(ll) LL
set opt(ifq) Queue/DropTail
set opt(mac) Mac/Csma/Cd
#set opt(mac) Mac/Csma/Ca
#set opt(mac) Mac/802_3
set opt(chan) Channel
set opt(tcp) TCP/Newreno
set opt(sink) TCPSink
set opt(app) FTP
proc finish {} {
global ns opt
$ns flush-trace
# exec nam $opt(namtr) &
exit 0
}
proc create-trace {} {
global ns opt
if [file exists $opt(tr)] {
catch "exec rm -f $opt(tr) $opt(tr)-bw [glob $opt(tr).*]"
}
settrfd [open $opt(tr) w]
$ns trace-all $trfd
if {$opt(namtr) != ""} {
$ns namtrace-all [open $opt(namtr) w]
}
return $trfd
}
proc create-topology {} {
global ns opt
global lan node source node0 nodex
set num $opt(node)
for {set i 0} {$i< $num} {incri} {
set node($i) [$ns node]
lappendnodelist $node($i)
}
set lan [$ns make-lan $nodelist $opt(bw) \
$opt(delay) $opt(ll) $opt(ifq) $opt(mac) $opt(chan)]
set node0 [$ns node]
$ns duplex-link $node0 $node(1) 20Mb 2ms DropTail
# $ns duplex-link-op $node0 $node(1) orient right
set nodex [$ns node]
$ns duplex-link $nodex $node(2) 20Mb 2ms DropTail
# $ns duplex-link-op $nodex $node(2) orient left
}
## MAIN ##
set ns [new Simulator]
settrfd [create-trace]
# create-topology
set tcp0 [$ns create-connection TCP/Newreno $node0 TCPSink $nodex 0]
$tcp0 set window_ 15
set ftp0 [$tcp0 attach-app FTP]
#set udp0 [new Agent/UDP]
#$ns attach-agent $node0 $udp0
#set cbr0 [new Application/Traffic/CBR]
#$cbr0 attach-agent $udp0
#set rcvr0 [new Agent/Null]
#$ns attach-agent $nodex $rcvr0
#$udp0 set dst_ [$rcvr0 set addr_]
$ns at 0.0 "$ftp0 start"
#$ns at 0.0 "$cbr0 start"
$ns at $opt(stop) "finish"
$ns run
# to run the example, use the following line
$ ns filename.tcl
$ nam vlandemo.nam
OUTPUT
VLAN Demo |
Sir, can you please explain about the implementation of wireless sensor network in ns3
ReplyDeleteSir please share aodv and dsdv CSV files
ReplyDelete