def configSim(self): """ Method to configure a schc simulation, setting some important configurations and creating a node in the network with a sequence of rules associated """ # packets loss and log Configuration simul_config = { "log": True, } # Configuration packets loss if self.configuration['packet_loss_simulation']: # Configuration with packet loss in noAck and ack-on-error loss_rate = 15 # in % collision_lambda = 0.1 background_frag_size = 54 loss_config = {"mode": "rate", "cycle": loss_rate} # loss_config = {"mode":"collision", "G":collision_lambda, "background_frag_size":background_frag_size} else: # Configuration without packet loss in noAck and ack-on-error loss_config = None if loss_config is not None: simul_config["loss"] = loss_config # Simul and node instance self.sim = simul.Simul(simul_config) self.node0 = self.make_node(self.sim, self.rule_manager, self.devaddr) self.node0.layer2.set_mtu(self.configuration['l2_mtu']) self.node0.layer2.set_role(self.configuration['role'], self.roleSend) print("-------------------------------- SCHC ", self.configuration['role'], " ------------------------") print( "SCHC device L3={} L2={} RM={}".format(self.node0.layer3.L3addr, self.node0.id, self.rule_manager.Print()))
print("0packet_size: {}, temp_packet_size:{}, send_data:{}".format( packet_size, temp_packet_size, send_data)) print("packet_size - > {}".format(send_data)) #input('') #for i in range(repetitions): print("packet_size - > {}".format(send_data)) #--------------------------------------------------------------------------- """ Init stastct module """ Statsct.initialize() Statsct.log("Statsct test") Statsct.set_packet_size(send_data) #--------------------------------------------------------------------------- Statsct.get_results() sim = simul.Simul(simul_config) devaddr = b"\xaa\xbb\xcc\xdd" node0 = make_node(sim, rm0, devaddr) # SCHC device node1 = make_node(sim, rm1, devaddr) # SCHC gw sim.add_sym_link(node0, node1) node0.layer2.set_mtu(l2_mtu) node1.layer2.set_mtu(l2_mtu) print("SCHC device L3={} L2={} RM={}".format(node0.layer3.L3addr, node0.id, rm0.__dict__)) print("SCHC gw L3={} L2={} RM={}".format(node1.layer3.L3addr, node1.id, rm1.__dict__)) print("rules -> {}, {}".format(rm0.__dict__, rm1.__dict__)) #device rule for rule1 in rm0.__dict__: