您的位置 首页 培训

在ARM+LINUX上运用pppd拔号上网(GPRS)流程

我的编程环境是vmware+fedora9,ARM目标板为ATMEL9G45,LINUX内核2.6.30,GPRS模块为TELIT公司的GC864-DUAL-V2,使用3线制串口连…

我的编程环境是vmware + fedora9, ARM方针板为ATMEL 9G45,LINUX内核2.6.30, GPRS模块为TELIT公司的GC864-DUAL-V2,运用3线制串口衔接(TXD RXD GND)

1.修正2.6.30内核选项,
make menuconfig
Device drivers -> Networking device support -> PPP(point to point protocol) support
我选了以下模块(以M方法即module方法)
PPP support for async serial ports
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
SLIP(serial line) support
之后编译:make && make install && make modules && make modules_install
得到了几个ko方法的内核库文件,复制它们到ARM方针板上,并在/etc/init.d/rcS中动态加载:
insmod /etc/ppp/slhc.ko
insmod /etc/ppp/ppp_generic.ko
insmod /etc/ppp/ppp_async.ko
insmod /etc/ppp/ppp_synctty.ko
insmod /etc/ppp/ppp_deflate.ko
insmod /etc/ppp/bsd_comp.ko
insmod /etc/ppp/slip.ko
留意加载次序,我记得好象有必要把slhc.ko先加载

2. 移植ppp与衔接网络进程,
1) ppp2.4.4 源码编译进程

#./configure

#make CC=arm-linux-gcc 留意指定arm-linux-gcc的途径,或是直接用绝对途径指定

需求复制到ARM方针板的文件有:
pppd
pppdump
pppstatus
chat
2 ) 脚本预备
有4个脚本需求预备,一个是规矩文件/etc/ppp/gprs-connect-chat,一个是参数文件/etc/ppp/peers/gprs, 还有认证文件:pap-secret和chap-secret。(其实我这儿只用到了pap-secret, 至于chap-secret 没有有到。anyhow,把它们全创立上)
(1) 脚本 #gprs-connect-chat:
TIMEOUT 15
ABORT \nBUSY\r
ABORT \nNO ANSWER\r
ABORT \nRINGING\r\n\r\nRINGING\r
# AT
#OK-+++\c-OK ATH0
TIMEOUT 40
\rAT
OK AT+FLO=0#这个是GC864-DUAL-V2特别要设置的,便是要封闭流控
OK ATS0=0
OK ATE0V1
OK AT+CGDCONT=1,”IP”,”CMNET” #衔接我国移动cmnet网
OK ATDT*99*1#
CONNECT
(2) 脚本gprsoptions
#/etc/ppp/peers/gprsoptions
# Usage: root>pppd call gprsoptions
/dev/ttyS4
115200
nocrtscts
modem
#noauth
#auth
#-pap
#+chap
lock
debug
nodetach
#hide-password
usepeerdns
noipdefault
defaultroute
user cmnet
#user smsong
0.0.0.0:0.0.0.0
ipcp-accept-local
#ipcp-accept-remote
#lcp-echo-failure 12
#lcp-echo-interval 3
noccp
#novj
#novjccomp
persist
connect /etc/ppp/chat -s -v -f /etc/ppp/gprs-connect-chat
(3) 认证文件pap-secrets根据需求来改
/etc/ppp # cat pap-secrets
# Secrets for authentication using PAP
# client server secret IP addresses
cmnet * cmnet *
(4) 认证文件 chap-secrets 根据需求来修正,现在暂时没用到
/etc/ppp # cat chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
* *

3) 调用进程
ifconfig eth0 down //先封闭有线网卡,以免与拔号初始化抵触
/etc/ppp/pppd call gprs& //发动/etc/ppp/peers/gprs脚本
ifconfig eth0 up //从头开有线网卡
来看衔接的显现日志内容:
/etc/ppp # ./pppd call gprs&
/etc/ppp # timeout set to 15 seconds
abort on (\nBUSY\r)
abort on (\nNO ANSWER\r)
abort on (\nRINGING\r\n\r\nRINGING\r)
timeout set to 40 seconds
send (^MAT^M)
expect (OK)
AT^M^M
OK
— got it

send (AT+FLO=0^M)
expect (OK)
^M
AT+FLO=0^M^M
OK
— got it

send (ATS0=0^M)
expect (OK)
^M
ATS0=0^M^M
OK
— got it

send (ATE0V1^M)
expect (OK)
^M
ATE0V1^M^M
OK
— got it

send (AT+CGDCONT=1,”IP”,”CMNET”^M)
expect (OK)
^M
^M
OK
— got it

send (ATDT*99*1#^M)
expect (CONNECT)
^M
^M
CONNECT
— got it

send (^M)
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS4
Warning – secret file /etc/ppp/pap-secrets has world and/or group access
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfAck id=0x1 ]
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
Warning – secret file /etc/ppp/pap-secrets has world and/or group access
sent [PAP AuthReq id=0x1 user=”cmnet” password=]
rcvd [PAP AuthAck id=0x1 “Welcome!”]
Remote message: Welcome!
PAP authentication succeeded
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x1 ]
sent [IPCP ConfAck id=0x1 ]
rcvd [IPCP ConfRej id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfNak id=0x2 ]
sent [IPCP ConfReq id=0x3 ]
rcvd [IPCP ConfAck id=0x3 ]
local IP address 10.176.120.186
remote IP address 192.168.202.0
primary DNS address 218.201.96.130
secondary DNS address 211.137.191.26

4) 检查网络设置与ping试验
/etc/ppp # ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

ppp0 Link encap:Point-to-Point Protocol
inet addr:10.176.120.186 P-t-P:192.168.202.0 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:64 (64.0 B) TX bytes:82 (82.0 B)
来ping 一下看看
/etc/ppp # ping www.163.com -c 3
PING www.163.com (221.204.240.161): 56 data bytes
64 bytes from 221.204.240.161: seq=0 ttl=46 time=466.873 ms
64 bytes from 221.204.240.161: seq=1 ttl=46 time=435.762 ms
64 bytes from 221.204.240.161: seq=2 ttl=46 time=414.000 ms

— www.163.com ping statistics —
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 414.000/438.878/466.873 ms

3.其它问题

1 ) 设置DNS地址
/etc/ppp 下会由拔号主动发生resolv.conf 文件, 但它和 /etc/resolv.conf 并不是同一个文件,所以有的时分不能解析DNS。
一个好办法是,首要确保存在/etc/resolv.conf, 然后在/etc/ppp下创立软链接ln -s /etc/ppp/resolv.conf /etc/resolv.conf
这样在拔号成功后,在/etc/resolv.conf中会有相似以下内容:
nameserver 218.201.96.130
nameserver 211.137.191.26
2) 只能ping IP地址,不能ping域名的现象
busybox的指令协助页面有这样一段话:
引证:
LIBC NSS
When used with glibc, the BusyBox networking applets will similarly require that you install at least some of the glibc NSS stuff (in particular, /etc/nsswitch.conf, /lib/libnss_dns*, /lib/libnss_files*, and /lib/libresolv*).
所以把arm-linux东西链的lib目录下的 libnss_dns* , libnss_files* , libresolv* 复制到ARM方针板的/lib下。能够ping域名啦
/etc/ppp # ping www.163.com
PING www.163.com (221.204.240.161): 56 data bytes
64 bytes from 221.204.240.161: seq=0 ttl=46 time=641.269 ms
64 bytes from 221.204.240.161: seq=1 ttl=46 time=435.801 ms
64 bytes from 221.204.240.161: seq=2 ttl=46 time=446.776 ms
64 bytes from 221.204.240.161: seq=3 ttl=46 time=381.381 ms
64 bytes from 221.204.240.161: seq=4 ttl=46 time=468.495 ms

— www.163.com ping statistics —
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 381.381/474.744/641.269 ms

3) 怎么完成拔号与我国联通的3G 联网?
换用TELIT公司的UC864-E, 运用USB衔接方法。指定串口为ttyUSB0
关于ppp方面,只需求更改4个脚本中的少数内容
a. 更改options脚本
把gprsoptions更名为g3options, 把里边的这一行参数/dev/ttyS4 更改为/dev/ttyUSB0,
把connect /etc/ppp/chat -s -v -f /etc/ppp/gprs-connect-chat
更改为connect /etc/ppp/chat -s -v -f/etc/ppp/g3-connect-chat
b. 更改chat脚本
TIMEOUT 15
ABORT \nBUSY\r
ABORT \nNO ANSWER\r
ABORT \nRINGING\r\n\r\nRINGING\r
# AT
#OK-+++\c-OK ATH0
TIMEOUT 40
\rAT
OK AT+FLO=0
OK ATS0=0
OK ATE0V1
OK AT+CGDCONT=1,”IP”,”UNINET”#UNINET是代表我国联通网的意思
#OK AT+CGDCONT=1,”IP”,”CMNET”
OK ATDT*99*1#
CONNECT
c. 更改pap-secrets
# Secrets for authentication using PAP
# client server secret IP addresses
#cmnet * cmnet * #如果是我国移动GPRS就用cmnet
uninet * uninet * #如果是我国联通3G就用uninet

d. 更改chap-secrets
同上pap-secrets

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/peixun/277182.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部