def to_layer_three(AorB, pkt): if random.uniform(0, 1) < sim.lossprob: return packet = copy.deepcopy(pkt) if random.uniform(0, 1) < sim.corruptprob: if packet.payload != 0: packet.payload.data = packet.payload.data[0:-1] + "*" else: packet.seqnum = -1 q = sim.envlist.head lasttime = sim.time while q != None: if q.eventity == AorB and q.evtype == "FROM_LAYER3": lasttime = q.evtime q = q.next eventime = lasttime + 1 + 9 * random.uniform(0, 1) if AorB == "A": sim.envlist.insert(event(eventime, "FROM_LAYER3", "B", packet)) else: sim.envlist.insert(event(eventime, "FROM_LAYER3", "A", packet))
def generate_next_arrival(self): time = self.time + self.Lambda self.envlist.insert(event(time, "FROM_LAYER5", "A")) return