示例#1
0
 def test_read_write_tm(self):
     tm = fnss.static_traffic_matrix(self.G, mean=10, stddev=0.1, max_u=0.9)
     tmp_tm_file = path.join(TMP_DIR, 'tms.xml')
     fnss.write_traffic_matrix(tm, tmp_tm_file)
     read_tm = fnss.read_traffic_matrix(tmp_tm_file)
     u, v = tm.od_pairs()[2]
     self.assertAlmostEqual(tm[(u, v)], read_tm[(u, v)])
示例#2
0
 def test_read_write_tm(self):
     tm = fnss.static_traffic_matrix(self.G, mean=10, stddev=0.1, max_u=0.9)
     tmp_tm_file = path.join(TMP_DIR, 'tms.xml')
     fnss.write_traffic_matrix(tm, tmp_tm_file)
     read_tm = fnss.read_traffic_matrix(tmp_tm_file)
     u, v = tm.od_pairs()[2]
     self.assertAlmostEqual(tm[(u, v)], read_tm[(u, v)])
示例#3
0
 def test_read_write_tms(self):
     tms = fnss.stationary_traffic_matrix(self.G, mean=10, stddev=0.1, gamma=1.2, 
                                     log_psi=-0.3, n=5, max_u=0.9)
     tmp_tms_file = path.join(TMP_DIR, 'tms.xml')
     fnss.write_traffic_matrix(tms, tmp_tms_file)
     read_tms = fnss.read_traffic_matrix(tmp_tms_file)
     u, v = tms[3].od_pairs()[2]
     self.assertAlmostEqual(tms[3][(u, v)], read_tms[3][(u, v)])
示例#4
0
 def test_read_write_tms(self):
     tms = fnss.stationary_traffic_matrix(self.G, mean=10, stddev=0.1, gamma=1.2, 
                                     log_psi=-0.3, n=5, max_u=0.9)
     tmp_tms_file = path.join(TMP_DIR, 'tms.xml')
     fnss.write_traffic_matrix(tms, tmp_tms_file)
     read_tms = fnss.read_traffic_matrix(tmp_tms_file)
     u, v = tms[3].od_pairs()[2]
     self.assertAlmostEqual(tms[3][(u, v)], read_tms[3][(u, v)])
示例#5
0
                        links=topology.edges(),  # 'links' argument
                        )

# Now let's create a schedule with link restoration events
# We assume that the duration of a failure is exponentially distributed with
# average 1 minute.
restore_schedule = fnss.EventSchedule(t_start=0, t_unit='min')
for failure_time, event in event_schedule:
    link = event['link']
    restore_time = failure_time + random.expovariate(1)
    restore_schedule.add(time=restore_time,
                         event={'link': link, 'action': 'up'},
                         absolute_time=True
                         )

# Now merge failure and restoration schedules
# After merging events are still chronologically sorted
event_schedule.add_schedule(restore_schedule)

# Note: there are several ways to create this link failure-restoration schedule
# This method has been used to illustrate a variety of functions and methods
# that FNSS provides to manipulate event schedules

# Write topology, event schedule and traffic matrix to files
fnss.write_topology(topology, 'topology.xml')
fnss.write_event_schedule(event_schedule, 'event_schedule.xml')
fnss.write_traffic_matrix(traffic_matrix, 'traffic_matrix.xml')



示例#6
0
    event_generator=rand_failure,  # event gen function
    links=topology.edges(),  # 'links' argument
)

# Now let's create a schedule with link restoration events
# We assume that the duration of a failure is exponentially distributed with
# average 1 minute.
restore_schedule = fnss.EventSchedule(t_start=0, t_unit='min')
for failure_time, event in event_schedule:
    link = event['link']
    restore_time = failure_time + random.expovariate(1)
    restore_schedule.add(time=restore_time,
                         event={
                             'link': link,
                             'action': 'up'
                         },
                         absolute_time=True)

# Now merge failure and restoration schedules
# After merging events are still chronologically sorted
event_schedule.add_schedule(restore_schedule)

# Note: there are several ways to create this link failure-restoration schedule
# This method has been used to illustrate a variety of functions and methods
# that FNSS provides to manipulate event schedules

# Write topology, event schedule and traffic matrix to files
fnss.write_topology(topology, 'topology.xml')
fnss.write_event_schedule(event_schedule, 'event_schedule.xml')
fnss.write_traffic_matrix(traffic_matrix, 'traffic_matrix.xml')
示例#7
0
       stddev=0.05,  # this is the std among average flows of different OD pairs
       gamma=0.8,  # gamma and log_psi are parameters for fitting the std of
       log_psi=-0.33,  # volume fluctuations over time. Look at Nucci et al. paper
       delta=0.2,  # traffic variation from period max and avg as fraction of average
       n=24,  # number of samples per each period
       periods=7,  # number of periods
       max_u=0.9,  # max link utilization desired
       origin_nodes=None,  # Specify origin and destination nodes. If None,
       destination_nodes=None  # all nodes of the topology are both
       )  # origin and destination nodes of traffic


# now we generate a static traffic matrix, but this time instead of generating
# a matrix where all nodes are both origin and destinations, we pick up only
# few nodes as sources and destinations of traffic.
# Let's select 5 sources and 5 destinations
nodes = topology.nodes()
origins = random.sample(nodes, 5)
destinations = random.sample(nodes, 5)
# generate traffic matrix
tms = fnss.static_traffic_matrix(topology, mean=0.5, stddev=0.05, max_u=0.9,
                                 origin_nodes=origins,
                                 destination_nodes=destinations)

# save topology on a file
fnss.write_topology(topology, 'topology.xml')

# save traffic matrices on files
fnss.write_traffic_matrix(tmc, 'cyclostationary-traffic-matrix.xml')
fnss.write_traffic_matrix(tms, 'static-traffic-matrix.xml')
示例#8
0
event_schedule = fnss.poisson_process_event_schedule(
    avg_interval=0.5,  # 0.5 min = 30 sec
    t_start=0,  # starts at 0
    duration=60,  # 2 hours
    t_unit="min",  # minutes
    event_generator=rand_failure,  # event gen function
    links=topology.edges(),  # 'links' argument
)

# Now let's create a schedule with link restoration events
# We assume that the duration of a failure is exponentially distributed with
# average 1 minute.
restore_schedule = fnss.EventSchedule(t_start=0, t_unit="min")
for failure_time, event in event_schedule:
    link = event["link"]
    restore_time = failure_time + random.expovariate(1)
    restore_schedule.add(time=restore_time, event={"link": link, "action": "up"}, absolute_time=True)

# Now merge failure and restoration schedules
# After merging events are still chronologically sorted
event_schedule.add_schedule(restore_schedule)

# Note: there are several ways to create this link failure-restoration schedule
# This method has been used to illustrate a variety of functions and methods
# that FNSS provides to manipulate event schedules

# Write topology, event schedule and traffic matrix to files
fnss.write_topology(topology, "topology.xml")
fnss.write_event_schedule(event_schedule, "event_schedule.xml")
fnss.write_traffic_matrix(traffic_matrix, "traffic_matrix.xml")