LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-01-2019, 07:52 AM   #1
soorya
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Rep: Reputation: Disabled
To access all nexthops in a path


Hai,
How can I find all the nexthops in a
Path using aomdv protocol.When i call
path->nexthop,I am getting the first hop of that path..How can I access further hops.Is there any way to increment nexthops...please help....
 
Old 07-01-2019, 08:02 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by soorya View Post
Hai,
How can I find all the nexthops in a Path using aomdv protocol.When i call path->nexthop,I am getting the first hop of that path..How can I access further hops.Is there any way to increment nexthops...please help....
Yes, you have to modify your code to do so. We will be happy to help you, so post your code and show us what you've done/tried so far, and we'll be glad to assist. See the "Question Guidelines".
 
1 members found this post helpful.
Old 07-01-2019, 08:21 AM   #3
soorya
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
To access all nexthops in a path

if(rt->rt_flags == RTF_UP) {
double max = 5.0;
assert(rt->rt_hops != INFINITY2);
AOMDV_Path *path = rt->path_find();

for (; path; path = path->path_link.le_next){
int nexthop = path->nexthop;
int path_count = path->hopcount;
while(resi_energy[nexthop]>=max){
ap1==true; ///here I want to check this condition for all nexthops in the path
}
if(ap1==true){
forward(rt, p, NO_AOMDV_DELAY);
}


}



}
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2019-07-01 18-49-48.png
Views:	21
Size:	180.4 KB
ID:	30819  
 
Old 07-01-2019, 08:54 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by soorya View Post
Code:
if(rt->rt_flags == RTF_UP) {
		double max = 5.0;
		assert(rt->rt_hops != INFINITY2);
		AOMDV_Path *path =  rt->path_find();
	
		for (; path; path = path->path_link.le_next){  
			int nexthop = path->nexthop;
			int path_count = path->hopcount;
			while(resi_energy[nexthop]>=max){
				ap1==true;  ///here I want to check this condition for all  nexthops in the path
			}			
			if(ap1==true){
				 forward(rt, p, NO_AOMDV_DELAY);
			}
		}
	}
Post code in CODE tags, and again, read the "Question Guidelines". You've posted a VERY small piece of code, with no context, error messages, or told us what you've done/tried. What do you expect us to be able to do with this???
 
Old 07-01-2019, 09:22 AM   #5
soorya
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
I am attaching aomdv.cc code here in text format.I am using ns2.35.I want to forward packets through the paths in which all nodes have an energy level higher than 5(threshold).So I made changes in AOMDV::rt_resolve(Packet *p) function.(Line 512-552). In line 544 I added a while loop for checking all nexthops in the path.But I dont know how to increment the nexthop to the remaining hops in the path. While running this code the while loop is not terminating bcz the nexthop condition is not changing .It only check first hop in the path.So how can I access further nexthops ?
Attached Files
File Type: txt aomdv.txt (48.1 KB, 19 views)

Last edited by soorya; 07-01-2019 at 09:31 AM.
 
Old 07-01-2019, 09:25 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by soorya View Post
I am attaching aomdv.cc code here in text format.
No, you didn't attach the file, and before you do that please (AGAIN) read the "Question Guidelines". Don't just post the code you downloaded in a file, and expect people to download it and run it. We volunteer our time to try to help...post the code HERE (in CODE tags), and most importantly, SHOW US WHAT YOU HAVE DONE/TRIED SO FAR.

Again, we are happy to help, but we aren't going to make your code changes for you. You have to show your own efforts.
 
Old 07-01-2019, 09:44 AM   #7
soorya
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Code:
void
AOMDV::rt_resolve(Packet *p) {
	struct hdr_cmn *ch = HDR_CMN(p);
	struct hdr_ip *ih = HDR_IP(p);
	aomdv_rt_entry *rt;
	bool ap = false;
	bool ap1 = false;

	struct hdr_aomdv_reply *rp = HDR_AOMDV_REPLY(p);

	/*
	 *  Set the transmit failure callback.  That
	 *  won't change.
	 */
	ch->xmit_failure_ = aomdv_rt_failed_callback;
	ch->xmit_failure_data_ = (void*) this;
   	rt = rtable.rt_lookup(ih->daddr());
	if(rt == 0) {
		rt = rtable.rt_add(ih->daddr());
	}
	
	/*
	 * If the route is up, forward the packet 
	 */
   /*I made modification here*/
  	if(rt->rt_flags == RTF_UP) {
		double max = 5.0;
		assert(rt->rt_hops != INFINITY2);
		AOMDV_Path *path =  rt->path_find();
	
		for (; path; path = path->path_link.le_next){  
			int nexthop = path->nexthop;
			int path_count = path->hopcount;
			while(resi_energy[nexthop]>=max){
				ap1==true;
					
			}			
			if(ap1==true){
				forward(rt, p, NO_AOMDV_DELAY);
			}
			
		
		}
		


	}
 
Old 07-02-2019, 07:05 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by soorya View Post
I am attaching aomdv.cc code here in text format.I am using ns2.35.I want to forward packets through the paths in which all nodes have an energy level higher than 5(threshold).So I made changes in AOMDV::rt_resolve(Packet *p) function.(Line 512-552). In line 544 I added a while loop for checking all nexthops in the path.But I dont know how to increment the nexthop to the remaining hops in the path. While running this code the while loop is not terminating bcz the nexthop condition is not changing .It only check first hop in the path.So how can I access further nexthops ?
Don't edit your posts; AGAIN, read the "Question Guidelines" and the LQ Rules. You added a great deal to this post, as well as attaching a file to it. And when you were asked to post the code, you still only posted a small bit.

The actual file you posted has an example on line 302 of how to implement a counter to loop through things.
 
  


Reply



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
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM
Removing path form PATH maginotjr Linux - Newbie 3 02-12-2005 02:23 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM
$PATH!? how to set these PATH(s)!? sirpelidor Red Hat 5 10-25-2003 04:00 PM

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

All times are GMT -5. The time now is 02:49 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