#
# Define nodes used in experiment
#
defNodes('senderwifi', [[12,1],[19,2],[13,8],[15,9],[1,10],[7,10],[10,11],[5,16],[10,18],[18,18],[13,20]]) {|node|
  node.prototype("test:proto:sender", {
    'destinationHost' => '192.168.14.10',
    'packetSize' => 512,
    'rate' => 100,
    'protocol' => 'udp'
  })
  node.net.w0.mode = "managed"
}

defNodes('receiverwifi', [14,10]) {|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('senderbt1', [10,11]) {|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.170.7.10',  #Send to
    'use_udp' => nil,           #UDP client
    'sender_rate' => 102400,   #Input offered load (bits per sec)
    'len' => 64,               #Payload length (bytes)
    'time' => 120
  })
}

#
# Receiver definition and configuration
#
defNodes('receiverbt1', [7,10]) {|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' => 64,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
}

#
# Iperf sender definition and configuration
#
defNodes('senderbt2', [14,15]) {|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.171.18.18',  #Send to
    'use_udp' => nil,           #UDP client
    'sender_rate' => 102400,   #Input offered load (bits per sec)
    'len' => 64,               #Payload length (bytes)
    'time' => 120
  })
}

#
# Receiver definition and configuration
#
defNodes('receiverbt2', [18,18]) {|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' => 64,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
}

#
# Iperf sender definition and configuration
#
defNodes('senderbt3', [13,8]) {|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.172.14.10',  #Send to
    'use_udp' => nil,           #UDP client
    'sender_rate' => 102400,   #Input offered load (bits per sec)
    'len' => 64,               #Payload length (bytes)
    'time' => 120
  })
}

#
# Receiver definition and configuration
#
defNodes('receiverbt3', [14,10]) {|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' => 64,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
}

#
# Iperf sender definition and configuration
#
defNodes('senderbt4', [13,10]) {|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.173.15.9',  #Send to
    'use_udp' => nil,           #UDP client
    'sender_rate' => 102400,   #Input offered load (bits per sec)
    'len' => 64,               #Payload length (bytes)
    'time' => 120
  })
}

#
# Receiver definition and configuration
#
defNodes('receiverbt4', [15,9]) {|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' => 64,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
}

#
# Iperf sender definition and configuration
#
defNodes('senderbt5', [1,10]) {|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.174.4.10',  #Send to
    'use_udp' => nil,           #UDP client
    'sender_rate' => 102400,   #Input offered load (bits per sec)
    'len' => 64,               #Payload length (bytes)
    'time' => 120
  })
}

#
# Receiver definition and configuration
#
defNodes('receiverbt5', [4,10]) {|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' => 64,           #Payload length (bytes)
  'report_interval' => 1   #Report interval(seconds)
  })
}

#
# Now, start the application
#
whenAllInstalled() {|node|
  wait 10
  nodes('receiverbt1').startApplications
  nodes('receiverbt2').startApplications
  nodes('receiverbt3').startApplications
  nodes('receiverbt4').startApplications
  nodes('receiverbt5').startApplications
  wait 20
  nodes('senderbt1').startApplications
  nodes('senderbt2').startApplications
  nodes('senderbt3').startApplications
  nodes('senderbt4').startApplications
  nodes('senderbt5').startApplications
  nodes('receiverwifi').startApplications
  nodes('senderwifi').startApplications
  wait 120

  Experiment.done
}

