Re: [NAB] question

Henri DF <[email protected]> Tue, 27 Apr 2004 13:47:46 +0200 (CEST)
Newsgroups gmane.network.simulator.epfl
Message-ID <[email protected]>
Hello, 

> Hello.
> My name is Jin B. Kim, who is studyng ad hoc network at USC.
> I'm testing EASE algoritm using NAB. But I have some question...
> 
> 
> 1. In lesson 3 (http://nab.epfl.ch/lesson3.html)
> 
> -------------------------------------------------------------------------  
>  # let grease_cost = ref 0.0 and ease_cost = ref 0.0 and fresh_cost = ref 0.0;;
> val grease_cost : float ref = {contents = 0.}
> val ease_cost : float ref = {contents = 0.}
> val fresh_cost : float ref = {contents = 0.}
> 
> # let route_cost_hook tot_cost l2pkt node =      
>   let l3pkt = L2pkt.l3pkt l2pkt in               
>   let ler_hdr =  L3pkt.ler_hdr l3pkt in        
>   tot_cost := !tot_cost +. ((Ler_pkt.search_dist ler_hdr) ** 2.0);;
> val route_cost_hook : float ref -> L2pkt.t -> 'a -> unit = 
> 
> # Nodes.gpsiter (fun n -> n#add_pktout_mhook ~stack:0 (route_cost_hook grease_cost));;
> - : unit = ()
> # Nodes.gpsiter (fun n -> n#add_pktout_mhook ~stack:1 (route_cost_hook ease_cost));;
> - : unit = ()
> # Nodes.gpsiter (fun n -> n#add_pktout_mhook ~stack:2 (route_cost_hook fresh_cost));;
> -------------------------------------------------------------------------------
>  It,,,, I think, looks like the only total searching disk size.
>  Am I wrong????

You are correct, these hooks measure the search cost. Note that this is 
exactly what the tutorial says :) 

"We now are going to define and insert the hooks to measure search costs"

>  I think that total sum of route cost + total searching disk size is the cost...
> but, it looks like only total searching disk size....

Counting the route cost can be easily done with hooks 
similar to those for the search cost. If you have any trouble doing this 
please let me know.

> 2. I want to print out the postion of nodes every test.
>  Can you give me any suggestion? 


Yes, you can do this by iterating over all nodes with Nodes.iter 
(http://nab.epfl.ch/gen/Nodes.html).

Something like:

let print_node_pos nodeobj = 
   let id = nodeobj#id in
   let x, y = (World.w())#nodepos id in
   Printf.printf "Node %d : <%f, %f>\n" id x y;;


Nodes.iter print_node_pos;;




Best Regards, 

Henri

> 
> I would appreciate if you answer to me...
> 
> Regards.
> 
> 
> 
> 
>