[ns] Ping over LAN missed packets
Neil Diaz
neil_or at yahoo.com
Tue Apr 18 10:04:42 PDT 2006
Hi all,
I have been doing simulations on ns2 in the past weeks, and I have some questions to our experimented community. I would appreciate your help.
1. I have this scenario:
* A Local Area Netwotk with 4 nodes.
* There is a Ping Agent on node 0, sending ping packets to node 2.
* I sent 100 ping packets (echo request) to node 2; on node 2 only 97 ping packets are received.
* Because the latter, only 97 echo reply are received on node 0.
As you can note, there are 3 ping packets missed, and the simulator does not reflect that.
Packets 29, 66 and 68 are never received on node 2.
This is my ns2 script. It is commented in Spanish. I send ping packets following an exponential distribution.
///////// BEGIN ////////////////
#-------------------------------------------------------------------#
# CONFIGURACION RED DE PRUEBAS #
# Realizado por: Neil Diaz Martinez #
# Abril de 2006 #
#-------------------------------------------------------------------#
#-------------------------------------------------------------------#
# 1. CONFIGURACION GENERAL #
#-------------------------------------------------------------------#
#Crear un nuevo objeto simulador.
set ns [new Simulator]
#Abrir una traza grafica para NAM.
set nf [open lan.nam w]
$ns namtrace-all $nf
#Abrir un archivo de trazas en texto.
set tf [open lan.tr w]
$ns trace-all $tf
#Definir el procedimeinto "finish".
proc finish {} {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam lan.nam &
exit 0
}
#Definir una función "recv" para la clase "Agent/Ping".
Agent/Ping instproc recv {from sendtime recvtime rtt} {
$self instvar node_
puts "[$node_ id] $from $sendtime $recvtime $rtt"
}
#-------------------------------------------------------------------#
#-------------------------------------------------------------------#
# 2. CONFIGURACION DE LA TOPOLOGIA DE RED #
#-------------------------------------------------------------------#
#Crear nodos.
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Conectar los cuatro nodos a una LAN.
$ns make-lan "$n0 $n1 $n2 $n3" 100Mb 1ms LL Queue/DropTail Mac/802_3
#-------------------------------------------------------------------#
#-------------------------------------------------------------------#
# 3. ASIGNACION DE LOS AGENTES GENERADORES DE PING #
#-------------------------------------------------------------------#
#Crear dos agentes "Agent/Ping" y asignarlos a los nodos n0 y n2.
set p0 [new Agent/Ping]
$ns attach-agent $n0 $p0
set p1 [new Agent/Ping]
$ns attach-agent $n2 $p1
#Conectar los dos agentes "Agent/Ping".
$ns connect $p0 $p1
#-------------------------------------------------------------------#
#-------------------------------------------------------------------#
# 4. GENERACION DE LOS EVENTOS PING #
#-------------------------------------------------------------------#
#Generar los eventos.
set t_ping 0
set n_pings 100
for {set i 1} {$i <= $n_pings} {incr i} {
$ns at $t_ping "$p0 send"
# Esta media genera en promedio una tasa de 10Mbps.
set exp [exponential 51.2e-6]
set t_ping [expr $exp + $t_ping]
}
#puts $t_ping
$ns at [expr $t_ping+1000] "finish"
#-------------------------------------------------------------------#
#-------------------------------------------------------------------#
# 5. EJECUCION DEL SCRIPT #
#-------------------------------------------------------------------#
#Ejecutar la simulacion.
$ns run
///////// END ////////////////
Thanks a lot for your cooperation,
Neil
Neil Díaz Martínez
neildiazmartinez at hotmail.com
Tel: 2887126 - 3008030379
Bogotá D.C., Colombia
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.
More information about the Ns-users
mailing list