Thanks for your responce,

in my case I have a wired scenario and I use the default (static) routing.
As I say in the previous post, I do all the work in the connector class. I
don't really care from which layer the packet is dropped, as long as I have
access to the packet to read the information from it.

So, if I got this correct, your suggestion is to move the code out from the
connector class and put it in the routing agent for example? In my case
that I use static routing, which is the file that I should edit?

Sorry for the amount of question but it is the first time I work with the
c++ code of ns2. So far I never had to change anything to perform my
simulations.

Thanks again,
Giorgos

On 3 August 2012 16:07, Ali Rostami <ali.rostami...@gmail.com> wrote:

> first of all you should determine which layer is responsible for dropping
> the packet?
> I suppose it's routing agent, for example. then, put this line wherever
> you want to drop the packet p:
>  drop(p, DROP_RTR_YOUR_REASON);
> put this at line 97 in file %NS_DIRECTORY%/trace/cmu-trace.h
> #define DROP_RTR_YOUR_REASON     "XXX"
> then run the following command:
> touch %NS_DIRECTORY%/trace/cmu-trace.cc
> now you can make the ns code. when the ns drops a packet under your
> condition, the trace will be like this:
> D 2.828954441 1 RTR  XXX 2 cbr 512 [0 0 0 0] ------- [1:0 20:0 32 0] [2] 0
> 3 0
>
> Good luck!
>
>
>
> On Fri, Aug 3, 2012 at 4:49 PM, Giorgos Karanikas 
> <computera...@gmail.com>wrote:
>
>>
>>
>> To provide some more info:
>>
>> Suppose I have the following topology:
>>
>> http://old.nabble.com/file/p34250683/topology.jpeg
>>
>> What I want is node D to drop packets from some specific nodes. What I've
>> done is the following:
>> I added one variables in the node.cc && node.h to define if the packets
>> from
>> that node are to be dropped and I also added one variable to the packet.cc
>> (in the header of the packet) to define after how many hops the packet is
>> to
>> be dropped.
>>
>> In the connector.cc I have changed the recv(Packet* p, Handler* h)
>> function
>> in order to check if the packet is to be dropped. If not then I update the
>> packet's hop variable I created (increase it to show the number of hops
>> that
>> packet has been over).
>> If the packet is to be dropped though I call the drop(p) function.
>>
>> As I said that does not work properly since (probably) the Packet::free(p)
>> function is used as I don't see the packet drop events in the traces.
>>
>> Anyone knows what I'm doing wrong? Should I define a drop-target for D and
>> connect it to the agents from the nodes that I want packets to be dropped?
>> And exactly how am I supposed to do that (since I tried but I failed)?
>>
>> Thanks in advance and I hope that these information give a clearer view of
>> my situation.
>> --
>> View this message in context:
>> http://old.nabble.com/Properly-drop-packet-tp34250208p34250683.html
>> Sent from the ns-users mailing list archive at Nabble.com.
>>
>>
>

Reply via email to