LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-26-2019, 01:07 AM   #1
bswap
LQ Newbie
 
Registered: Aug 2018
Location: India
Posts: 6

Rep: Reputation: Disabled
Unhappy To add a C++ code in DSR Protocol in NS2


I am working on DSR protocol in NS2 for my project. For my required application, the complete situation is as follows:

Suppose, X is the sending node and Y is the receiving node. All the nodes are moving. X must have sent or forwarded packets to Y previously. Now when Y is 1 hop count away from X (i.e. neighboring node), X will receive a 'Hello' message from Y. Now, X has to send route request message but instead of that it will send an investigation message to all its neighbors including Y that how many packets did they receive from X previously.. Y is having the count of received packets from X along with the route. Y sends it to X in Investigation reply message. X stores the count.

So, how can I modify the code? Where should I make the modifications?
Can I get the code to be attached for the complete situation?

Also please tell me how can I modify 'Hello' message in DSR.

Thank You.
 
Old 02-26-2019, 08:08 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,420
Blog Entries: 13

Rep: Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739
I'm guessing that you may be able to use different languages, including C++, but mainly I see .tcl scripts being used.

Please perform a general web search for "how to do a simulation in ns2" and the find results should give you plenty of examples.

Please also understand that your fellow members are all volunteers, we're happy to try and help with a problem, however what helps us it knowing what you have tried. You've not shown any attempts and instead asked for complete code. Someone may have an exact example, or they may not.

As far as how you modify code to make a simulation, please search for that information. Because there is plenty on the web and any reiteration of that, which I might do here would be very limited coverage of a rather large topic that already has plenty of well written guides.
 
1 members found this post helpful.
Old 02-26-2019, 08:52 AM   #3
bswap
LQ Newbie
 
Registered: Aug 2018
Location: India
Posts: 6

Original Poster
Rep: Reputation: Disabled
Sir, I genuinely appreciate your suggestion. But I am done with the simulation part. My network is ready. Now my aim is to make modifications in the existing protocol. I've also done number of web searches but didn't get anything. Also, unfortunately, I don't possess the knowledge of C++...
 
Old 02-26-2019, 09:42 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,420
Blog Entries: 13

Rep: Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739
Quote:
Originally Posted by bswap View Post
Sir, I genuinely appreciate your suggestion. But I am done with the simulation part. My network is ready. Now my aim is to make modifications in the existing protocol. I've also done number of web searches but didn't get anything. Also, unfortunately, I don't possess the knowledge of C++...
I've never modified the NS2 source code. I have however downloaded, modified, and rebuilt source code applications to customize their behavior to do what I want.

Therefore the most complicated, but definitive method to modify the actual application is to download the NS2 source, read the information about how to build it, build it and test it to verify it works, and then review the source code to determine where you can put in your modifications. I can pretty much guarantee that if you put in the effort to go that far and identify a C++ source file, and function where you believe changes can be made which will modify the behavior as you intend, and you discuss what you are thinking about how to modify it, then many members here can possibly review that material and offer their thoughts. I know that if someone showed me source, told me what they wanted to modify in it, and asked me if I felt their proposed modifications would work, I would be able to review enough of it to help advise them.

As you say, you've managed to write a simulation. Therefore you've used something attune to a programming language; albeit instead a script language. C++ is not that much harder than Tcl. It is similarly readable.

Unless someone happens to reply and say that they've already done this exact modification, and they post a link to their code, I see no real alternative. One possible alternative is whether or not you actually need to modify the NS2 source and instead can write additional Tcl script modifications which will cause the application to behave as you intend.
 
1 members found this post helpful.
Old 02-26-2019, 09:42 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,420
Blog Entries: 13

Rep: Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739Reputation: 3739
Quote:
Originally Posted by bswap View Post
Sir, I genuinely appreciate your suggestion. But I am done with the simulation part. My network is ready. Now my aim is to make modifications in the existing protocol. I've also done number of web searches but didn't get anything. Also, unfortunately, I don't possess the knowledge of C++...
I've never modified the NS2 source code. I have however downloaded, modified, and rebuilt source code applications to customize their behavior to do what I want.

Therefore the most complicated, but definitive method to modify the actual application is to download the NS2 source, read the information about how to build it, build it and test it to verify it works, and then review the source code to determine where you can put in your modifications. I can pretty much guarantee that if you put in the effort to go that far and identify a C++ source file, and function where you believe changes can be made which will modify the behavior as you intend, and you discuss what you are thinking about how to modify it, then many members here can possibly review that material and offer their thoughts. I know that if someone showed me source, told me what they wanted to modify in it, and asked me if I felt their proposed modifications would work, I would be able to review enough of it to help advise them.

As you say, you've managed to write a simulation. Therefore you've used something attune to a programming language; albeit instead a script language. C++ is not that much harder than Tcl. It is similarly readable.

Unless someone happens to reply and say that they've already done this exact modification, and they post a link to their code, I see no real alternative. One possible alternative is whether or not you actually need to modify the NS2 source and instead can write additional Tcl script modifications which will cause the application to behave as you intend.
 
1 members found this post helpful.
Old 02-26-2019, 10:15 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,591

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
yep what rtmistler said, get a copy of the source or whatever you're working with now. then look at it, then find the code that is doing what you need or find where you need to cut in to manipulate it to do something else, that being hat you want it to do instead, or add to before it completes the operation you're cutting into.

I use a lot of printf or cout to see what it is doing so I can figure out how to modify it to do what I now want it to do, along with a lot of searching for snippets of how to do something if needed, then just mod that to make it work for me, if need be.

It will probably turn into a lot of peck and hunting to find the locations you need to be in, I use grep to search text code for "key" words I think might be used to perform certain tasks at times to cut down on searching through lines and lines of code in multiple files.

how-to-use-dsr-routing-protocol-in-ns2
 
2 members found this post helpful.
Old 02-26-2019, 12:20 PM   #7
bswap
LQ Newbie
 
Registered: Aug 2018
Location: India
Posts: 6

Original Poster
Rep: Reputation: Disabled
Well the idea using an already modified DSR didn't strike my mind actually. Thanks for the remarkable words from rtmistler and BW-userx. Basically I needed code for trust based DSR protocol to be modified my way. For AODV everything is readily available but it is hard to find for DSR. I'll just search for it and if possible please mention the link for it...

Thank you.

Last edited by bswap; 02-26-2019 at 12:25 PM.
 
Old 02-26-2019, 12:26 PM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,591

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
open source = reusable code curtailed to your needs.
 
  


Reply

Tags
c++ programming, dsr, ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Run scenario of DSR protocol multiple times in one session in ns2 sadeem Linux - Networking 6 04-10-2018 12:46 PM
Multipath Design using DSR routing protocol in ns2 tandel kavita Linux - Wireless Networking 2 03-12-2013 04:45 PM
Black hole insersion for DSR protocol Abhee Linux - Newbie 3 06-18-2012 01:47 AM
How to run DSR protocol in ns-2 NimeshaK Linux - Newbie 5 03-29-2012 07:52 AM
weight throwing protocol using ns2 code,diffusion based protocol using ns2 code rajrupa Linux - Networking 1 05-27-2010 04:39 AM

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

All times are GMT -5. The time now is 12:27 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration