debug on headless raspberry pi


#1

I’m trying to debug hologram.io sim 8944501805175407748 (1MB - Developer Plan) in an unlocked Huawei E397 4G LTE usb modem connected to a headless raspberry pi running Raspbian Jessie. The problem is that I need the eth0 interface to ssh into the RPI to debug the ppp0 interface. I’d appreciate advice on how to do this.
modemmanager and usb_modeswitch were already installed. (Although for some reason libqmi-proxy was not. I had to run ‘apt-get install libqmi-proxy’ to get rid of error messages in /var/log/daemon.log). I set up /etc/ppp/peers/e379 and /etc/ppp/chatscripts/e379 as instructed on the hologram.io help page. After booting up, I run ‘sudo pon e379’ BUT without bringing down eth0 first. ifconfig shows:
ppp0 Link encap:Point-to-Point Protocol
inet addr:10.170.140.39 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1428 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:22 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:62 (62.0 B) TX bytes:1426 (1.3 KiB)
‘route -n’ shows
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 202 0 0 eth0
10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
169.254.0.0 0.0.0.0 255.255.0.0 U 355 0 0 wwan0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0

On my hologram.io Dashboard, it shows
Usage this period 21.20KBi
When I click Inspect, I see a number of usage entries like
{“linkid”:358456,“record_id”:190849407,“session_begin”:“2017-10-01 12:54:09”,“timestamp”:“2017-10-01 13:13:46”,“bytes”:1455,“network_name”:“T-Mobile USA, Inc. CO”}
The signal strength seems ok:
$ comgt -d /dev/ttyUSB1 sig
Signal Quality: 19,99
(when comgt shows Registered)

I tried testing by setting up a route to an external IP:

sudo ip route add 89.160.456.987 via 10.64.64.64 dev ppp0
ping 89.160.456.987

all that happens is that the ppp0 interface disappears.

I’d appreciate advice.

thanks


#2

What I usually do is set up Network Sharing on my MAC. This allows my ethernet dongle to serve a DHCP address to the Raspberry Pi.

I then run “arp -a” after a minute or so. I usually see something like 192.168.2.8. I then SSH via this address.


#3

I don’t understand how this helps. I need two interfaces on the raspberry pi:

(1) ppp0 via the 4G LTE modem using the hologram.io sim

(2) eth0 via the ethernet cable to the local network.

At the moment, my router serves a DHCP address to the raspberry pi via the local network. I could have a local Mac serve the DHCP address but what do I gain?

My problem is to have both interfaces active simultaneously so I can test (1).

thanks,
Daniel


#4

Oh gotcha.

Are you using Network Manager? I do, and have no issue having multiple active adapters.


#5

I don’t really understand what you’re trying to do.
Is your pi nearby to run ethernet or within wifi range (pi3 or dongle)?
Or, is your only connection thru cellular?

On my pi3 i stay connected via ssh over LAN while cellular is active. The route changes dynamically.

eth0 Link encap:Ethernet HWaddr b8:27:eb:75:ef:3f
inet addr:XXX.XXX.XXX.XXX Bcast:172.27.35.255 Mask:255.255.255.0
inet6 addr: fe80::c3e5:cea8:af4b:53b3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:803722 errors:0 dropped:1024 overruns:0 frame:0
TX packets:158393 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:239088454 (228.0 MiB) TX bytes:74972754 (71.4 MiB)

ppp0 Link encap:Point-to-Point Protocol
inet addr:XXX.XXX.XXX.XXX P-t-P:XXX.XXX.XXX.XXX Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:68 (68.0 B) TX bytes:204 (204.0 B)


#6

Brian: thanks for the suggestion. I’ll try Network Manager. I jumped to the conclusion that it was a gui application. Now I see that it has a cli, namely ‘nmcli’.

stevemac: I want what you have:

On my pi3 i stay connected via ssh over LAN while cellular is active. The route changes dynamically.

Specifically, I want traffic to a single IP, call it 123.456.789.876, to go out via ppp0 and everything else to go via eth0.

thanks,
Daniel


#7

Look into “policy based routing”. https://en.wikipedia.org/wiki/Policy-based_routing

I initially worked on this and stopped when the new python hologram library came out as it satisfied my problem without additional complexity.

I still don’t know your specific needs but for my needs, I simply send out http requests over cellular or ethernet based on my own application parameters. Very easy using the hologram python library.

Then all you have to do is class to your policy:

params = ['sudo', '/usr/local/bin/hologram', 'send', message, '--cloud', '--topic', topic]
d = defer.Deferred()
pp = reactor.spawnProcess(twistedutil.ProcessReader(d), params[0], params, env=None, childFDs={0: "w", 1: "r"})
response = yield d

or

  d = agent.request('POST',
      'https://api.myurl.com/messages.json',
       Headers({'Content-Type': ['application/x-www-form-urlencoded']}),
       FileBodyProducer(StringIO(urlencode({="message": message,= }))))
  d.addCallback(cbRequest)

(I use twisted for my networking library.)
At the hologram cloud I have webhooks which then perform the appropriate relays.
The hologram python library is very well written and easy to implement.
Think about what you’re trying to accomplish. I’d be surprised if it’s not already implemented and debugged for you.


#8

I just want to sent a short UDP datagram every 1200 seconds to a specific port at a specific IP

import socket
import time
UDP_IP = "12.345.678.987"
UDP_PORT = 6789
TIME_INTERVAL = 1200
reading_a = 12.345
reading_b = 56.789
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
while True:
    the_time = time.strftime("%Y-%m-%d %H:%M:%S %Z")
    MESSAGE = '{:} {:.3f} {:.3f}'.format(the_time,reading_a,reading_b )
    sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
    time.sleep(TIME_INTERVAL)

I want to get the low level 4G LTE connection to the internet working properly before I think about using more sophisticated IOT infrastructure. All this is new to me. How reliable is my Huawei E397u-53 usb 4G modem? Is there a strong enough 4G signal at my location? Does “strong enough” depend on the IOT provider? How much overhead is there for each UDP datagram?

At the moment, the PPP0 interface disappears as soon as I try to send a UDP datagram. The 4G connection is erratic using the hologram.io sim card. I’ve sent 0B of data yet my Hologram Dashboard shows 21KB consumed, presumably in setting up connections.