The implementation of receive_event does not look correct. Conceptually the following should occur: time_= max(received_time, time_)+1; return time_; You are not adding 1 to the clock in all cases.