Posts mit dem Label network werden angezeigt. Alle Posts anzeigen
Posts mit dem Label network werden angezeigt. Alle Posts anzeigen

Sonntag, 28. Februar 2021

Raspberry Pi, test my internet connection

Since start of Corona times, I use my internet at home also for work. So its reliability and performance has become crucial. Performance seems to be stable, I test it using speedtest.net:

But regarding the reliability, I get outages almost every day. Very awkward during a video conference in your job. So, first step is to check whether the outage comes from the internet provider or from the WLAN. 

German video where I describe what I did.

It can be that your WLAN router needs to change channels which will be bad enough to cut you off a video conference although your internet connection from the router to the internet works perfectly fine.

So I got the idea to use my raspberry pi which is connected to the router via cable (not WLAN) to check if there are internet outages (not WLAN outages):

modern art: 
if WLAN is down, Raspberry Pi will still be connected to the internet

I use a screen session to monitor the network connection. A screen session will survive users closing the terminal window, network outages and it never times out. See below:

A screen session survives network outages and it does not time out.

To install screen, I ran on raspian:

apt-get update
apt-get install screen

To start a screen session, run 

screen

and follow the instructions (to type Enter ;).

To list all screen sessions, type

screen -ls

Once you re-login, you can re-attach to a screen session (if there is only one) using

screen -x

Inside the screen session, to detect network errors, I used the command

ping -O 8.8.8.8 2>&1| while read a; do echo $(date; echo $a); done | grep -v time

This command will only output a line in case of an issue, and it will also write a timestamp like this:

pi@raspberrypi:~ $ ping -O 8.8.8.8 2>&1| while read a; do echo $(date; echo $a); done | grep -v time 
Mon 01 Mar 2021 10:58:49 AM CET PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 
Mon 01 Mar 2021 10:59:01 AM CET ping: sendmsg: Network is unreachable

You can provoke an error situation by drawing the LAN cable from the Raspberry Pi.

Learnings

I found that by telling FritzBox to reconnect I can provoke a situation where ping does not get replies and packages are lost, however, no error message gets printed. You can detect the error by looking at the icmp_seq value that suddenly increases by more than one. Fixed by applying -O.

I found that FritzBox' DSL information does not really provide the information if the internet connection has been lost or not. Or if it does, I do not understand it. It talks about non-recoverable errors, but I am not sure if this means "DSL connection lost".

I still don't understand why, but 
ping 8.8.8.8 2>&1| while read a; do echo $(date; echo $a); done | grep -v time 
works and
ping 8.8.8.8 2>&1| grep -v time | while read a; do echo $(date; echo $a); done
does not

Montag, 6. April 2015

PsyComputing - a computer's psychology

With Linux it's easy to do what I call psycomputing - talking with the computer like "why do you behave this way". This can be done on multiple levels and areas:
  • strace shows all syscalls a process does while executing. This makes it easy to find where things start to go wrong. I give an introduction at http://www.linuxintro.org/wiki/STrAce.
  • disassembling: objdump -d shows what a program will do once it is executed in assembler language. This is also called disassembling. I show disassembling a "hello world" program at http://www.staerk.de/thorsten/Assembler_Tutorial#disassemble_it_2
  • network replay: Using the telnet or netcat tool you can manually interact with a web service. You can test e.g. HTTP transfer and IMAP transfer, see http://www.linuxintro.org/wiki/Telnet
  • network sniffing: What you can do to process execution you can also do with network communication. Use the tool wireshark, see http://en.wikipedia.org/wiki/Wireshark
  • USB bus sniffing: You can use Wireshark to drill down on USB bus communication as well. Good for troubleshooting keyboards, printers and scanners.
  • SCSI bus sniffing: Using the tool blktrace to dissect the communication of scsi commands between your hard disk controller and your processor.
  • byte-by-byte disk analysis: Use the tool dd to read any sector or byte on your harddisk. Great for analyzing boot problems and for cloning harddisks.
There is another word for PsyComputing. How is it called? Write your answer to the comment section :)

Raspberry Pi, test my internet connection

Since start of Corona times, I use my internet at home also for work. So its reliability and performance has become crucial. Performance see...