Hi Faisal,
There's two possibilities to do that in ns. May be, in the examples
you are referring to, source and destination agents responsible of
generating packets are explicitely connected to each other in the tcl
script, making one of them source of packets and the other its
destination for all the simulation (I think this was the case in the
ping tutorial, where ther's 2 agents, one source and the other the
destination). In this case, the variable target_ -I'm not sure this is
its actual name, but jsut to say that the destination of each packet
is fixed in the beginning of the simulation an has not to be set in
the code.
The other way, is to not conect explicitely source and destination but
set them in the source code, like this:


Packet *pk = Packet::alloc();
struct hdr_ip *ihpk = HDR_IP(pk);
ihpk->daddr() = dest;
ihpk->saddr() = my_address;
ihpk->sport() = MYAGENT_PORT;
ihpk->dport() = MYAGENT_PORT;

In this case, you should assign a port value to all agents created in
your tcl file, to be sure packets are correctly received by
correspondent agent.

Bye.


On 4/18/06, Faisal Siddiqui <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have been investigating NS2 for research purposes for the last several
> weeks. I have a very basic question and would really appreciate if someone
> could shed some valuable light on it.
>
> I really stepped through each line of the code but can't really find when
> and where the simulator assigns source and destination node addresses to the
> packets. Could someone please explain in some detail how, when and where the
> packets are assigned source and destination node addresses and from where
> does the packets learn this information? Also, if there are more than 3
> nodes (in case of ping agent), how does the packet establishes the source
> and the destination nodes for traffic because in the Tcl script we only
> connect the agents and do not specify the source and destination nodes.
>
> Secondly, function "access (some argument) is spread all over the code. I
> went through the manual as well but can't really understand why it is being
> used in so many places. Could someone please explain what is the purpose of
> using this function and how does this function when cast into different data
> types provides information?
>
> Thanks,
> - Faisal Siddiqui
>

Reply via email to