LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-05-2003, 07:58 PM   #1
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Rep: Reputation: 0
Question Dialing only when there is data to send via PPP


Hi,

If PPPd is invoked with the demand option, as described in pppd man pages, the pppd deamon starts running but chat script is not executed and there is no attempt to establish connection with the PPP server. Thats good. But now coming to the real question ... does demand option mean that when there is data to send out, pppd will try to establish connection with the PPP server on its own? What will happen if pppd is not able to establish connection .. how will my function know that PPP connection couldn't be established? I am not running PPP with updetach option, hence it runs detached from the controlling terminal from the get go. Is there a way to find out if PPP connection got established successfully and the data went thru in this case? The intent is to not hold the calling process while we r trying to establish the PPP connection, thats the reason pppd is invoked without the updetach option.
Since connection is established only when there is data to send, this wouldn't cost more than when nodemand option is specified. Is that right?

Is there a way of making sure that only one PPPd and PPP connection is alive/active at any time?

Any pointers will be highly appreciated.

Thanks,
Ruchika
 
Old 09-06-2003, 12:53 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 389

Rep: Reputation: 52
Sorry you're not getting too many replies to your posts. It's just that your questions are a bit unstructured, but that's okay because that's just the stage you're at. I hope you'll forgive me if my suggestions are also unstructured.

It seems to me that your program shouldn't be written to be so PPP specific. What if the situation should change and the client and server need to be on the same LAN, over the Internet, or on the same machine? You would have to change your program for it to work. I can't think of any client or server program that I use that is aware if I'm using PPP or not.

So, your client program shouldn't worry about whether or not pppd connected successfully--only that the call to connect was successful. But before that, it has to worry about if the call to gethostbyname was successful. This is how to know what IP address to specify in the connect call. Your client program should accept a hostname to connect to. You could add a line in /etc/hosts to provide an IP address to the other end of the PPP connection. You can find out the IP address of the other end of the PPP link by running ifconfig while the PPP link is up; as far as I know, it stays the same.

There's an article at http://www.linuxjournal.com/article....rder=0&thold=0 that deals with some of this material.

In order to deal with the slow connection times associated with a PPP connection coming up or other errors, your client could use a back off algorithm for the gethostbyname and connect calls. For example, if the call to gethostbyname fails, it could wait 2 seconds and try again. If that fails wait 4 seconds then try, if that fails wait 6 seconds, and on and on to a configurable number of tries or amount of time to keep trying.

pppd runs some scripts, namely ip-up and ip-down when a PPP connection comes up and goes down respectively. You can do whatever you want in these scripts, and pppd passes a bunch of environment variables you can use in these scripts. See man pppd and the PPP HOWTO at http://www.tldp.org/HOWTO/PPP-HOWTO/index.html

Lyle
 
Old 09-08-2003, 09:39 PM   #3
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0
Thank you for the reply lyle_s.

Excuse me if my questions may have been unstructured. I'll try to be more clear about things.

As mentioned by you, it makes sense not to make the client PPP aware. Someone else is working on a module that allows the client and server on the same LAN to talk to each other over the Internet. My job is to provide plugins for an alternate route (instead of LAN, a CDMA modem that can establish PPP connection). We are already using socket interface. So once the PPP connection has been established, we can use the same socket interface for data transfer.

I have the PPP connection established. But I am not able to browse the internet. I think the problem is because the default route is ethernet on my machine. I know that by changing the default route using /sbin/route del default I can fix this. Is there an alternate way of fixing this problem? Maybe by specifying something in the options file?

Also, I want to support demand dial. Do I need to specify/change some settings inorder to support this? My current settings are

persist idle debug lock modem crtscts defaultroute noauth bsdcomp 0 deflate 0 asyncmap 0 kdebug 0 connect $DIALER SCRIPT

Thanks,
Ruchika
 
Old 09-08-2003, 10:41 PM   #4
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 389

Rep: Reputation: 52
You can get dial on demand working by placing "demand" in the options file. Use the "idle" option to specify how many seconds of inactivity on the ppp interface you want before pppd terminates the connection.

You can have pppd add a default route to the ppp interface by adding "defaultroute" to the options file.

This is what my options file looks like:
root@europa:~# cat /etc/ppp/options.demand
# General configuration options for PPPD:
lock
defaultroute
noipdefault
modem
/dev/modem
115200
crtscts
# Uncomment the line below for more verbose error reporting:
#debug
# If you have a default route already, pppd may require the other side
# to authenticate itself, which most ISPs will not do. To work around this,
# uncomment the line below. Note that this may have negative side effects
# on system security if you allow PPP dialins. See the docs in /usr/doc/ppp*
# for more information.
#noauth
passive
asyncmap 0
name "username corresponding to username in pap-secrets"
ipcp-accept-local
ipcp-accept-remote
0.0.0.0:10.10.10.10
demand
idle 180
maxfail 100
connect "/usr/sbin/chat -v -f /etc/ppp/pppscript"
# End general configuration options for PPPD

pppd is started like this:

root@europa:~# pppd file "/etc/ppp/options.demand"

Hope this helps,
Lyle
 
Old 09-09-2003, 04:12 PM   #5
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks lyle_s.

You had mentioned that the client program shouldn't worry about whether or not pppd connected successfully--only that the call to connect was successful. I call connect on a non-blocking socket, and also select the socket for completion of connection before writing, what should I look for inorder to know that the connection could not be established? Does select still indicate writablilty if connection fails? Can a timeout be specified on connect?

In some cases, the application may want to know the reason why the connection could not be established. For eg, if the modem is not connected, if there is no carrier etc. I am thinking of creating a thread that establishes PPP connection with the updetach option inorder to catch the errors returned by pppd/chat and not block the main process. Is this the standard way to catch errors and know the connection state or is there another way?

Thanks,
Ruchika
 
Old 09-09-2003, 11:50 PM   #6
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 389

Rep: Reputation: 52
Sorry, you've gone a bit out of my area of expertise (which isn't that large in the first place). I've never used select or non-blocking sockets; I've just done a "hello network world" sort of thing.

Wish I could help more.

Lyle
 
Old 09-10-2003, 11:30 AM   #7
ruchika
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0
No problem Lyle. Thanks for you help.

Ruchika
 
  


Reply


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
Can't start PPP after dialing in... Or don't know how to start PPP after dialing in.. exabrial Linux - Networking 2 04-13-2004 04:46 PM
ppp demand dialing hangs startup process Tom Bozack Linux - Networking 0 03-24-2004 05:22 PM
getting ENOBUFS while trying to send data arb Programming 0 09-19-2003 06:52 AM
Sending data over ppp shibdas Linux - Networking 0 06-26-2003 12:40 PM
ppp demand dialing med Linux - Networking 2 04-02-2002 10:51 AM


All times are GMT -5. The time now is 12:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration