Esempio n. 1
0
    def test_successful_transfer_cycle_without_RBA(self):
        """
        To test if an arrival dataframe event can take effect smoothly
        :return:
        """
        gel = Global_Event_List()
        for x in gel.host_array[0:2]:
            initialEvent = ScheduleDataFrameEvent("internal DF",
                                                  gel.current_time, x,
                                                  gel.getRandomHost(x), gel)
            gel.addEvent(initialEvent)

        # initialize the event
        """
        Timer 1 for 1 is created, and it will be ready at 1.2062966341753119
        Timer 1 will ring at 1.2142218689806692


        """
        event_run = 100
        start_at = 40
        for x in range(event_run):
            gel_event_11 = gel.getNextEvent()
            gel_event_11.takeEffect(gel)
            if x > start_at - 2:
                print(gel_event_11.description())
        self.assertEqual(gel_event_11.name, "success transfer")
Esempio n. 2
0
    def test_successful_transfer_TOTAL_PACKET_for_One_HOST(self):
        gel = Global_Event_List()
        for x in gel.host_array[0:1]:
            initialEvent = ScheduleDataFrameEvent("internal DF",
                                                  gel.current_time, x,
                                                  gel.getRandomHost(x), gel)
            gel.addEvent(initialEvent)

        while gel.packet_counter <= gel.TOTAL_PACKET:
            # print(gel.packet_counter)
            gel_event = gel.getNextEvent()

            if gel_event == None:
                break
            else:
                gel_event.takeEffect(gel)
                print(gel_event.description())
        gel.draw_event_timeline()
        self.assertEqual(gel_event_11.name, "success transfer")
Esempio n. 3
0
    def test_successful_transfer_TOTAL_PACKET_for_TWO_HOST(self):
        gel = Global_Event_List()
        gel.TOTAL_PACKET = 20
        for x in gel.host_array:
            initialEvent = ScheduleDataFrameEvent("internal DF", gel.current_time, x, gel.getRandomHost(x), gel)
            gel.addEvent(initialEvent)
        #
        # num = 100
        # for x in range(0, num):
        #     gel_event = gel.getNextEvent()
        #     gel_event.dataframe.globalID = gel.packet_counter
        #     print(gel_event)
        #     gel_event.takeEffect(gel)
        #
        # gel.draw_event_timeline()

        gel_event = True
        try:
            while gel_event:
                gel_event = gel.getNextEvent()
                gel_event.dataframe.globalID = gel.packet_counter
                gel_event.takeEffect(gel)

        except Exception as e:
            gel.draw_event_timeline()
            print(e)
Esempio n. 4
0
            print("Error: must be a number between 0 and 1")
        else:
            break
    except:
        print("Error: must be a number between 0 and 1")

config = configparser.ConfigParser()
config.read("configuration_file.ini")
config.set("DEFAULT", "NUMBER_OF_HOST", str(NUMBER_OF_HOST))
config.set("DEFAULT", "ARRIVE_RATE", str(ARRIVE_RATE))

with open('configuration_file.ini', 'w') as configfile:
    config.write(configfile)

gel = Global_Event_List()

for x in gel.host_array:
    initialEvent = ScheduleDataFrameEvent("internal DF", gel.current_time, x, gel.getRandomHost(x), gel)
    gel.addEvent(initialEvent)
    gel_event = True

while gel_event:
    gel_event = gel.getNextEvent()
    if gel_event != None:
        gel_event.dataframe.globalID = gel.packet_counter
        gel_event.takeEffect(gel)
        print(gel_event.description())

average_throughput = gel.calculate_throughput()
average_delay = gel.calculate_average_network_delay()
print(f"The average throughput is {average_throughput}, The average_dealy is {average_delay}")