Ping can be suppressed by a firewall, so I like to take a more overall view.
- I would choose one thing that Macs can share like Screen Sharing and File Sharing and turn them on on both Macs.
- I would check if the time of day is correct on both (since some deviation past a few hundred seconds can cause visibility errors in some sharing tasks). This also ensures that the network connection to internet time servers is working if you set the time automatically.
- Now that you know the network itself is functional for each Mac - open Finder in both and search for the other Mac.
If you have hidden the "shared" sidebar in finder, you might have to un-hide it. Alternatively, you could make a new test user account on both Macs and use it for troubleshooting. The default Finder settings will show shared Macs on the local network.
At that point, you'll know a bit more about the network and possibly want to power off both Macs and power off the router and then start them all up again.