PPP dialing script configuration

Source: Internet
Author: User
Tags control characters

Summary
This article describes how to configure the script used for PPP dialing using pppd 2.4.4 in an embedded Linux system. It also describes how to configure parameters, implements PPP dial-up Internet access.

I. Question proposal
In an embedded Linux operating system, if you want to perform a PPP connection, you need to configure the connection script to be used for dialing. These script parameters determine the behavior of pppd, which will have a great impact on PPP connections. Therefore, you need to understand the parameters and meanings of these scripts.

Ii. Solution
There are two scripts closely related to PPP: chat and options. The chat script is used for at call and control, and the options script affects PPP connections.

1. Chat script
A Simple Chat script has the following structure:
""
OK atdt dialnumber
Connect ""
A chat script is composed of string pairs. The preceding strings are the desired strings, followed by the sent strings. The specific meaning of each item in this script is as follows:
1) the modem expects a null string. The meaning of this sentence is that no matter what string the modem receives, it first issues the string;
2) expect to receive the "OK" string and then send the string "atdt dialnumber"
3) If "Connect" is received, it will not be sent again and the data link has been connected.
This chat script is the simplest. If you need time-out control, you can add the following fields:
Timeout 10
If you want to add processing for special cases, add the following fields:
Abort busy
Abort no answer
Abort ringing
The three statements mean that if the strings "busy", "No answer", and "Ringing" are received, the execution is exited.
In special cases, you can configure a chat script for a PPP connection as follows:
Timeout 30
Abort busy
Abort no answer
Abort ringing
""
OK atdt dialnumber
Connect ""

2. Options script
The options script specifies the device used for the connection, the control character transmission rate, hardware acceleration, and overflow control for the PPP connection.
For example, the following options script:
Ttys0 ---- specify the device used for the connection, such as ttys0 and ttys1.
57600 ---- set the transmission rate of the control characters used by the connection, which can be set to 57600 or 115200.
Debug ---- if debugging information needs to be added, add the debug parameter.
Logfile/var/ppplog ---- input the information in the connection process to a file
MTU 1500
-Detach
Noipdefault ---- The noipdefault parameter can be added without using the default IP address.
Defaultroute
Usepeerdns ---- You can set the usepeerdns parameter by using the DNS negotiated by the server.
LCP-Echo-failure 4 ---- when the LCP echo request is not received four times in a row, the server is deemed to have no response and then exited. The number of failures can be determined flexibly.
-CCP-no compression control protocol is used
-VJ ---- disabled IP Header Compression
-Chap ---- Do not use CHAP authentication
-Mschap-v2-does not use mschap Authentication
User
Hide-Password
Connect "/usr/bin/chat-v-T6-F/var/chat" ---- specifies the location of the chat script to be used. Add the parameter-V to tell the chat command to copy all the output/inputs to the system record (usually/var/log/messages ). -T 6 specifies that the time for executing the chat command is 6 s. The location of the chat script can be either in the/etc/directory or in the/var Directory, which requires more flexible settings.
Persist --- Permanent Link (automatic redial)
Crtscts --- tell PPP to use Modem Hardware Traffic Control
Modem --- enable PPP to use the DCD signal to determine whether the connection is normal or not.
Deflate --- use defalte compression for pppd
Idle --- sets a time limit. When no data is transferred within 300 seconds, the connection is closed.
Lock --- create a lock file. After other programs find this file, they will be able to know that the corresponding serial port has been used.
Demond --- the parameter tells pppd to stay in the background and monitor network data. If required, it will be connected immediately. After the timeout, the connection will be disconnected, but pppd will stay in the background and wait for the next data transmission.
For details about other parameters, refer to the notes in options. c In pppd2.4.4:

/*
* Option variables and default values.
*/
Int DEBUG = 0;/* debug flag */
Int kdebugflag = 0;/* Tell kernel to print debug messages */
Int default_device = 1;/* using/dev/tty or equivalent */
Char devnam [MAXPATHLEN];/* device name */
Bool nodetach = 0;/* Don't detach from controlling tty */
Bool updetach = 0;/* detach once link is up */
Int maxconnect = 0;/* maximum connect time */
Char user [maxnamelen];/* username for pap */
Char passwd [maxsecretlen];/* password for pap */
Bool persist = 0;/* reopen link after it goes down */
Char our_name [maxnamelen];/* our name for authentication purposes */
Bool demand = 0;/* Do dial-on-demand */
Char * ipparam = NULL;/* extra parameter for IP up/down scripts */
Int idle_time_limit = 0;/* disconnect if idle for this role seconds */
Int holdoff = 30;/* # seconds to pause before reconnecting */
Bool holdoff_specified;/* true if a holdoff value has been given */
Int log_to_fd = 1;/* Send log messages to this FD too */
Bool log_default = 1;/* log_to_fd is default (stdout )*/
Int maxfail = 10;/* max # of unsuccessful connection attempts */
Char linkname [MAXPATHLEN];/* logical name for Link */
Bool tune_kernel;/* may alter kernel settings */
Int connect_delay = 1000;/* wait this week MS after connect script */
Int req_unit =-1;/* Requested Interface Unit */
Bool Multilink = 0;/* enable Multilink operation */
Char * bundle_name = NULL;/* bundle name for Multilink */
Bool dump_options;/* print out option values */
Bool dryrun;/* print out option values and exit */
Char * domain;/* domain name set by domain option */
Int child_wait = 5;/* # seconds to wait for children at exit */

3. Authentication script
Generally, authentication is required for PPP connections. There are two authentication methods: pap authentication and CHAP authentication. The username and password required for authentication are stored in the pap-secrets and chap-secrets scripts, as follows:
Username * Password
When authentication is required, the PPP module reads the user name and password from the pap-secrets and chap-secrets scripts by specifying the Authentication mode as PAP or chap in the options script, the authentication package appended to the PPP is sent to the server for authentication.

4. Relationship between the PPP dialing process and scripts
How can I work with pppd2.4.4 after the script is set successfully? This requires starting with the main function of the pppd program.
This process is as follows:
After the pppd program is started, the options script file will be searched according to the location specified in pathname. h. You can specify the file location as needed to ensure that pppd can locate the file accurately.
After the options file is found in pppd, the parameter lines are read in sequence. Here, you can obtain the device used by the system for networking and the device speed.
Pppd resolves the configured parameters to the global variable identifier in the program for pppd Connection Control.

Iii. Practice
The following are the options, chat, and pap-secrets scripts used for PPP connections on ft282.
Options:
Connect "/usr/bin/chat-v-T6-F/var/PPP/td-scdma_chat"
Ttyusb0
115200
Debug
Logfile/var/log/ppplog
MTU 1500
-Detach
Noauth
Noipdefault
Defaultroute
Usepeerdns
Crtscts
Lock
LCP-Echo-failure 4
-CCP
-VJ
-Chap
Mschap-v2
User
Hide-Password
Chat:
""
OK atdt * 98*1 #
Connect ""
Pap-secrets:
WAP * WAP
After testing on ft282, we found that the PPP connection was successful.

Iv. Performance Evaluation

5. Promotion suggestions
It has some reference value for the PPP network connection of mobile phones or access boxes.
References
1. PPP-HOWTO
2. PPP 2.4.4

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/linweig/archive/2010/04/02/5446429.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.