chance of struct.error when writing pcap packet timestamps

Under certain unlucky timing, the pcap_cb_write() function can raise a struct.error because nsec can be negative.

Here's the case I happened to catch in my CI. I call writer.write(packet, ts=time.time_ns())

self = <pypacker.ppcap.Writer object at 0x7fe470596bb0>
bts = b'<redacted>'
metadata = {'ts': 1628514346999999976}, ts = 1628514346999999976
sec = 1628514347, nsec = -24, n = 94

    def pcap_cb_write(self, bts, **metadata):
    	ts = metadata.get("ts", self._timestamp + 1000000)
    	self._timestamp = ts
    	sec = int(ts / 1000000000)
    	nsec = ts - (sec * 1000000000)
    
    	# logger.debug("paket time sec/nsec: %d/%d", sec, nsec)
    	n = len(bts)
>   	self._fh.write(pack_IIII(sec, nsec, n, n))
E    struct.error: argument out of range

env/lib/python3.8/site-packages/pypacker/ppcap.py:103: error

What's happening here is that the time hapens to be very close to the end of a second. So when we do ts / 1000000000 we get 1628514347.0, understandably, due to the limits of floating point precision. But then we convert it to an int, multiply by 1000000000, and subtract it from ts, which are all integer operations, so we end up with a negative nsec.

One possible solution is to use integer division like ts // 1000000000 instead of normal division and then converting to an int.