嵌入式 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

相关文章

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

嵌入式QT开发:构建高效智能的嵌入式系统

摘要: 本文深入探讨了嵌入式 QT 相关的各个方面。从 QT 框架的基础架构和核心概念出发,详细阐述了其在嵌入式环境中的优势与特点。文中分析了嵌入式 QT 的开发环境搭建过程,包括交叉编译工具链的配置等关键步骤。进一步探讨了嵌入式 QT 的界面设计与开发,涵盖了从基本控件的使用到复杂界面布局的构建。同时也深入研究了信号与槽机制在嵌入式系统中的应用,以及嵌入式 QT 与硬件设备的交互,包括输入输出设

OpenHarmony鸿蒙开发( Beta5.0)无感配网详解

1、简介 无感配网是指在设备联网过程中无需输入热点相关账号信息,即可快速实现设备配网,是一种兼顾高效性、可靠性和安全性的配网方式。 2、配网原理 2.1 通信原理 手机和智能设备之间的信息传递,利用特有的NAN协议实现。利用手机和智能设备之间的WiFi 感知订阅、发布能力,实现了数字管家应用和设备之间的发现。在完成设备间的认证和响应后,即可发送相关配网数据。同时还支持与常规Sof

读书摘录《控糖革命》

又到了每周推荐时间,这周末给大家推荐一本书《控糖革命》。身体是革命的本钱,只有保持健康的身体,才能保证持久的生产力,希望我的读者都可以身体健康,青春永驻。 推荐前,首先申明在《控糖革命》一书中,作者提出了一些颇具争议的观点,这些观点并没有经过系统的科学论证,但这并不妨碍我们从中获取一些有益的控糖建议。作者通过分享作者的个人经验和研究,为我们提供了一种全新的饮食理念,帮助我们更好地控制血糖峰值

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

【Prometheus】PromQL向量匹配实现不同标签的向量数据进行运算

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全栈,前后端开发,小程序开发,人工智能,js逆向,App逆向,网络系统安全,数据分析,Django,fastapi

让树莓派智能语音助手实现定时提醒功能

最初的时候是想直接在rasa 的chatbot上实现,因为rasa本身是带有remindschedule模块的。不过经过一番折腾后,忽然发现,chatbot上实现的定时,语音助手不一定会有响应。因为,我目前语音助手的代码设置了长时间无应答会结束对话,这样一来,chatbot定时提醒的触发就不会被语音助手获悉。那怎么让语音助手也具有定时提醒功能呢? 我最后选择的方法是用threading.Time

高效录音转文字:2024年四大工具精选!

在快节奏的工作生活中,能够快速将录音转换成文字是一项非常实用的能力。特别是在需要记录会议纪要、讲座内容或者是采访素材的时候,一款优秀的在线录音转文字工具能派上大用场。以下推荐几个好用的录音转文字工具! 365在线转文字 直达链接:https://www.pdf365.cn/ 365在线转文字是一款提供在线录音转文字服务的工具,它以其高效、便捷的特点受到用户的青睐。用户无需下载安装任何软件,只