贴一个,gprs无线上网的配置方法,希望对大家有帮助!

CPU/显卡/打印机/USB设备等硬件问题
回复
头像
zhouzhanlun
帖子: 50
注册时间: 2005-07-16 4:06

贴一个,gprs无线上网的配置方法,希望对大家有帮助!

#1

帖子 zhouzhanlun » 2005-07-27 18:26

Linux下拨号采用的是PPP协议,这与windows是一致的.
只是windows下采用拨号程序对协议用图形化界面加以封装,因此我们在拨号时不易察觉.
而在Linux下,采利用的是pppd程序,因此较windows而言能理解的更清楚.
Linux下的GUI拨号程序是KPPP,其实也是将pppd加以封装而已.

在Linux下拨号采用的脚本为ppp-on,ppp-on-dialer,ppp-off
在默认安装的RH9下可以在/usr/share/doc/ppp/script下找到这三个脚本

这三个脚本原本是用来为普通的调制解调器作拨号脚本的,
我们可以利用这三个脚本做一定的修改,即可实现ppp拨号GPRS上网.

拨号原理为:
初始化模块,主要是设定APN:CMNET
at+cgdcont=1,ip,cmnet
然后利用chat程序拨号*99***1#
待拨号连接成功后,由pppd将建立通信链路即可.

脚本改动如下:
在ppp-on里改了电话号码为*99***1#
将账号与密码清除,
改了DIALER_SCRIPT的路径
把下面的设备改成/dev/ttyS0,速率改为19200
将crtscts参数去掉,
  
在ppp-on-dialer里把帐号密码去掉

改动后的脚本如下:
#!/bin/sh
#
# Script to initiate a ppp connection. This is the first part of the
# pair of scripts. This is not a secure pair of scripts as the codes
# are visible with the 'ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE=*99***1# # The telephone number for the connection
ACCOUNT= # The account name for logon (as in 'George Burns')
PASSWORD= # The password for this account (and 'Gracie Allen')
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK=255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at 'ppp-on-dialer' time.
export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# in. Please use the absolute file name as the $PATH variable is not
# used on the connect option. (To do so on a 'root' account would be
# a security hole so don't ask.)
#
DIALER_SCRIPT=/home/testBoot/ppp/ppp-on-dialer
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# forget the 'lock' option or some programs such as mgetty will not
# work. The asyncmap and escape will permit the PPP link to work with
# a telnet or rlogin connection. You are welcome to make any changes
# as desired. Don't use the 'defaultroute' option if you currently
# have a default route to an ethernet gateway.
#
exec /usr/sbin/pppd debug lock nocrtscts modem /dev/ttyS0 19200 \
asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \
noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT


在改动完成后,执行脚本ppp-on
./ppp-on
即可拨号上网

如要自己写程序来执行此脚本的话,则利用EXEC函数即可,至于EXEC的具体用法,可参阅C函数的说明书
有一点要提醒的是,在利用EXEC的时候,原进程会湮灭,而只有所执行程序的进行在运行,因此,如果想保留原进程,我采用的方法是利用fork函数,在子进程中执行脚本,而在父进程中执行自己的程序即可
HP compaq nx9040(PK160PA-AB2)
Intel Pentium M(Dothan) 725(1.6G)
DDR 512M
Intel Extreme2
E-mail:8666@vip.sohu.com
cately
帖子: 51
注册时间: 2005-07-19 11:23
来自: 广州

#2

帖子 cately » 2005-10-07 14:41

真是谢谢 这个非常有用 全收了
adwindy
帖子: 51
注册时间: 2007-12-12 19:09
联系:

#3

帖子 adwindy » 2008-03-26 20:29

初始化模块,主要是设定APN:CMNET
怎么初始化?我看了都不知道怎么做。
回复