Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STAR TOPOLOGY USING TCP
- set ns [new Simulator]
- set nf [open prac1.nam w]
- $ns namtrace-all $nf
- proc finish {} {
- global ns nf
- $ns flush-trace
- close $nf
- exec nam prac1.nam &
- exit 0
- }
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- $ns duplex-link $n0 $n2 10Mb 10ms DropTail
- $ns duplex-link $n1 $n2 10Mb 10ms DropTail
- $ns duplex-link $n2 $n3 10Mb 10ms DropTail
- $ns duplex-link-op $n0 $n2 orient right-down
- $ns duplex-link-op $n1 $n2 orient right-up
- $ns duplex-link-op $n2 $n3 orient right
- set tcp [new Agent/TCP]
- $tcp set class_ 2
- $ns attach-agent $n0 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n3 $sink
- $ns connect $tcp $sink
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ftp set type_ FTP
- $ftp set packet_size_ 1000
- $ftp set rate_ 1mb
- $ns at 1.0 "$ftp start"
- $ns at 2.0 "$ftp stop"
- $ns at 5.0 "finish"
- $ns run
- --------------------------------------------------------------------------------------------------------------------------------------
- THROUGHPUT AND LATENCY
- set ns [new Simulator]
- set nf [open pgm1.nam w]
- $ns namtrace-all $nf
- set nt [open pgm1.tr w]
- $ns trace-all $nt
- proc finish {} {
- global ns nf nt
- $ns flush-trace
- close $nf
- close $nt
- exec nam pgm1.nam &
- exec awk -f throughput.awk pgm1.tr &
- exit 0
- }
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- $ns duplex-link $n0 $n2 10Mb 10ms DropTail
- $ns duplex-link $n1 $n2 5Mb 15ms DropTail
- $ns duplex-link $n2 $n3 15Mb 6ms DropTail
- $ns duplex-link-op $n0 $n2 orient right-down
- $ns duplex-link-op $n1 $n2 orient right-up
- $ns duplex-link-op $n2 $n3 orient right
- set tcp [new Agent/TCP]
- $tcp set class_ 2
- $ns attach-agent $n0 $tcp
- set sink [new Agent/TCPSink]
- $ns attach-agent $n3 $sink
- $ns connect $tcp $sink
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ftp set type_ FTP
- $ftp set packet_size_ 1000
- $ftp set rate_ 1mb
- $ns at 1.0 "$ftp start"
- $ns at 2.0 "$ftp stop"
- $ns at 5.0 "finish"
- $ns run
- Step3:
- Throughput.awk file
- Code:
- BEGIN{
- stime=0
- ftime=0
- flag=0
- fsize=0
- throughput=0
- latency=0
- }
- {
- if($1=="r"&&$4==3)
- fsize+=$6
- if(flag==0)
- {
- stime=$2
- flag=1
- }
- ftime=$2
- }
- END{
- latency=ftime-stime
- throughput=(fsize*8)/latency
- printf("Latency : %f", latency)
- printf("Throughput : %f",throughput)
- }
- --------------------------------------------------------------------------------------------------------------------------------------
- PING
- set val(stop) 10.0;# time of simulation end
- #Create a ns simulator
- set ns [new Simulator]
- #Open the NS trace file
- set tracefile [open out.tr w]
- $ns trace-all $tracefile
- #Open the NAM trace file
- set namfile [open out.nam w]
- $ns namtrace-all $namfile
- #Create 6 nodes
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- set n5 [$ns node]
- $n0 label "ping0"
- $n1 label "ping1"
- $n2 label "R1"
- $n3 label "R2"
- $n4 label "ping4"
- $n5 label "ping5"
- $ns color 1 red
- $ns color 2 blue
- $ns color 3 green
- $ns color 4 orange
- #Createlinks between nodes
- $ns duplex-link $n0 $n2 1Mb 10ms DropTail
- $ns duplex-link $n1 $n2 0.4Mb 10ms DropTail
- $ns duplex-link $n2 $n3 4Kb 10ms DropTail
- $ns duplex-link $n3 $n4 1Mb 10ms DropTail
- $ns duplex-link $n3 $n5 1Mb 10ms DropTail
- #Give node position (for NAM)
- $ns duplex-link-op $n0 $n2 orient right-down
- $ns duplex-link-op $n1 $n2 orient right-up
- $ns duplex-link-op $n2 $n3 orient right
- $ns duplex-link-op $n3 $n4 orient right-up
- $ns duplex-link-op $n3 $n5 orient right-down
- #add manually
- set ping0 [new Agent/Ping]
- $ns attach-agent $n0 $ping0
- set ping1 [new Agent/Ping]
- $ns attach-agent $n1 $ping1
- set ping4 [new Agent/Ping]
- $ns attach-agent $n4 $ping4
- set ping5 [new Agent/Ping]
- $ns attach-agent $n5 $ping5
- $ns connect $ping0 $ping4
- $ns connect $ping1 $ping5
- proc sendPingPacket {} {
- global ns ping0 ping1
- set intervalTime 0.001
- set now [$ns now]
- $ns at [expr $now + $intervalTime] "$ping0 send"
- $ns at [expr $now + $intervalTime] "$ping1 send"
- $ns at [expr $now + $intervalTime] "sendPingPacket"
- }
- #rtt=round trip time(packet travel from src to dest and back to src)
- Agent/Ping instproc recv {from rtt} {
- global seq
- $self instvar node_
- puts "The node [$node_ id] received an ACK from the node $from with RTT $rtt ms"
- }
- $ping0 set class_ 1
- $ping1 set class_ 2
- $ping4 set class_ 3
- $ping5 set class_ 4
- #end
- #Define a 'finish' procedure
- proc finish {} {
- global ns tracefile namfile
- $ns flush-trace
- close $tracefile
- close $namfile
- exec nam out.nam &
- exit 0
- }
- #add manually
- $ns at 0.01 "sendPingPacket"
- $ns at 10.0 "finish"
- $ns run
- ------------------------------------------------------------------------------------------------------------------------------------
- IPSPOOFING
- if config
- nc -lnvp portnumber to open a port
- l-listen
- n- skip DNS lookup
- v- verbose
- p-port number
- Sudo nmap -sS -Pn -D ip address spoofed ipaddress
- -sS stealth scan
- -Pn skip host discovery
- -D decoy scan <ip>
- -------------------------------------------------------------------------------------------------------------------------------------
- DOS ATTACK
- nc lnvp [port-number]
- sudo hping3 -S --flood -V -p 3333 192.168.19.6
- where
- -S: specifies SYN packets.
- • –flood: replies will be ignored and packets will be sent as fast as possible.
- • -V: Verbosity.
- -p <portnumber>: port number
- filter in wireshark
- ip.addr == <ip address of attacking machine> && tcp.flags.syn
- -------------------------------------------------------------------------------------------------------------------------------------
- set val(stop) 10.0;
- set ns [new Simulator]
- set nf [open out.nam w]
- $ns namtrace-all $nf
- set nt [open out.tr w]
- $ns trace-all $nt
- proc finish {} {
- global ns nt nf
- $ns flush-trace
- close $nt
- close $nf
- exec nam out.nam &
- exec awk -f out.awk out.tr &
- exit 0
- }
- set n0 [$ns node]
- set n1 [$ns node]
- set n2 [$ns node]
- set n3 [$ns node]
- set n4 [$ns node]
- set n5 [$ns node]
- $ns duplex-link $n0 $n2 1Mb 10ms DropTail
- $ns duplex-link $n1 $n2 0.4Mb 10ms DropTail
- $ns duplex-link $n2 $n3 4Kb 10ms DropTail
- $ns duplex-link $n3 $n4 1Mb 10ms DropTail
- $ns duplex-link $n3 $n5 1Mb 10ms DropTail
- $ns duplex-link-op $n0 $n2 orient right-down
- $ns duplex-link-op $n1 $n2 orient right-up
- $ns duplex-link-op $n2 $n3 orient right
- $ns duplex-link-op $n3 $n4 orient right-up
- $ns duplex-link-op $n3 $n5 orient right-down
- set ping0 [new Agent/Ping]
- $ns attach-agent $n0 $ping0
- set ping1 [new Agent/Ping]
- $ns attach-agent $n1 $ping1
- set ping4 [new Agent/Ping]
- $ns attach-agent $n4 $ping4
- set ping5 [new Agent/Ping]
- $ns attach-agent $n5 $ping5
- $ns connect $ping0 $ping4
- $ns connect $ping1 $ping5
- proc sendPingPacket {} {
- global ns ping0 ping1
- set intervalTime 0.001
- set now [$ns now]
- $ns at [expr $now + $intervalTime] "$ping0 send"
- $ns at [expr $now + $intervalTime] "$ping1 send"
- $ns at [expr $now + $intervalTime] "sendPingPacket"
- }
- Agent/Ping instproc recv {from rtt} {
- global seq
- $self instvar node_
- puts "The node [$node_ id] received an ACK from the node
- $from with RTT $rtt ms"
- }
- $ns at 0.01 "sendPingPacket"
- $ns at 10.0 "finish"
- $ns run
- throughput.awk
- BEGIN {
- count=0;
- }
- {
- event=$1;
- if(event=="d")
- {
- count++;
- }
- }
- END {
- printf("No of packets dropped : %d\n",count);
- }
- _---++++++-----------------------------------------------
- active queue management (AQM) is the policy of dropping packets inside a buffer before that buffer becomes full, often with the goal of reducing network congestion or improving end-to-end latency. This task is performed by the network scheduler
- An emulator is a tool that replicates the actual hardware and software environment of a network device, allowing the protocol implementation to run on the actual device
- Dummynet is a network emulation tool that allows network engineers to test and
- analyze the behavior of various network protocols and applications in a controlled
- environment.
- simulator is a tool that models the behavior of a protocol implementation and the network environment in which it operates. A simulator can be used to create a virtual network environment with multiple network nodes, each running a protocol implementation, and simulate the interactions between these nodes.
- a test bed is a physical or virtual network environment that is set up to test and evaluate the behavior of a protocol implementation. The purpose of a test bed is to provide an environment in which the protocol implementation can be tested and validated in a variety of real-world network scenarios and conditions.
- SPIN PROTOCOL It transfers all the useful data only from each node to every node in the network assuming that all the nodes in the network are Base Station. SPIN node uses three types of messages for communication.
- 1. ADV- It is used to advertise new data.
- 2. REQ- REQ is used to receive the actual data.
- 3. DATA- DATA is the actual message itself.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement