Setting up the PPP connection

PPP is a data layer communication protocol that is established through the serial port of the modem. These Serial port communications could be either the UART(/dev/ttyS0) or the serial exposed to USB(/dev/ttyUSB3). This serial is also used for both modem commands (AT commands) and responses. This connection is established by dial-up (ATD*99#).

PPP is easy to establish, widely used protocol, and it is flexible with the devices. PPP may show a drop of the connection while using the AT command set for other functionality of modem. The PPP protocol is just used between the computer and the modem to make the connection look like a legacy dial-up modem-based network connection.

Hardware Setup

It is important to properly setup your hardware before you get started. To setup the hardware please follow:

Each of these Shields/HATs can be connected to the Internet via PPP(Point to Point Protocol). For this tutorial, we have developed a script to install and perform the required steps.

Without further ado let us jump into the installation process.

Software Setup

⚙️ Module Configuration

Before running the PPP/QMI make sure the module is configured to the right settings.
For Quectel Modules:
AT+QCFG="usbnet" should return 0, otherwise,send AT+QCFG="usbnet",0 then reboot the module after 10 seconds with AT+CFUN=1,1

For Telit Modules:
AT#USBCFG? should return 0, otherwise,send AT#USBCFG=0 then reboot the module after 10 seconds with AT#REBOOT

For sending AT commands, you may check the Sending AT Commands tutorial.

Clone the repository, change it into the directory, and change the permission of the installation script. Then install it.

git clone https://github.com/sixfab/Sixfab_PPP_Installer.git 
cd Sixfab_PPP_Installer 
chmod +x ppp_install.sh
sudo ./ppp_install.sh

During the installation, the user will need to answer several questions, in order to complete the installation process. The questions are:

Please choose your Sixfab Shields/HATs
You will be offered to choose among the mentioned shields/HATs. Then it will fetch the required scripts for you.

pi@raspberrypi:~ $ sudo ./install.sh Please choose your Sixfab Shield/HAT: 1: GSM/GPRS Shield 2: 3G, 4G/LTE Base Shield 3: Cellular IoT App Shield 4: Cellular IoT HAT 5: Tracker HAT 6: 3G/4G Base HAT

What is your carrier APN?
It will then ask for APN. Type in your APN and then press ENTER. For Sixfab SIM, it is super.

pi@raspberrypi:~ $ sudo ./install.sh Checking requirements... Updating headers... Get:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB] ... Reading package lists... Done Copying setup files... ppp installing... Reading package lists... Done Building dependency tree... Done Reading state information... Done ... Selecting previously unselected package ppp. Preparing to unpack .../ppp_2.4.9-1+1_armhf.deb ... Unpacking ppp (2.4.9-1+1) ... What is your carrier APN? super

Does your carrier need username and password?

pi@raspberrypi:~ $ sudo ./install.sh Checking requirements... Updating headers... Get:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB] ... Reading package lists... Done Copying setup files... ppp installing... Reading package lists... Done Building dependency tree... Done Reading state information... Done ... Selecting previously unselected package ppp. Preparing to unpack .../ppp_2.4.9-1+1_armhf.deb ... Unpacking ppp (2.4.9-1+1) ... What is your carrier APN? super Does your carrier need username and password? [Y/n] n

Enter your communication PORT name
In this step, you will enter your PORT.

Selecting Port

Note: To use the UART(ttyS0) follow the steps mentioned in the UART guide.
pi@raspberrypi:~ $ sudo ./install.sh Checking requirements... Updating headers... Get:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB] ... Reading package lists... Done Copying setup files... ppp installing... Reading package lists... Done Building dependency tree... Done Reading state information... Done ... Selecting previously unselected package ppp. Preparing to unpack .../ppp_2.4.9-1+1_armhf.deb ... Unpacking ppp (2.4.9-1+1) ... What is your carrier APN? super Does your carrier need username and password? [Y/n] n What is your device communication PORT? (ttyS0/ttyUSB3/etc.) ttyUSB3

Do you want to activate auto-connect/reconnect service at Raspberry Pi boot up?
This option allows you to connect to the Internet via your HAT automatically when your Raspberry Pi starts.

pi@raspberrypi:~ $ sudo ./install.sh Checking requirements... Updating headers... Get:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB] ... Reading package lists... Done Copying setup files... ppp installing... Reading package lists... Done Building dependency tree... Done Reading state information... Done ... Selecting previously unselected package ppp. Preparing to unpack .../ppp_2.4.9-1+1_armhf.deb ... Unpacking ppp (2.4.9-1+1) ... What is your carrier APN? super Does your carrier need username and password? [Y/n] n What is your device communication PORT? (ttyS0/ttyUSB3/etc.) ttyUSB3 To connect to internet run "sudo pon" and to disconnect run "sudo poff" Press ENTER key to reboot

If you want to connect to the Internet automatically type y or N. If you have selected N then you will need to run sudo pon to connect to the internet and sudo poff to stop it. Make sure your module is powered up.

pi@raspberrypi:~ $ sudo pon pppd options in effect: debug # (from /etc/ppp/peers/provider) updetach # (from /etc/ppp/peers/provider) persist # (from /etc/ppp/peers/provider) dump # (from /etc/ppp/peers/provider) noauth # (from /etc/ppp/peers/provider) remotename 3gppp # (from /etc/ppp/peers/provider) /dev/ttyUSB3 # (from /etc/ppp/peers/provider) 115200 # (from /etc/ppp/peers/provider) lock # (from /etc/ppp/peers/provider) connect chat -s -v -f /etc/chatscripts/chat-connect -T super # (from /etc/ppp/peers/provider) disconnect chat -s -v -f /etc/chatscripts/chat-disconnect # (from /etc/ppp/peers/provider) nocrtscts # (from /etc/ppp/peers/provider) modem # (from /etc/ppp/peers/provider) asyncmap 0 # (from /etc/ppp/options) lcp-echo-failure 4 # (from /etc/ppp/options) lcp-echo-interval 30 # (from /etc/ppp/options) hide-password # (from /etc/ppp/peers/provider) novj # (from /etc/ppp/peers/provider) novjccomp # (from /etc/ppp/peers/provider) ipcp-accept-local # (from /etc/ppp/peers/provider) ipcp-accept-remote # (from /etc/ppp/peers/provider) ipparam 3gppp # (from /etc/ppp/peers/provider) noipdefault # (from /etc/ppp/peers/provider) ipcp-max-failure 30 # (from /etc/ppp/peers/provider) defaultroute # (from /etc/ppp/peers/provider) usepeerdns # (from /etc/ppp/peers/provider) noccp # (from /etc/ppp/peers/provider) noipx # (from /etc/ppp/options) abort on (BUSY) abort on (NO CARRIER) abort on (NO DIALTONE) abort on (ERROR) abort on (NO ANSWER) timeout set to 30 seconds send (AT^M) expect (OK) ^M OK -- got it send (ATE0^M) expect (OK) ^M ^M OK -- got it send (AT+CPIN?^M) expect (OK) ^M ^M +CPIN: READY^M ^M OK -- got it send (AT+CSQ^M) expect (OK) ^M ^M +CSQ: 27,99^M ^M OK -- got it send (AT+CREG?^M) expect (OK) ^M ^M +CREG: 0,5^M ^M OK -- got it send (AT+CGREG?^M) expect (OK) ^M ^M +CGREG: 0,5^M ^M OK -- got it send (AT+COPS?^M) expect (OK) ^M ^M +COPS: 0,0,"Twilio",7^M ^M OK -- got it send (AT+CGDCONT=1,"IP","super",,0,0^M) expect (OK) ^M ^M OK -- got it send (ATD*99#^M) expect (CONNECT) ^M ^M CONNECT -- got it Script chat -s -v -f /etc/chatscripts/chat-connect -T super finished (pid 3399), status = 0x0 Serial connection established. using channel 1 Using interface ppp0 Connect: ppp0 <--> /dev/ttyUSB3 sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x1f1aee7b> <pcomp> <accomp>] rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x7f83c33d> <pcomp> <accomp>] No auth is possible sent [LCP ConfRej id=0x0 <auth chap MD5>] rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x1f1aee7b> <pcomp> <accomp>] rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x7f83c33d> <pcomp> <accomp>] sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x7f83c33d> <pcomp> <accomp>] sent [LCP EchoReq id=0x0 magic=0x1f1aee7b] sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>] rcvd [LCP DiscReq id=0x2 magic=0x7f83c33d] rcvd [LCP EchoRep id=0x0 magic=0x7f83c33d 1f 1a ee 7b] rcvd [IPCP ConfReq id=0x0] sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>] rcvd [IPCP ConfNak id=0x1 <addr 100.82.153.48> <ms-dns1 8.8.8.8> <ms-dns2 8.8.4.4>] sent [IPCP ConfReq id=0x2 <addr 100.82.153.48> <ms-dns1 8.8.8.8> <ms-dns2 8.8.4.4>] rcvd [IPCP ConfReq id=0x1] sent [IPCP ConfAck id=0x1] rcvd [IPCP ConfAck id=0x2 <addr 100.82.153.48> <ms-dns1 8.8.8.8> <ms-dns2 8.8.4.4>] Could not determine remote IP address: defaulting to 10.64.64.64 not replacing default route to wlan0 [192.168.1.1] local IP address 100.82.153.48 remote IP address 10.64.64.64 primary DNS address 8.8.8.8 secondary DNS address 8.8.4.4

Checking The Connection

pi@raspberrypi:~ $ ifconfig ppp0 ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 100.64.140.89 netmask 255.255.255.255 destination 10.64.64.64 ppp txqueuelen 3 (Point-to-Point Protocol) RX packets 18 bytes 1392 (1.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 20 bytes 1395 (1.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pi@raspberrypi:~ $ ping -I ppp0 -c 5 sixfab.com PING sixfab.com (104.26.9.221) from 100.64.29.57 ppp0: 56(84) bytes of data. 64 bytes from 104.26.9.221 (104.26.9.221): icmp_seq=1 ttl=53 time=316 ms 64 bytes from 104.26.9.221 (104.26.9.221): icmp_seq=2 ttl=53 time=318 ms 64 bytes from 104.26.9.221 (104.26.9.221): icmp_seq=3 ttl=53 time=314 ms 64 bytes from 104.26.9.221 (104.26.9.221): icmp_seq=4 ttl=53 time=333 ms 64 bytes from 104.26.9.221 (104.26.9.221): icmp_seq=5 ttl=53 time=334 ms --- sixfab.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 7ms rtt min/avg/max/mdev = 314.010/323.157/333.655/8.553 ms

Managing the Connection Manager Service

To check if the service is active you can type.

pi@raspberrypi:~ $ sudo systemctl status ppp_connection_manager.service ppp_connection_manager.service - PPP Connection Manager Loaded: loaded (/etc/systemd/system/ppp_connection_manager.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-01-26 16:29:13 GMT; 3min 3s ago Main PID: 1246 (bash) Tasks: 7 (limit: 3861) CGroup: /system.slice/ppp_connection_manager.service ├─1246 /bin/bash ppp_connection_manager.sh ├─1533 bash ppp_reconnect.sh ├─1534 sudo tee -a ./logs/2021_01_26_16:29:13.log ├─1536 tee -a ./logs/2021_01_26_16:29:13.log ├─1856 /usr/sbin/pppd call provider ├─2694 /usr/sbin/pppd call provider └─2749 sleep 60

To stop your reconnect service, type:

sudo systemctl stop ppp_connection_manager.service

To start the reconnect service when it is stopped, type:

sudo systemctl start ppp_connection_manager.service

By default, the reconnect service is configured to start automatically when the server boots. If this is not what you want, you can disable this behavior by typing:

sudo systemctl enable ppp_connection_manager.service

To re-enable the service to start up at boot, you can type:

sudo systemctl enable reconnect.service

Uninstall

If you are using auto-connect/reconnect service, stop the service and disable it.

sudo systemctl stop ppp_connection_manager.service
sudo systemctl disable ppp_connection_manager.service

Then delete the files.

sudo rm -r /opt/sixfab/ppp_connection_manager
Note: After the installation you may need to change some configuration in the future if required, this could be the credentials, APN or, the device port. Instead of reinstalling the whole process, you may change them as follows.

Credential

If your carrier asks for username and password;
Remove noauth from /etc/ppp/peers/provider and add the following lines.

user “YOUR USERNAME”

password “YOURPASSWORD"

APN or device port

You can change APN and PORT from /etc/ppp/peers/provider.

To understand PPP further you can check PPP documentation.

If you have the Thales mini PCIe products we recommend using their pppd tutorial.

Troubleshooting

We recommend to go through the section on troubleshooting as it covers the more common issues with establishing and maintaining a network connection. Please check the troubleshooting of your shield/HAT.