@@ -0,0 +1,2253 @@
+import bootstrap%0A%0Afrom engine import Device, BaseStation%0A%0Aclass DQObject:%0A    REQUEST = 0%0A    FEEDBACK = 1%0A    def __init__(self, obj_type):%0A        self.type = obj_type%0A%0A%0Aclass DQRequest(DQObject):%0A    def __init__(self, slot):%0A        super().__init__(DQObject.REQUEST)%0A        self.slot = slot%0A%0Aclass DQFeedback(DQObject):%0A    def __init__(self, slots, dtq, crq):%0A        self.slots = slots%0A        self.dtq = dtq%0A        self.crq = crq%0A%0A%0Aclass LPDQNode(Device):%0A    IDLE = 0%0A    IN_TRANSMISSION = 1%0A    DTQ  = 2%0A    CRQ  = 3%0A%0A    def __init__(self, id, env, seed, jitter_range, rate, average_packet_size, m, packet_rate):%0A        super().__init(id, env, seed=seed, jitter_range=jitter_range)%0A        self.rate = rate%0A        self.average_packet_size = average_packet_size%0A        self.m = m%0A        self.packet_rate = packet_rate%0A        self.sleep_time = self.random.randint(0, 20)   # TODO: change this to parameter%0A        %0A        self..chosen_slot = 0%0A        %0A        self.state = LPDQNode.IDLE%0A%0A        self.env.process(self.run())%0A%0A    def on_receive(self, packet):%0A        if self.state == LPDQNode.IN_TRANSMISSION:%0A            payload = packet.payload%0A            if type(payload) != DQFeedback:%0A                return # not valid packet%0A            if payload.slots%5Bself.chosen_slot%5D: # it's a successful request%0A                queue_position = 0%0A                for i in range(self.chosen_slot):%0A                    if payload.slots%5Bi%5D:%0A                        queue_position += 1%0A                self.sleep_time = payload.dtq + queue_position%0A                self.state = LPDQNode.DTQ%0A            else:%0A                # enter crq%0A                queue_position = 0%0A                for i in range(self.chosen_slot):%0A                    if not payload.slots%5Bi%5D:%0A                        queue_posiiton += 1%0A                self.sleep_time = payload.crq + queue_position%0A                self.state = LPDQNode.CRQ%0A%0A%0A    def run(self):%0A        while True:%0A            yield self.env.timeout(self.sleep_time)%0A            if self.state == LPDQNode.IDLE:%0A                # decide whether to transmit the packet%0A                if self.random.random() %3C self.rate: # needs to transmit%0A                    self.state = LPDQNode.IN_TRANSMISSION%0A%0A

add some code for LPDQ