249: def initialize
250: @drift = 0
251: @last_clock = (Time.now.to_f * CLOCK_MULTIPLIER).to_i
252: @mutex = Mutex.new
253:
254: state_file = self.class.state_file
255: if state_file && File.size?(state_file) then
256: next_sequence
257: else
258: @mac = mac_address
259: fail "Cannot determine MAC address from any available interface, tried with #{mac_address}" if @mac == 0
260: @sequence = rand 0x10000
261:
262: if state_file
263: open_lock 'wb' do |io|
264: write_state io
265: end
266: end
267: end
268: end