<commit_before>module NetworkSimulator
  require 'network_simulator/event'
  require 'network_simulator/message'
  require 'network_simulator/packet'

  def generate_send packet, entity
    loss_chance = rand
    if loss_chance < $loss
      puts '        Packet being lost'
      return
    end

    random_modification = rand(10) - 4
    time = $current_time + $delay + random_modification
    puts "next time is #{$current_time + $delay} and the modification to the time is #{random_modification}"
    event = NetworkSimulator::Event.new time, :receive_data, entity

    corruption_chance = rand
    if corruption_chance < $corruption
      puts '        Packet being corrupted'
      if corruption_chance < 0.75
        event.packet.payload[0] = event.packet.payload[0].next if event.packet.payload
      elsif corruption_chance < 0.90
        event.packet.seq += 1 if event.packet.seq
      else
        event.packet.ack += 1 if event.packet.ack
      end
    end

    event.packet = packet
    puts "Scheduled event => #{event}"
    $events << event
  end
  module_function :generate_send

  def a_to_layer_five message
    puts "A successfully received this message: #{message.data}"
  end
  module_function :a_to_layer_five

  def b_to_layer_five message
    puts "B successfully received this message: #{message.data}"
  end
  module_function :b_to_layer_five

  def start_timer timeout, entity
    $events << NetworkSimulator::Event.new($current_time + timeout, :timeout, entity)
  end
  module_function :start_timer<commit_msg>Created NetworkSimulator.a_start_timer method.<commit_after>module NetworkSimulator
  require 'network_simulator/event'
  require 'network_simulator/message'
  require 'network_simulator/packet'

  def generate_send packet, entity
    loss_chance = rand
    if loss_chance < $loss
      puts '        Packet being lost'
      return
    end

    random_modification = rand(10) - 4
    time = $current_time + $delay + random_modification
    puts "next time is #{$current_time + $delay} and the modification to the time is #{random_modification}"
    event = NetworkSimulator::Event.new time, :receive_data, entity

    corruption_chance = rand
    if corruption_chance < $corruption
      puts '        Packet being corrupted'
      if corruption_chance < 0.75
        event.packet.payload[0] = event.packet.payload[0].next if event.packet.payload
      elsif corruption_chance < 0.90
        event.packet.seq += 1 if event.packet.seq
      else
        event.packet.ack += 1 if event.packet.ack
      end
    end

    event.packet = packet
    puts "Scheduled event => #{event}"
    $events << event
  end
  module_function :generate_send

  def a_to_layer_five message
    puts "A successfully received this message: #{message.data}"
  end
  module_function :a_to_layer_five

  def b_to_layer_five message
    puts "B successfully received this message: #{message.data}"
  end
  module_function :b_to_layer_five

  def start_timer timeout, entity
    $events << NetworkSimulator::Event.new($current_time + timeout, :timeout, entity)
  end
  module_function :start_timer

  def a_start_timer timeout
    start_timer timeout, :a
  end
  module_function :a_start_timer
{'fraction_non_alphanumeric': 0.07769110764430577, 'fraction_numerical': 0.008112324492979718, 'mean_word_length': 3.3382949932341, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2939165', 'n_tokens_mistral': 972, 'n_tokens_neox': 946, 'n_words': 266}