199: def initialize
200: @drift = 0
201: @last_clock = (Time.now.to_f * CLOCK_MULTIPLIER).to_i
202: @mutex = Mutex.new
203:
204: state_file = self.class.state_file
205: if state_file && File.size?(state_file) then
206: next_sequence
207: else
208: @mac = Mac.addr.gsub(/:|-/, '').hex & 0x7FFFFFFFFFFF
209: fail "Cannot determine MAC address from any available interface, tried with #{Mac.addr}" if @mac == 0
210: @sequence = rand 0x10000
211:
212: if state_file
213: open_lock 'wb' do |io|
214: write_state io
215: end
216: end
217: end
218: end