Question

Python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following...

Python

Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following

  • A number of instance variables/fields to store a table of data. You can design them on your own.
  • A constructor that creates a table with the following:
    • a list of data.
    • IP address
    • an integer to indicate the number of elements in the sum_list/freq_list/average_list
  • A get_ip_address() method that returns the IP address

For example, consider the following code fragment:

ip_key = '192.168.0.24'
data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)]
size = 3
ip = IP_address(key, data_list, size)

The data_list contains a list of tuple objects. Each tuple consists of the time-period value and the packet-size. You should summarize this list and create a frequency list, a sum of the packet-size list and an average of the packet-size list. There are a lot of data for each time-period value. We calculate the total number of bytes that the source host sent for each 10-second interval. For example, the above data_list will be divided into 3 groups, such as (0-9 second), (10-19 second) and (20-29 second)

  • (0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84)
  • (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84)
  • (20, 84)

Therefore, the IP_address object should contain:

  • the IP address: '192.168.0.24'
  • a frequency list: [10, 10, 1] (i.e. there are 10 elements in the first group, 10 elements in the second group and 1 element in the third group)

This will give

ip_key = '192.168.0.24'
data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)]
size = 3
ip = IP_address(ip_key, data_list, size)
print(ip.get_ip_address())
192.168.0.24

And

  • modify the constructor and create the frequency list
  • add a method named get_freq_list(). The get_freq_list() method return a list of frequency lists (i.e. if the frequency list is [10, 10, 1], then the get_freq_list() should return [[0, 10], [1, 10], [2, 1]]

For example, consider the following code fragment:

ip_key = '192.168.0.24'
data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)]
size = 3
ip = IP_address(key, data_list, size)

The data_list contains a list of tuple objects.

  • (0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84)
  • (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84)
  • (20, 84)

Therefore, the IP_address object should contain:

  • ip address: '192.168.0.24'
  • a frequency list: [10, 10, 1] (i.e. there are 10 elements in the first group, 10 elements in the second group and 1 element in the third group)
ip_key = '192.168.0.24'
data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), 
(6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), 
(16, 84), (17, 84), (18, 84), (19, 84), (20, 84)]
size = 3
ip = IP_address(ip_key, data_list, size)
print(ip.get_freq_list())
[[0, 10], [1, 10], [2, 1]]
 
ip_key = '192.168.0.24'
data_list = [(0, 84), (1, 84), (2, 84), (3, 84), (4, 84)]
size = 3
ip = IP_address(ip_key, data_list, size)
print(ip.get_freq_list())
[[0, 5], [1, 0], [2, 0]]
 
ip_key = '192.168.0.2'
data_list = [(33, 60), (34, 64), (34, 1500), (34, 712), (35, 52), (35, 60), (36, 52), (36, 287), (37, 52), (37, 52), (37, 52), (39, 60), (40, 643), (40, 52)]
size = 5
ip = IP_address(ip_key, data_list, size)
print(ip.get_freq_list())
[[0, 0], [1, 0], [2, 0], [3, 12], [4, 2]]

Homework Answers

Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !!

================================================================================================

class IP_address():

    def __init__(self,key,data_list,size):
        self.ip_key=key
        self.data_list=data_list
        self.size=size

    def get_ip_address(self):
        return self.ip_key

    def get_freq_list(self):

        frequencies=[0 for i in range(self.size)]
        for data in self.data_list:
            index = data[0]//10
            if index<self.size:
                frequencies[index]+=1

        return [list(e) for e in zip([i for i in range(self.size)],frequencies)]


ip_key = '192.168.0.2'
data_list = [(33, 60), (34, 64), (34, 1500), (34, 712), (35, 52), (35, 60), (36, 52), (36, 287), (37, 52), (37, 52), (37, 52), (39, 60), (40, 643), (40, 52)]
size = 5
ip = IP_address(ip_key, data_list, size)
print(ip.get_freq_list())

=======================================================================================

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python Design a class named IP_address to represent IP address objects. The IP_address class contains the...
Python Design a class named IP_address to represent IP address objects. The IP_address class contains the following A number of instance variables/fields to store a table of data. You can design them by your own. A constructor that creates a table with the following: a list of data. ip address a integer to indicate the number of elements in the sum_list/freq_list/average_list A get_ip_address() method that returns the ip address For example, consider the following code fragment: ip_key = '192.168.0.24' data_list...
I need a breakdown to perform in excel for numbers 7,8,9. I am unsure of how...
I need a breakdown to perform in excel for numbers 7,8,9. I am unsure of how I calculate the times. heres the data set and the questions. Calculate the probability that a flight will depart early or on time. Calculate the probability that a flight will arrive late. Calculate the probability that a flight departs late or arrives early. DEP_Delay ARR_Delay -4 0 -3 -3 0 -5 -7 -1 8 3 -1 -5 3 8 11 6 -6 0 -5...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16 10 17 14 14 16 7 10 12 19 15 16 14 9 12 21 13 10 16 12 16 13 17 17 13 14 18 11 12 15 16 13 18 16 17 12 12 14 9 11 14 19 13 11 17 11 13 15 14 18 18 18 12 10 11 13 14 11 14 18 13 13 19 17 14...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16...
Cork price: 16 10 15 10 17 11 14 13 11 14 11 16 18 16 10 17 14 14 16 7 10 12 19 15 16 14 9 12 21 13 10 16 12 16 13 17 17 13 14 18 11 12 15 16 13 18 16 17 12 12 14 9 11 14 19 13 11 17 11 13 15 14 18 18 18 12 10 11 13 14 11 14 18 13 13 19 17 14...
The following frequency table summarizes 60 data values. What is the 80th percentile of the data?...
The following frequency table summarizes 60 data values. What is the 80th percentile of the data? The table is read from left to right. 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 6 6 6 7 7 8 8 9 9 9 9 10 11 11 11 11 11 12 12 12 12 13 13 13 14 14 14 14 15 15 15 16 17 17 17 17 17 18 19 19 20...
Let S be the universal set, where: S = { 1 , 2 , 3 ,...
Let S be the universal set, where: S = { 1 , 2 , 3 , ... , 18 , 19 , 20 } Let sets A and B be subsets of S, where: Set A = { 2 , 5 , 6 , 10 , 16 , 17 } Set B = { 5 , 6 , 9 , 11 , 15 , 16 , 17 , 18 , 20 } C = { 2 , 3 , 4...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS")...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS") calculate the correlation between the GAS – Goal disengagement and the GAS – Goal reengagement scores. Write the results in a statistical statement. 7. Using the class data calculate the correlation between the GAS – Goal disengagement and the PSS-10 scores. Write the results in a statistical statement. 8. Using the class data calculate the correlation between the GAS – Goal reengagement scores and...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing text files, writing functions, and program planning and development. You will read a data file and store all of the input data in a two dimensional array. You will perform calculations on the data and store the results in the 2 dimensional array. You will sort the array and print the results in a report. Instructions You will read in the same input file...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population...
Assuming that the population standard deviation is unknown, calculate the 95% confidence interval of the population mean. The following is the data. Calculating Process should be shown by Excel (Formulas). What formulas in statistics are used? 7 21 23 24 18 16 2 19 11 6 3 13 17 9 5 12 13 17 4 14 15 25 12 24 22 14 14 20 15 11 26 17 21 11 4 13 16 14 13 14 25 23 9 15...
The table below contains two samples (X and Y). Please construct a test where the null...
The table below contains two samples (X and Y). Please construct a test where the null hypothesis is that the population mean Y exceeds the population mean X by exactly 3. Please note that we don't know the population standard deviations and can't assume that they are equal. Please state the p-value of your test. X Y 15 13 10 13 11 12 12 19 11 14 17 15 11 19 16 18 15 14 10 12 17 12 16...