# Zing, basic Elixir ICMP ('ping') server using Zig NIF

**URL:** <https://forum.elixirforum.com/t/zing-basic-elixir-icmp-ping-server-using-zig-nif/31681>\
**Category:** Discussions\
**Tags:** nifs, zig\
**Created:** [May 21, 2020, 4:52am UTC](https://forum.elixirforum.com/t/zing-basic-elixir-icmp-ping-server-using-zig-nif/31681 "2020-05-21T04:52:38Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![lkuty](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/lkuty/32/34879_2.png) [@lkuty](https://forum.elixirforum.com/u/lkuty)\
**Post date:** [June 19, 2021, 5:24am UTC](https://forum.elixirforum.com/t/zing-basic-elixir-icmp-ping-server-using-zig-nif/31681/10 "2021-06-19T05:24:06Z")

</div>

From different tests I made on macOS and Linux, it looks like macOS needs us to compute the checksum for the echo request and then give us back the full IP packet of the echo reply, hence your `_::size(160)` to skip 20 bytes of IP header. On Linux we do not need to compute the checksum or set an id because the OS will dot it for us and we also only get the ICMP echo reply, not the full IP packet.

This is confirmed by the [`ping` source code](https://opensource.apple.com/source/network_cmds/network_cmds-433/ping.tproj/ping.c.auto.html) on MacOS. I guess the behaviour of the library regarding a socket created with `socket(PF_INET, SOCK_DGRAM, IPPROTO_ICMP)` is quite OS dependent.

---

_[View the full topic](https://forum.elixirforum.com/t/zing-basic-elixir-icmp-ping-server-using-zig-nif/31681)._
