[ns] How to send a packet to previous node

Teerawat Issariyakul teerawat at ece.ubc.ca
Tue Nov 11 08:36:29 PST 2008


Dear Howard,

Say you have a topology like (n1)-->(n2). Usually, packet will flow from
(n1) to (n2). When you want to send a packet from (n2) back to (n1), you
can do the following.

1. Define an instvar $conn (whose class Connector) of n2
2. Put the following in the Tcl simulation script

[$n2 set conn] target $n1

3. I don't know when you want to send the packet back to n1, but when
you want to do so, you can simply send the packet to $conn by using
function recv(p,h)

I hope this will help.

Regards,
Teerawat

On 11/11/2008, "howardgod howardgod" <howardgod at gmail.com> wrote:

>Deer Teerawat
>I already know how to transmit to node. 1.generate new packet 2.fill common
>header and destination address 3. target->recv(p,h)
>but my problem is that, I can't find out previous hop's address. My purpose
>is to send a packet to previous node in IFQ.
>But when packet received by queue's recv function. I can't find anything
>about previous hop's address in common header, ip header or mac-802_11
>header.
>I also know that in routing object, it can find out the next hop's
>information in routing table. But unfortunately in IFQ can't access routing
>object's functions.
>
>any way, thanks a lot of ur reply.
>
>Howard
>
>2008/11/11 Teerawat Issariyakul <teerawat at ece.ubc.ca>
>
>>
>> Dear Howard,
>>
>> The easiest way to transmit from one NsObject (e.g. Nodes) to another is
>> through a (C++ and Tcl) Connector object. A connector has two pointers
>> to NsObjects: target_ and drop_. In the OTcl domain, it uses an OTcl
>> commands "target" and "drop" (followed by the name of the NsObject)
>> to specify its "forwarding object" and "dropping object"
>>
>> A Connector object recieves a Packet "p" through its funciton
>> recv(p,h). Upon receiving a packet, the Connector object forwards the
>> packet "p" to its forwarding object by executing
>> "target_->recv(p,h)". To drop a packet, the function drop(p) of a
>> Connector object is invoked. In this case, the packet is forwarded to
>> the dropping object "*drop_" which is responsible for destroying the
>> packet.
>>
>> To find out more about Connector please refer to chapter 5 in the
>> following book from Springers:
>>
>> If you are a beginning user, you may look at the following book from
>> Springer.
>>
>> T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
>> NS2", Springer 2008.
>>
>> Here is the link:
>> http://www.springer.com/engineering/signals/book/978-0-387-71759-3
>>
>> You might also find the following slide useful:
>> http://www.ece.ubc.ca/~teerawat/NS2.htm<
>> http://www.ece.ubc.ca/%7Eteerawat/NS2.htm
>>
>> On 11/11/2008, "howardgod howardgod" <howardgod at gmail.com> wrote:
>>
>> >
>> >---------- Forwarded message ----------
>> >From: howardgod howardgod <howardgod at gmail.com>
>> >Date: 2008/11/8
>> >Subject: How to send a packet to previous node
>> >To: ns-users at isi.edu
>> >
>> >
>> >I want to send a packet to previous node. And I don't know how to find
>> >previous node's ID and where to fill the ID.
>> >
>> >I found that in common header, there's a prev_hop and next_hop_. But the
>> >prev_hop_ is NOT the previous node. It's the source.
>> >
>> >So I want to fill previous node's ID to common header's next_hop_.
>> >
>> >And is there anything else I have to fill?
>> >
>> >btw I found a way to do so. Reverse the ip header's src and dst then send
>> >it. but It still do nothing at all.
>> >
>> >HELP ME!! PLZ
>> >
>> >thanks a lot.
>> >
>> >                 Howard.
>> >
>>



More information about the Ns-users mailing list