Linux ping program

I have a really strange problem.

At random points during the day, my computer stops uploading data but continues downloading it. I'm trying to figure out whether it's an issue with my computer or with my ISP. To do this I have decided to write a program for my raspberry pi so that it pings my pc at 5 second intervals to see if it gets a response (they're on the same network by the way) and recording the time at which it doesn't get a response.

My question to you is how I should go about writing such a program as I'm not used to programming with network communications.

Cheers.

ping -Di5 $pc_ip_address | grep --line-buffered Unreachable > network-down-times.txt

Prettier time format:

ping -Dni5 $pc_ip_addr | gawk 'match($0, /\[(.*)\].*Unreachable/, ary) { print strftime("%Y-%m-%d %T", ary[1]); }' > downtime.txt &