Esempio n. 1
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. 2
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. 3
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. 4
0
    def test_successful_transfer_TOTAL_PACKET_for_One_HOST(self):
        gel = Global_Event_List()
        gel.TOTAL_PACKET = 5
        initialEvent = ScheduleDataFrameEvent("internal DF", gel.current_time, gel.host_array[0], gel.host_array[2], 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)
Esempio n. 5
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()
        initialEvent = ScheduleDataFrameEvent("internal DF", gel.current_time, gel.host_array[0], gel.host_array[2], gel)
        gel.addEvent(initialEvent)

        # initialize the event
        gel_event_1 = gel.getNextEvent()
        gel_event_1.takeEffect(gel)
        # self.assertEqual(gel_event_1.name, "internal DF")

        gel_event_2 = gel.getNextEvent()
        gel_event_2.takeEffect(gel)
        # self.assertEqual(gel_event_2.name, "sense channel, df, stage 0")

        gel_event_3 = gel.getNextEvent()
        gel_event_3.takeEffect(gel)
        # self.assertEqual(gel_event_3.name, "sense channel, df, stage 1")

        gel_event_4 = gel.getNextEvent()
        gel_event_4.takeEffect(gel)
        # # self.assertEqual(gel_event_4.name, "push data to channel")
        #
        gel_event_5 = gel.getNextEvent()
        gel_event_5.takeEffect(gel)
        # # self.assertEqual(gel_event_5.name, "Departure Event, data")
        #
        # # Host 2 receive the packet from Host 1
        gel_event_6 = gel.getNextEvent()
        gel_event_6.takeEffect(gel)
        # # self.assertEqual(gel_event_6.name, "external DF")
        #
        # # Host 2 sense if the channel is idle or not
        gel_event_7 = gel.getNextEvent()
        gel_event_7.takeEffect(gel)
        # # self.assertEqual(gel_event_7.name, "sense channel, ack, stage 0")
        #
        gel_event_8 = gel.getNextEvent()
        gel_event_8.takeEffect(gel)
        # # self.assertEqual(gel_event_8.name, "sense channel, ack, stage 1")
        #
        gel_event_9 = gel.getNextEvent()
        gel_event_9.takeEffect(gel)
        # # self.assertEqual(gel_event_9.name, "push ack to channel")
        #
        gel_event_10 = gel.getNextEvent()
        gel_event_10.takeEffect(gel)
        # # self.assertEqual(gel_event_10.name, "Departure Event, ack")
        #
        gel_event_11 = gel.getNextEvent()
        gel_event_11.takeEffect(gel)
Esempio n. 6
0
from configuration_file import NUMBER_OF_HOST
from Host import Host
from Channel import Channel
from GEL import Global_Event_List

GEL = Global_Event_List()
print(GEL)



Esempio n. 7
0
        if ARRIVE_RATE >= 1 or ARRIVE_RATE <= 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()