The 16-bit IPID field carries a copy of the current value of a counter in a host’s IP stack. Many commercial operating systems (including various versions of Windows and Linux versions 2.2 and earlier) implement this counter as a global counter. That is, the host maintains a single IPID counter that is incremented (modulo 216 ) whenever a new IP packet is generated and sent. Other operating systems implement the IPID counter as a per-flow counter (as is done in the current version of Linux), as a random number, or as a constant, e.g., with a value of 0 ([1]).

From: ftp://gaia.cs.umass.edu/pub/Chen04_IPID.pdf

From: Fun with IP Identification Field Values

RFC 791 gives a description about the IP Identification field.

The identification field value is used to uniquely identify the fragments of
a particular datagram. Fragments of a particular datagram are assembled if
they have the same source, destination, protocol, and Identifier. The
identifier is being chosen to be unique for this “this source, destination
pair and protocol for the time the datagram (or any fragment of it) could be
alive in the internet”[1].