-
Notifications
You must be signed in to change notification settings - Fork 1
/
wifi-adhoc.py
58 lines (38 loc) · 1.08 KB
/
wifi-adhoc.py
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
import rlcompleter
import readline
import time
from mininet.net import Mininet
from mininet.node import Node, Switch
from mininet.link import Link, Intf
from mininet.log import setLogLevel, info
from mininet.cli import CLI
import mininet.ns3
from mininet.ns3 import WIFISegment
readline.parse_and_bind("tab: complete")
if __name__ == '__main__':
setLogLevel( 'info' )
info( '*** ns-3 network demo\n' )
net = Mininet()
info( '*** Creating Network\n' )
h0 = Node( 'h0' )
h1 = Node( 'h1' )
h2 = Node( 'h2' )
net.hosts.append( h0 )
net.hosts.append( h1 )
net.hosts.append( h2 )
wifi = WIFISegment()
wifi.add( h0 )
wifi.add( h1 )
wifi.add( h2 )
info( '*** Configuring hosts\n' )
h0.setIP( '192.168.123.1/24' )
h1.setIP( '192.168.123.2/24')
h2.setIP( '192.168.123.3/24')
mininet.ns3.start()
info( '*** Network state:\n' )
for node in h0, h1, h2:
info( str( node ) + '\n' )
info( '*** Running test\n' )
h0.cmdPrint( 'ping -c1 ' + h1.IP() )
h0.cmdPrint( 'ping -c1 ' + h2.IP() )
CLI(net)