在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 在ARM+LINUX上使用pppd拔號上網(wǎng)(GPRS)流程

            在ARM+LINUX上使用pppd拔號上網(wǎng)(GPRS)流程

            作者: 時間:2016-11-09 來源:網(wǎng)絡 收藏
            我的編程環(huán)境是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中動態(tài)加載:
            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與連接網(wǎng)絡過程,
            1) ppp2.4.4 源碼編譯過程

            本文引用地址:http://www.biyoush.com/article/201611/317924.htm

            #./configure

            #make CC=arm-linux-gcc 注意指定arm-linux-gcc的路徑,或是直接用絕對路徑指定

            需要拷貝到ARM目標板的文件有:
            pppd
            pppdump
            pppstatus
            chat
            2 ) 腳本準備
            有4個腳本需要準備,一個是規(guī)則文件/etc/ppp/gprs-connect-chat,一個是參數(shù)文件/etc/ppp/peers/gprs, 還有認證文件:pap-secret和chap-secret。(其實我這里只用到了pap-secret, 至于chap-secret 沒有有到。anyhow,把它們全創(chuàng)建上)
            (1) 腳本 #gprs-connect-chat:
            TIMEOUT 15
            ABORT nBUSYr
            ABORT nNO ANSWERr
            ABORT nRINGINGrnrnRINGINGr
            # 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網(wǎng)
            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根據(jù)需要來改
            /etc/ppp # cat pap-secrets
            # Secrets for authentication using PAP
            # client server secret IP addresses
            cmnet * cmnet *
            (4) 認證文件 chap-secrets 根據(jù)需要來修改,現(xiàn)在暫時沒用到
            /etc/ppp # cat chap-secrets
            # Secrets for authentication using CHAP
            # client server secret IP addresses
            * *

            3) 調用過程
            ifconfig eth0 down //先關閉有線網(wǎng)卡,以免與拔號初始化沖突
            /etc/ppp/pppd call gprs& //啟動/etc/ppp/peers/gprs腳本
            ifconfig eth0 up //重新開有線網(wǎng)卡
            來看連接的顯示日志內容:
            /etc/ppp # ./pppd call gprs&
            /etc/ppp # timeout set to 15 seconds
            abort on (nBUSYr)
            abort on (nNO ANSWERr)
            abort on (nRINGINGrnrnRINGINGr)
            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) 查看網(wǎng)絡設置與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下創(chuàng)建軟鏈接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域名的現(xiàn)象
            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下??梢詐ing域名啦
            /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) 如何實現(xiàn)拔號與中國聯(lián)通的3G 聯(lián)網(wǎng)?
            換用TELIT公司的UC864-E, 使用USB連接方式。指定串口為ttyUSB0
            對于ppp方面,只需要更改4個腳本中的少量內容
            a. 更改options腳本
            把gprsoptions更名為g3options, 把里面的這一行參數(shù)/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 nBUSYr
            ABORT nNO ANSWERr
            ABORT nRINGINGrnrnRINGINGr
            # AT
            #OK-+++c-OK ATH0
            TIMEOUT 40
            rAT
            OK AT+FLO=0
            OK ATS0=0
            OK ATE0V1
            OK AT+CGDCONT=1,"IP","UNINET"#UNINET是代表中國聯(lián)通網(wǎng)的意思
            #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 * #如果是中國聯(lián)通3G就用uninet

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



            關鍵詞: ARMLINUXpppd拔號上

            評論


            技術專區(qū)

            關閉