LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   construction of packet in NS2 (https://www.linuxquestions.org/questions/linux-newbie-8/construction-of-packet-in-ns2-4175539744/)

sims2801 04-14-2015 10:15 PM

construction of packet in NS2
 
I am implementing a new protocol in NS2.
I stucked at a point. kindly help me.
Is it possible to make two different type of packets(containing different headers) in the same simulation
In my protocol there are two types of struct header { } . At few instances i want to use one and at other instances want to use another.One of the structure has very less fields compared to other so this would reduce the size of packet i'm sending.
Is it possible ? and if yes then how to implement that?

rtmistler 04-15-2015 08:07 AM

Quote:

Originally Posted by sims2801 (Post 5347549)
I am implementing a new protocol in NS2.
I stucked at a point. kindly help me.
Is it possible to make two different type of packets(containing different headers) in the same simulation
In my protocol there are two types of struct header { } . At few instances i want to use one and at other instances want to use another.One of the structure has very less fields compared to other so this would reduce the size of packet i'm sending.
Is it possible ? and if yes then how to implement that?

Yes it's very possible. Post the exact structures you've created and explain in better detail where you're stuck. You seem to be concerned that each packet or header is a different size, which is not a problem. Have you tried to run it and found a problem?

sims2801 04-16-2015 11:13 AM

thanks a lot for ur help and kind reply .
I must say this forum and its members are very helpful. we post lots of questions on other forums also but never we get any kind of reply. But on this forum , always kundl helped us. Really a great job .
thanks a lot .

Actually , I want to optimize a routing protocol. For this purpose , i am creating two packets.

I want to know x,y of the nodes at certain instances in my protocol so instead of sending the huge packet which I'm using for Route Request. I am thinking about sending a packet of smaller size so as to decrease overhead( or optimize it as the large packet is not required for this work ).

For that i have created 2 structures 1 for route request and another for CoordinateRequest(small packet).They are as follows-
In lar.h file
1)
struct hdr_dlar {

double sourceX_;
double sourceY_;
double lastHopX_;
double lastHopY_;
double destinationX_;
................... and many more fields and inline functions to access them and size() and headerLength()
}

2)
struct hdr_cordReq{
char dlarCode_;
double sourceX_;
double sourceY_;

....................... few more fields , inline functions to access them and size() and headerLength()
};

2nd structure has almost 1/4th fields compared to the 1st structure.

In lar.cc file
we have lines like this to access packet and its headers
Packet* newpkt = allocpkt();
struct hdr_cordReq* newlarhdr = hdr_cordReq::access(newpkt);

Now I'm stuck that when I'm creating a new packet will it contain both the headers (structures) because if it is containing both then even though I'm accessing only one structure still I'm not fulfilling the motive of creating a small packet .
So my basic question is if I'm doing like this will memory be given to both the structures in the packet (this is not I want to happen in my protocol) ? If not then how to decide which structure is getting the memory.

Main purpose of all this is the routing overhead is reduced , but i don't know it will happen by doing this or not . plz suggest.
If there is any other possible way then please suggest and help me out.

rtmistler 04-16-2015 12:44 PM

It's hard to say depending on what allocpkt() does. Why can't you give it an argument allocate based on the packet header type? Eventually the information contained in the frame should indicate what type it is, right? If you have to union them to always match your larger packet size, but then ignore extra if you happen to use the briefer size, this is an option commonly used where it always allows for the max packet size, but accepts that for the smaller packet size, some of that space is just wasted. That tactic doesn't then have a packet size which matches both structures together.

sims2801 04-17-2015 12:21 AM

allocpkt() is a function for creating/ generating the packet. It is defined in agent.cc , it calls alloc function of Packet class (defined in packet.h) and initpkt(p) function of Agent class (defined in agent.cc).
alloc function -- allocates memory
initpkt(p) --- fill all the generic fields of packet.

What i concluded is
I will create two packets/ structures as mentioned in #3. Modify the recv function in such a way that it will check the type of packet whether it is a 1st or 2nd. Accordingly pointer of that structure and function for that purpose would be called. I think it will reduce the routing overhead bcz in Packet class , there is a function init(Packet*) which intialize the packet header. So, packet header would be initialized as per the type of packet. But still confusion at two points :
1) When we calculate the routing overhead from the trace file, would this point be visualized in the trace file?

2) In protocols like AODV, GPSR , we have different type of packets like hello packet , route request pkt , route reply pkt etc. . But in both the protocols , they have used UNION . But here ,we are not using UNION. Will it work ...

plz guide further .

thanks & rgds

sims2801 04-21-2015 01:10 AM

@rtmistler -- kindly reply so that i can proceed further.

if anyone else knows about this issue , please please ..........reply


All times are GMT -5. The time now is 02:22 PM.