For your own reference, I strongly recommend reading the original RFC for IPv4. You'd be surprised how readable it is and how much information you can glean from just the underlying spec. It's also available for free, online, here: https://tools.ietf.org/html/rfc791.
I'd also recommend, simply for its brevity, that you read the original IEN 2 to understand exactly what motivated the development of IP in the first place. It's also free to read online, and surprisingly engaging: https://www.rfc-editor.org/ien/ien2.txt.
Additionally, if you'd like to understand other ways to program for IP, I once again recommend Understanding TCP/IP, by Alena Kabelová and Libor Dostálek, available from Packt Publishing here: https://www.packtpub.com/networking-and-servers/understanding-tcpip.