add sending and receiving ping packet function and fix some error