LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2015, 10:15 PM   #1
sims2801
Member
 
Registered: Aug 2012
Posts: 50

Rep: Reputation: Disabled
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?
 
Old 04-15-2015, 08:07 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by sims2801 View Post
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?
 
Old 04-16-2015, 11:13 AM   #3
sims2801
Member
 
Registered: Aug 2012
Posts: 50

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-16-2015, 12:44 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
Old 04-17-2015, 12:21 AM   #5
sims2801
Member
 
Registered: Aug 2012
Posts: 50

Original Poster
Rep: Reputation: Disabled
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
 
Old 04-21-2015, 01:10 AM   #6
sims2801
Member
 
Registered: Aug 2012
Posts: 50

Original Poster
Rep: Reputation: Disabled
@rtmistler -- kindly reply so that i can proceed further.

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


Reply

Tags
ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to broadcast packet in ns2.34? anand755 Ubuntu 15 01-05-2017 07:38 PM
ns2-aodv hello packet indumit18 Linux - Software 0 03-05-2012 04:33 AM
[SOLVED] how to create my own packet in NS2 naren123.k Programming 2 04-21-2011 05:51 AM
packet reordering NS2 passer-by Linux - Newbie 3 11-01-2010 06:37 PM
libnet packet construction - wrong values = infinite loop?! westies870 Programming 0 05-13-2008 05:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration