コード例 #1
0
    def __init__(self, sim, extra_config={}):
        self.sim = sim
        self.config = sim.simul_config.get("node-config", {}).copy()
        self.config.update(extra_config)

        self.layer2 = SimulLayer2(sim)
        self.layer3 = SimulLayer3(sim)
        self.protocol = schc.SCHCProtocol(self.config, self, self.layer2,
                                          self.layer3)
        self.id = self.layer2.mac_id
        self.sim._add_node(self)
コード例 #2
0
ファイル: SCHC_server.py プロジェクト: n44hernandezp/openschc
    def __init__(self, scheduler):
        #self.port = port
        #self.devEUI = devEUI
        self.port = None
        self.devEUI = None
        self.cont = 0
        self.loss_config = None
        self.rule = []
        self.context = "example/context-100.json"
        self.rule_comp = "example/comp-rule-100.json"
        self.rule_fragin2 = "example/frag-rule-201.json"  #NoACK
        self.rule_fragout2 = "example/frag-rule-202.json"  #NoACK
        self.rule_fragin = "example/frag-rule-101.json"  #ACK-ON-Error
        self.rule_fragout = "example/frag-rule-102.json"  #ACK-ON-Error
        for k in [
                self.context, self.rule_comp, self.rule_fragin,
                self.rule_fragout, self.rule_fragin2, self.rule_fragout2
        ]:
            with open(k) as fd:
                self.rule.append(json.loads(fd.read()))

        self.rule_manager = RuleManager()
        self.rule_manager.add_context(self.rule[0], self.rule[1], self.rule[2],
                                      self.rule[3], self.rule[4], self.rule[5])
        #--------------------------------------------------------------------------
        #simul
        self.l2_mtu = 56
        self.layer_2 = SimulLayer2()
        self.layer_2.set_mtu(self.l2_mtu)
        self.layer_3 = SimulLayer3()
        self.scheduler = scheduler
        #self.scheduler = Scheduler()
        self.protocol = schc.SCHCProtocol(self.scheduler, self.layer_2,
                                          self.layer_3)
        self.protocol.set_rulemanager(self.rule_manager)
        self.protocol.set_dev_L2addr(0)  #setear la direccion MAC
        self.sender_id = self.layer_2.mac_id  #tengo que tener la mac del que envia
コード例 #3
0
ファイル: schcgw.py プロジェクト: sandoche2k/openschc
# set the logger object.
logger = set_logger(logging, config)
if not config.debug_level:
    requests.packages.urllib3.disable_warnings()

# create the schc protocol object.
rule = []
for k in [config.context_file, config.rule_comp_file, config.rule_fragin_file,
          config.rule_fragout_file]:
    with open(k) as fd:
        rule.append(json.loads(fd.read()))
rule_manager = RuleManager()
rule_manager.add_context(rule[0], rule[1], rule[2], rule[3])
#
loop = asyncio.get_event_loop()
if config.debug_level > 1:
    loop.set_debug(True)
system = System(loop, logger=logger, config=config)
layer2 = gwLayer2(system, config=config)
layer3 = gwLayer3(system, config=config)
protocol = schc.SCHCProtocol(config, system, layer2, layer3)
protocol.set_rulemanager(rule_manager)
#
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.load_cert_chain(config.my_cert)
app = web.Application(loop=loop, debug=True)
app.router.add_route("POST", "/ul", app_uplink)
app.router.add_route("POST", "/dl", app_downlink)
web.run_app(app, host=config.bind_addr, port=config.bind_port,
            ssl_context=ctx)