Академический Документы
Профессиональный Документы
Культура Документы
Networks
Sagnik Bhattacharya
9/12/2001
Overview
• What we need?
• How much effort should we put?
• Some existing network simulators.
• SensorSim.
• NS-2 primer.
• NS-2 issues and conclusion.
-The first 90% of project takes 90% of the time, the last 10% takes
the other 90% of the time.
What we want?
• It should perform simulations of our
algorithms. (obviously)
• It should have models for wireless
transmissions and battery models.
• It should be extremely scalable.
• It should be efficient for large simulations.
• There should be technical support.
ns
app
GUI app
socket serial
comm comm
Physical Layer
Sensor #2 Model
-There are two ways to write error-free programs; only the third
one works.
Power Management Model
BZR event
Off
BZR BZR event
BZR Off event
event
Transmit transmit BZR event Receive
Transmit BZR Receive transmit
event done receive
done
transmit Idle
transmit receive
Idle done timeout receive
transmit
done Sleep timeout(3 sec)
-The definition of an upgrade: Take old bugs out, put new ones in.
NS-2 primer
# define traces
set tracefd [open simple.tr w]
$ns_ trace-all $tracefd
-Computers can figure out all kinds of problems, except the things
in the world that just don't add up.
An Example – Step 5
#Create two ping agents and attach them
to the nodes n0 and n2
set p0 [new Agent/Ping]
$ns attach-agent $n0 $p0
set p1 [new Agent/Ping]
$ns attach-agent $n2 $p1
#Connect the two agents
$ns connect $p0 $p1
-Computer Science is no more about computers than astronomy is
about telescopes.
E. W. Dijkstra
An Example – Step 6
#Schedule events
$ns_ at 100.0 "puts \"hell-O\" "
$ns_ at 10.2 "$p0 send"
$ns_ at 10.4 "$p1 send"
:
:
-Build a system that even a fool can use, and only a fool will use
it.
Ping Protocol
• Check out the handout.
• To add a new protocol :
– Define packet header (PT_PING)
– Define new agent class as a subclass of
Agent in header file (ping.h)
– Implement at least the following functions:
• int command ( int argc, const char*const* argc)
• void recv ( Packet * pkt, Handler* h)
• NS-2 home:
http://www.isi.edu/nsnam/ns