Академический Документы
Профессиональный Документы
Культура Документы
Alefiya Hussain
What is Emulation ?
Ability
Requirements:
Scheduler support
Packet capture and generation
capabilities
ns Tutorial 2002
Scheduler
ns
ns Tutorial 2002
Emulation Objects
Interface
between ns
and network traffic
Network Objects
Access to live network via
BPF and raw sockets
Tap
Capture: BPF
network to ns
ns
Objects
Conversion between ns
and
network packet formats
ns Tutorial 2002
ns to network
Inject: Raw socket
Modes of Operation
Packet
Opaque
Mode
Mode
ns Tutorial 2002
Opaque Mode
Network
packet is passed
unmodified through simulator
Extern
Source
Destination
Size
Ns packet
contains a
pointer to the
network packet
Source
Destination
Size
Data
ns
Read packets
Network
Packet
ns Tutorial 2002
Write
packets
Network
Protocol Mode
Network
Source
Destination
Size
The ns packet
header is
mapped onto
the network
packet header
and visa
versa .
Source
Destination
Size
Host A
Host B
TCP Agent
TCP
Application
Data
Network
Packet
ns Tutorial 2002
ns
Send/receiv
e packets
from
application
Send/receiv
e packets
from ns
Network
7
Applications
Opaque
Mode
Protocol
Mode
ns Tutorial 2002
Example: Setup
Goal: Make a ns TCP agent interact with a TCP server
B 192.168.1.2 port
A 192.168.1.1
8000
ns
e
TCP server
Disable IP forwarding
sysctl w net.inet.ip.forwarding=0
ns Tutorial 2002
Switch
Disable IP redirects
sysctl w net.inet.ip.redirect=0
Example Script
Activate ns and
Change to real-time
scheduler
TCP Agent
tcp_node
ns Tutorial 2002
Create topology
BPF
entry_node
TCPTap RawSocket
10
Example Script
set bpf [new Network/Pcap/Live]
TCP Agent
set dev [$bpf open readonly eth0]
$bpf filter "src 192.168.1.2 and src port 8000 \ tcp_node
and dst 10.0.0.1 and dst port 6000
set capture_tap [new Agent/TCPTap]
$capture_tap network $bpf
$ns attach-agent $entry_node $capture_tap
$ns simplex-connect $capture_tap $tcp
Example Script
$ns at 0.01 "$tcp advance 1"
$ns at 20.0 exit 0"
$ns run
start nse
192.168.1.1
TCP Agent
192.168.1.2
TCP Server
(8000)
BPF
Raw Socket
ns Tutorial 2002
Switch
12
Further Information
http://www.isi.edu/nsnam/ns/ns-emulation.html
Scripts
~ns/emulate
Opaque Mode:
em.tcl
Protocol Mode
thrutcp.tcl
pingdemo.tcl
tcpemu.tcl
ns Tutorial 2002
13