-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMITM.tcl
60 lines (60 loc) · 1.38 KB
/
MITM.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#create network simulator
set ns [new Simulator]
#create trace file
set tf [open lanout.tr w]
$ns trace-all $tf
#create nam file
set nf [open namfile1.nam w]
$ns namtrace-all $nf
#create 4 nodes give color red
set n0 [$ns node]
$n0 color "green"
set n1 [$ns node]
$n1 color "green"
set n2 [$ns node]
$n2 color "green"
#create node and give color blue
set n3 [$ns node]
$n3 color "blue"
set n4 [$ns node]
$n4 color "blue"
set n5 [$ns node]
$n5 color "blue"
#create attacker nod
set n6 [$ns node]
$n6 color "red"
#creation of LAN
$ns make-lan "$n0 $n1 $n2" 100Mb 30ms LL Queue/DropTail Mac/802_3
$ns make-lan "$n3 $n4 $n5" 100Mb 30ms LL Queue/DropTail Mac/802_3
#create a duplex link between 3 and 4
$ns duplex-link $n2 $n6 10Mb 1ms DropTail
$ns duplex-link $n6 $n5 10Mb 1ms DropTail
#set error rate
set err [new Error Model]
$ns loss model $err $n6 $n5
$err set rate_ 0.2
#create udp agent
set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
#create null agent
set null [new Agent/Null]
$ns attach-agent $n3 $null
#create virtual connection
$ns connect $udp $null
#create application
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
#start the traffic
$ns at 0.5 "$cbr start"
$ns at 5.5 "finish"
#finish procedure
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam namfile1.nam &
exec gedit lanout.tr &
exit 0
}
$ns run