Hi,

I think there is bug with the Ping Agent. If we simulate Ping Agent with
only 3 nodes, it works fine but if we increase the number of nodes to more
than 3, there are packets lost. I am able to provide a fix and described
below. Please let me know if it helped you out.

In the recv() function in ping.cc, declare the following two variables in
the first two lines.
nsaddr_t source;
nsaddr_t destination;

Then after hdrip is assigned values (hdr_ip* hdrip = hdr_ip::access(pkt);),
add the following two lines.
source = hdrip->src_.addr_;
destination = hdrip->dst_.addr;

Now go to the part of the routine where the following statement is declared:
if (hdr->ret == 2)
Under this part of the "if" statement, after the statement: hdr_ping* hdrret
= hdr_ping::access(pktret);
add the following lines of code:
hdrip = hdr_ip::access(pktret);
hdrip->src_.addr_ = destination;
hdrip->dst_.addr_ = source;

After adding all these lines, build it again and then simulate. Hope it
fixes the problem. Let me know in any case.

Thanks,
- Faisal Siddiqui

On 4/18/06, Neil Diaz <[EMAIL PROTECTED]> wrote:
>
>
> 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
> [EMAIL PROTECTED]
> 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.
>

Reply via email to