#
# Define nodes used in experiment
#
defNodes('senderwifi', [1,1]) {|node|
  node.prototype("test:proto:sender", {
    'destinationHost' => '192.168.1.2',
    'packetSize' => 1024,
    'rate' => 10000,
    'protocol' => 'udp'    
  })
  node.net.w0.mode = "managed"
}

defNodes('receiverwifi', [1,2]) {|node|
  node.prototype("test:proto:receiver" , {
    'protocol' => 'udp'
  })
  node.net.w0.mode = "master"
}

allNodes.net.w0 { |w|
  w.type = 'b'
  w.essid = "wifi"
  w.ip = "%192.168.%x.%y"
  w.channel = 6
}

#
# Iperf sender definition and configuration
#
defNodes('senderbt', [1,1]) {|node|
  node.image = nil  # assume the right image to be on disk
  # use prototype "sender" 
  # and set it's property "destinationHost" to 
  # the receiver node
  # and bind the remaining properties to the 
  # experiment property space
  node.prototype("test:proto:iperfudpsender", {
    'client' => '192.169.1.2',  #Send to 
    'use_udp' => nil,           #UDP client
    'sender_rate' => 1000000,   #Input offered load (bits per sec)
    'len' => 1024,               #Payload length (bytes)
    'time' => 300
  })
  #node.net.w1.ip = "%192.169.%x.%y"
  #node.net.w1.mode = "Managed"
  #node.net.w1.type = 'b'
  #node.net.w1.essid = "iperf"
}

#
# Receiver definition and configuration
#
defNodes('receiverbt', [1,2]) {|node|
  node.image = nil  # assume the right image to be on disk
  node.prototype("test:proto:iperfudpreceiver" , {
  'server' => nil,         # Server
  'use_udp' => nil,        # Use UDP
  'len' => 1024,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
  #node.net.w1.ip = "%192.169.%x.%y"
  #node.net.w1.mode = "Master"
  #node.net.w1.type = 'b'
  #node.net.w1.essid = "iperf"
}

#
# Now, start the application
#
whenAllInstalled() {|node|
  wait 30 
  allNodes.startApplications
  wait 300

  Experiment.done
}
