Remove switch case which cannot be triggered any more
Move main loop to main_loop() function
Add more const keywords where possible
Start pings with sequence number 0, not 1
reformat code