嵌入式 PPPD工具实现3G拨号实践以及工具PPPD和CHAT详解摘录

2024-01-05 12:32

本文主要是介绍嵌入式 PPPD工具实现3G拨号实践以及工具PPPD和CHAT详解摘录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

PPPD:

1、我的平台:SIMCOM 5360E 中国联通3G

首先是WCDMA脚本:

root@njqy:/etc/ppp/peers# cat kj_wcdma
#/etc/ppp/peers/wcdma
#This is pppd script, used SIMCOM 5360(Union)
/dev/ttyUSB3
115200
crtscts
modem
debug
nodetach
usepeerdns
defaultroute
user "3gnet"
connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-connect-chat'
root@njqy:/etc/ppp/peers#

wcdma-connect-chat脚本:

root@njqy:/etc/ppp/peers# cat wcdma-connect-chat
#/etc/ppp/wcdma-connect-chat
TIMEOUT 5
ABORT "DELAYED"
ABORT "BUSY"
ABORT "ERROR"
ABORT "NO DIALTONE"
ABORT "NO CARRIER" #异常处理
#"AT
#'OK-+++\c-OK' ATH0

''      AT
OK     AT+CFUN=1 #实现基本的全功能模式
OK     AT+CNAOP=2 #设置为WCDMA
OK     AT+CNMP=14 #设置WCDMA模式
OK     AT+CGDCONT=1,"IP","3gnet",,0,0 #VPN服务器
OK     ATDT*99# #联通3G特殊号码
CONNECT    ''
root@njqy:/etc/ppp/peers#

2、PPPD在man中详解:

NAME

pppd - 点对点协议守护进程 

总览 SYNOPSIS

pppd [ tty_name ] [ speed ] [ options

描述

点对点协议 (PPP) 提供一种在点对点串列线路上传输资料流 (datagrams)的方法。PPP是由三个部份所组成的:一个在串列线路上封装(encapsulating)资料流的方法,一个可延伸的连结控制协定(LinkControlProtocol:LCP),以及一些用来建立并配置不同网路层协定的网路控制协定(NetworkControlProtocols:NCP)

封装的机制(scheme)是由核心中的驱动程式码来提供。pppd提供基本的LCP,验证(authentication)的支援,以及一个用来建立并配置网际网路协定(InternatProtocol(IP))(叫做IP控制协定,IPCP)的NCP。 

常用选项 FREQUENTLY USED OPTIONS

<tty_name>

在该名称的设备上进行通讯。如果需要的话可以前置一个 "/dev/"字串。如果没有给设备名称,pppd将会使用控制台的终端机(controllingteriminal),并且产生(fork)出来时将不会把自己放到背景去。
<speed>

将波特率设为speed。在像是4.4BSD以及NetBSA的系统上,可以指定任何速率。其他系统(e.g.SunOs)只允许有限的几种速率。
asyncmap <map>

把非同步(async)字元设为对照到。这个对照表描述哪些控制字元不能在串列线路上成功地接收。pppd将会要求彼端以两个位元组的逸出序列(escapesequence)来传送这些字元。其参数是32位元的十六进位数字而每个位元代表一个得避开(escape)的字元。位元0(00000001) 代表字元0x00;位元31(80000000)代表字元0x1f或是^_。如果给了多个asyncmap选项,这些数值会以逻辑的或(OR)合在一起。如果没有给asyncmap选项,将没有非同步字元对照表会被加以协商来导引接收。这样彼端将会避开所有的控制字元。
auth
要求彼端在允许传送或接收网路封包之前先验证它自己。 This option is the default if the system has a default route. If neither this option nor the noauth option is specified, pppd will only allow the peer to use IP addresses to which the system does not already have a route.
call name
Read options from the file /etc/ppp/peers/name. This file may contain privileged options, such as noauth, even if pppd is not being run by root. The name string may not begin with / or include .. as a pathname component. The format of the options file is described below.
connect script

使用以所指定的可执行指令或是shell指令来设定串列线路。这个指令稿一般会使用"chat"程式来拨数据机并开始远端ppp区段作业(session)。 A value for this option from a privileged source cannot be overridden by a non-privileged user.
crtscts
使用硬体流量控制(i.e.RTS/CTS)来控制串列埠上的资料流。 If neither the crtscts, thenocrtscts, the cdtrcts nor the nocdtrcts option is given, the hardware flow control setting for the serial port is left unchanged. Some serial ports (such as Macintosh serial ports) lack a true RTS output. Such serial ports use this mode to implement unidirectional flow control. The serial port will suspend transmission when requested by the modem (via CTS) but will be unable to request the modem stop sending to the computer. This mode retains the ability to use DTR as a modem control line.
defaultroute

当IPCP协商完全成功时,增加一个预设递送路径到系统的递送表,将彼端当作闸道器使用。这个项目在ppp连线中断後会移除。
disconnect script

在pppd已经终结该连线之後执行以所指定的可执行指令或是shell指令。这个指令稿可以用来,例如,如果硬体的数据机控制信号无法使用时,发出指令给数据机使其挂断电话。 The disconnect script is not run if the modem has already hung up. A value for this option from a privileged source cannot be overridden by a non-privileged user.
escape xx,yy,...

指定在传输上确实应该要避开的字元(不管对方是否有用它的非同步控制字元对照表要求避开它们)。这些要被避开的字元是以用逗号隔开的一串十六进位数字指定的。要注意到几乎任何字元都可以用escape选项指定避开,不像asyncmap选项只允许指定控制字元。不能避开的字元是那些有十六进位值0x20-0x3f或是0x5e者。
file name

从档案里读取选项(其格式叙述在後) The file must be readable by the user who has invoked pppd.
init script
Run the executable or shell command specified by script to initialize the serial line. This script would typically use the chat(8) program to configure the modem to enable auto answer. A value for this option from a privileged source cannot be overridden by a non-privileged user.
lock
指定pppd应该在此串列设备上使用UUCP式的锁定以确定对该设备为互斥(exclusive)存取。
mru n
把MRU[MaximumReceiveUnit最大接收单元]的值设为 n来进行协商。pppd将会要求彼端传送不比位元组更长的封包。最小的MRU值是128。预设的MRU值则是 1500。对於慢速线路上的建议值是296(其中40个位元组给TCP/IP表头+256个位元组的资料)。
(Note that for IPv6 MRU must be at least 1280)
mtu n

将MTU[MaximumTransmitUnit最大传输单元]的值设为n。除非彼端经由MRU协商要求一个更小的值,pppd 将会要求核心网路程式码透过PPP网路界面所传送的资料封包不超过n个位元组。
(Note that for IPv6 MTU must be at least 1280)
passive

在LCP中开启"passive"选项。加上这个选项,pppd将会试图初使一个连线;如果没有从彼端接收到回应,那麽 pppd将只会被动地等待从彼端所传来的一个有效LCP封包(代替结束离开,就像它在没有这个选项时所作的)。

选项 OPTIONS

<local_IP_address>:<remote_IP_address>

设定本地以及/或是远端界面的IP位址。两者之中的任何一个都可以省略。该IP位址可以利用主机名称或者是十进位数值加小数点符号指定(e.g.150.234.56.78)。预设的本地位址是系统的(第一个)IP位址(除非有加上 noipdefault选项)。远端位址如果没有在任何选项中指定的话将从彼端取得。因此,在简单的案例中,这个选项不是必须的。如果有一个本地以及/或是远端的IP位址以这个选项加以指定的话,pppd将不会接受在IPCP协商中从彼端所传来不同的值,除非加上ipcp-accept-local 以及/或是ipcp-accept-remote选项,个别地。
ipv6 <local_interface_identifier>,<remote_interface_identifier>
Set the local and/or remote 64-bit interface identifier. Either one may be omitted. The identifier must be specified in standard ascii notation of IPv6 addresses (e.g. ::dead:beef). If the ipv6cp-use-ipaddr option is given, the local identifier is the local IPv4 address (see above). On systems which supports a unique persistent id, such as EUI-48 derived from the Ethernet MAC address, ipv6cp-use-persistent option can be used to replace the ipv6 <local>,<remote> option. Otherwise the identifier is randomized.
active-filter filter-expression
Specifies a packet filter to be applied to data packets to determine which packets are to be regarded as link activity, and therefore reset the idle timer, or cause the link to be brought up in demand-dialling mode. This option is useful in conjunction with the idle option if there are packets being sent or received regularly over the link (for example, routing information packets) which would otherwise prevent the link from ever appearing to be idle. The filter-expression syntax is as described for tcpdump(1), except that qualifiers which are inappropriate for a PPP link, such asether and arp, are not permitted. Generally the filter expression should be enclosed in single-quotes to prevent whitespace in the expression from being interpreted by the shell. This option is currently only available under NetBSD, and then only if both the kernel and pppd were compiled with PPP_FILTER defined.
allow-ip address(es)
Allow peers to use the given IP address or subnet without authenticating themselves. The parameter is parsed as for each element of the list of allowed IP addresses in the secrets files (see the AUTHENTICATION section below).
bsdcomp nr,nt
Request that the peer compress packets that it sends, using the BSD-Compress scheme, with a maximum code size of nr bits, and agree to compress packets sent to the peer with a maximum code size of nt bits. If nt is not specified, it defaults to the value given for nr. Values in the range 9 to 15 may be used for nr and nt; larger values give better compression but consume more kernel memory for compression dictionaries. Alternatively, a value of 0 for nr or nt disables compression in the corresponding direction. Use nobsdcomp or bsdcomp 0 to disable BSD-Compress compression entirely.
cdtrcts
Use a non-standard hardware flow control (i.e. DTR/CTS) to control the flow of data on the serial port. If neither the crtscts, the nocrtscts, the cdtrcts nor thenocdtrcts option is given, the hardware flow control setting for the serial port is left unchanged. Some serial ports (such as Macintosh serial ports) lack a true RTS output. Such serial ports use this mode to implement true bi-directional flow control. The sacrifice is that this flow control mode does not permit using DTR as a modem control line.
chap-interval n

如果有给这个选项,pppd将会每n 秒重新盘查彼端。
chap-max-challenge n

将CHAP盘查(challenge)传输的最大数目设为n(预设为10)。
chap-restart n

将CHAP重新开始的间隔(重新传输的时间限制)设为n 秒钟(预设为3)。
connect-delay n
Wait for up n milliseconds after the connect script finishes for a valid PPP packet from the peer. At the end of this time, or when a valid PPP packet is received from the peer, pppd will commence negotiation by sending its first LCP packet. The default value is 1000 (1 second). This wait period only applies if the connect or ptyoption is used.
debug
递增侦错层级(与-d相同)。如果加上这个选项,pppd 将以可供阅读的格式记录所有传送或接收的控制封包内容。这些封包透过syslog以facilitydaemon还有level debug加以记录。该资讯可以适当设定/etc/syslog.conf 来导向到一个档案去。(参阅syslog.conf(5))。(如果 pppd以开启扩充侦错(extradebugging)编译的话,它将会使用facilitylocal2取代daemon来记录讯息)。
default-asyncmap
Disable asyncmap negotiation, forcing all control characters to be escaped for both the transmit and the receive direction.
default-mru
Disable MRU [Maximum Receive Unit] negotiation. With this option, pppd will use the default MRU value of 1500 bytes for both the transmit and receive direction.
deflate nr,nt
Request that the peer compress packets that it sends, using the Deflate scheme, with a maximum window size of 2**nr bytes, and agree to compress packets sent to the peer with a maximum window size of 2**nt bytes. If nt is not specified, it defaults to the value given for nr. Values in the range 9 to 15 may be used for nr and nt; larger values give better compression but consume more kernel memory for compression dictionaries. Alternatively, a value of 0 for nr or nt disables compression in the corresponding direction. Use nodeflate or deflate 0 to disable Deflate compression entirely. (Note: pppd requests Deflate compression in preference to BSD-Compress if the peer can do either.)
demand
Initiate the link only on demand, i.e. when data traffic is present. With this option, the remote IP address must be specified by the user on the command line or in an options file. Pppd will initially configure the interface and enable it for IP traffic without connecting to the peer. When traffic is available, pppd will connect to the peer and perform negotiation, authentication, etc. When this is completed, pppd will commence passing data packets (i.e., IP packets) across the link.

The demand option implies the persist option. If this behaviour is not desired, use the nopersist option after the demand option. The idle and holdoff options are also useful in conjuction with the demand option.

domain d

新增领域名称到本地主机名称以支援验证。例如,如果gethostname()回应porsche这个名称,但是完整合格的领域名称是porsche.Quotron.COM的话,你可以使用 domain选项来将领域名称设为Quotron.COM。
Pppd would then use the name porsche.Quotron.COM for looking up secrets in the secrets file, and as the default name to send to the peer when authenticating itself to the peer. This option is privileged.
dryrun
With the dryrun option, pppd will print out all the option values which have been set and then exit, after parsing the command line and options files and checking the option values, but before initiating the link. The option values are logged at level info, and also printed to standard output unless the device on standard output is the device that pppd would be using to communicate with the peer.
dump
With the dump option, pppd will print out all the option values which have been set. This option is like the dryrun option except that pppd proceeds as normal rather than exiting.
endpoint <epdisc>
Sets the endpoint discriminator sent by the local machine to the peer during multilink negotiation to <epdisc>. The default is to use the MAC address of the first ethernet interface on the system, if any, otherwise the IPv4 address corresponding to the hostname, if any, provided it is not in the multicast or locally-assigned IP address ranges, or the localhost address. The endpoint discriminator can be the string null or of the form type:value, where type is a decimal number or one of the strings local, IP, MAC, magic, or phone. The value is an IP address in dotted-decimal notation for the IP type, or a string of bytes in hexadecimal, separated by periods or colons for the other types. For the MAC type, the value may also be the name of an ethernet or similar network interface. This option is currently only available under Linux.
hide-password
When logging the contents of PAP packets, this option causes pppd to exclude the password string from the log. This is the default.
holdoff n
Specifies how many seconds to wait before re-initiating the link after it terminates. This option only has any effect if the persist or demand option is used. The holdoff period is not applied if the link was terminated because it was idle.
idle n
Specifies that pppd should disconnect if the link is idle for n seconds. The link is idle when no data packets (i.e. IP packets) are being sent or received. Note: it is not advisable to use this option with the persist option without the demand option. If the active-filter option is given, data packets which are rejected by the specified activity filter also count as the link being idle.
ipcp-accept-local
加上这个选项的话,pppd将会接受彼端对於本地IP位址的意见,即使本地的IP位址已经在某个选项中指定。
ipcp-accept-remote
加上这个选项的话,pppd将会接受彼端对於它的IP位址的意见,即使远端的IP位址已经在某个选项中指定。
ipcp-max-configure n

将IPCP配置要求(configure-request)传输的最大数目设为n(预设为10)。
ipcp-max-failure n
将开始传送配置拒绝(configure-Rejects)之前的IPCP配置未接收(configure-NAKs)的最大数目以取代n(预设为10)。
ipcp-max-terminate n

将IPCP终结要求(terminate-request)传输的最大数目设为 n(预设为3)。
ipcp-restart n

将IPCP重新开始的间隔(重新传输的时间限制)设为n 秒钟(预设为3)。

这篇关于嵌入式 PPPD工具实现3G拨号实践以及工具PPPD和CHAT详解摘录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/572878

相关文章

使用Java解析JSON数据并提取特定字段的实现步骤(以提取mailNo为例)

《使用Java解析JSON数据并提取特定字段的实现步骤(以提取mailNo为例)》在现代软件开发中,处理JSON数据是一项非常常见的任务,无论是从API接口获取数据,还是将数据存储为JSON格式,解析... 目录1. 背景介绍1.1 jsON简介1.2 实际案例2. 准备工作2.1 环境搭建2.1.1 添加

Oracle的to_date()函数详解

《Oracle的to_date()函数详解》Oracle的to_date()函数用于日期格式转换,需要注意Oracle中不区分大小写的MM和mm格式代码,应使用mi代替分钟,此外,Oracle还支持毫... 目录oracle的to_date()函数一.在使用Oracle的to_date函数来做日期转换二.日

Java实现任务管理器性能网络监控数据的方法详解

《Java实现任务管理器性能网络监控数据的方法详解》在现代操作系统中,任务管理器是一个非常重要的工具,用于监控和管理计算机的运行状态,包括CPU使用率、内存占用等,对于开发者和系统管理员来说,了解这些... 目录引言一、背景知识二、准备工作1. Maven依赖2. Gradle依赖三、代码实现四、代码详解五

java如何分布式锁实现和选型

《java如何分布式锁实现和选型》文章介绍了分布式锁的重要性以及在分布式系统中常见的问题和需求,它详细阐述了如何使用分布式锁来确保数据的一致性和系统的高可用性,文章还提供了基于数据库、Redis和Zo... 目录引言:分布式锁的重要性与分布式系统中的常见问题和需求分布式锁的重要性分布式系统中常见的问题和需求

SpringBoot基于MyBatis-Plus实现Lambda Query查询的示例代码

《SpringBoot基于MyBatis-Plus实现LambdaQuery查询的示例代码》MyBatis-Plus是MyBatis的增强工具,简化了数据库操作,并提高了开发效率,它提供了多种查询方... 目录引言基础环境配置依赖配置(Maven)application.yml 配置表结构设计demo_st

python使用watchdog实现文件资源监控

《python使用watchdog实现文件资源监控》watchdog支持跨平台文件资源监控,可以检测指定文件夹下文件及文件夹变动,下面我们来看看Python如何使用watchdog实现文件资源监控吧... python文件监控库watchdogs简介随着Python在各种应用领域中的广泛使用,其生态环境也

el-select下拉选择缓存的实现

《el-select下拉选择缓存的实现》本文主要介绍了在使用el-select实现下拉选择缓存时遇到的问题及解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录项目场景:问题描述解决方案:项目场景:从左侧列表中选取字段填入右侧下拉多选框,用户可以对右侧

Mysql 中的多表连接和连接类型详解

《Mysql中的多表连接和连接类型详解》这篇文章详细介绍了MySQL中的多表连接及其各种类型,包括内连接、左连接、右连接、全外连接、自连接和交叉连接,通过这些连接方式,可以将分散在不同表中的相关数据... 目录什么是多表连接?1. 内连接(INNER JOIN)2. 左连接(LEFT JOIN 或 LEFT

Java中switch-case结构的使用方法举例详解

《Java中switch-case结构的使用方法举例详解》:本文主要介绍Java中switch-case结构使用的相关资料,switch-case结构是Java中处理多个分支条件的一种有效方式,它... 目录前言一、switch-case结构的基本语法二、使用示例三、注意事项四、总结前言对于Java初学者

Linux内核之内核裁剪详解

《Linux内核之内核裁剪详解》Linux内核裁剪是通过移除不必要的功能和模块,调整配置参数来优化内核,以满足特定需求,裁剪的方法包括使用配置选项、模块化设计和优化配置参数,图形裁剪工具如makeme... 目录简介一、 裁剪的原因二、裁剪的方法三、图形裁剪工具四、操作说明五、make menuconfig