예제 #1
0
 def routeStreamPath(self, path, s, curTime):
     nodeA = path[0]
     as_nodeA = sg.gnGraph.netGraph.node[nodeA]
     for nodeB in path[1:]:
         as_nodeB = sg.gnGraph.netGraph.node[nodeB]
         link_AB = sg.gnGraph.netGraph[nodeA][nodeB]
         if 'p2p_link' not in link_AB:
             if sg.gnGraph.isAccessNode(
                     as_nodeA['type']
             ) or sg.gnGraph.isAccessNode(
                     as_nodeB['type']
             ):
                 link_AB['p2p_link'] = \
                     nl.netLink(
                         sg.BACKBONE_LINK_BANDWIDTH,
                         nodeA,
                         nodeB
                     )
             else:
                 link_AB['p2p_link'] = \
                     nl.netLink(
                         sg.FAST_BACKBONE_LINK_BANDWIDTH,
                         nodeA,
                         nodeB
                     )
         s.links.append(link_AB['p2p_link'])
         nodeA = nodeB
         as_nodeA = sg.gnGraph.netGraph.node[nodeA]
     if s.streamType == sg.STREAM_NOISE and not sg.simRef.simulatorReady:
         for l in s.links:
             l.netDataStreams.append(s)
         self.initStreamsList.append(s)
     else:
         sg.simRef.eventPush(
             se.event(
                 curTime + sg.PROPAGATION_DELAY*len(path),
                 id(s),
                 sg.EVENT_STREAM_START,
                 s
             )
         )
     return
예제 #2
0
 def __init__(self, cr, sip, dip, s, cnl=None, strType=sg.STREAM_NORMAL):
     self.transmitRate = 0
     self.bottleneckLinkID = None
     if cr is None:
         return
     #   fields up to this point are necessary for calcFairThroughput
     self.bottleneckLink = None
     self.useParallel = True
     self.tSeq = 0.0
     self.tParal = 0.0
     self.downloadedBit = 0
     self.sizeBit = s
     self.transmitPoint = None
     self.consumeRate = float(cr)
     self.srcIP = sip
     self.dstIP = dip
     self.links = []
     self.id = 0
     self.beingConsumed = False
     self.beingTransmitted = False
     self.consumePoint = 0
     self.consumedBit = 0
     self.bufferingBegin = 0.0
     self.eventRef_trComplete = None
     self.eventRef_consBegin = None
     self.eventRef_consComplete = None
     self.eventRef_bufferEmpty = None
     self.eventRef_expand = None
     self.eventRef_toLiveTRate = None
     self.stats_startTime = None
     self.stats_bufferingTime = 0.0
     self.stats_bufferingEvents = 0
     self.stats_bitRates = []
     self.collectBitrateStats = False
     self.stats_lastTransmitRate_time = 0
     self.stats_transmitRate_sumRates = 0
     self.stats_transmitRate_sumTime = 0
     self.interestingResult = False
     self.stats_events = []
     self.streamType = strType
     if strType == sg.STREAM_NORMAL or strType == sg.STREAM_NOISE:
         self.links.append(nl.netLink(sg.LAN_LINK_RATE, None, None))
     self.channel = cnl
     self.connectedToCache = False   # true when a stream is getting the data
     # from a cache node
     self.upCacheRef = None          # link to the upped level cache, the one
     # from which the stream gets its data
     self.downCacheRef = None        # link to the lower level cache, used to
     # enable cache hierarchy
     self.transmitingLive = False
     return
예제 #3
0
 def __init__(self, cr, sip, dip, s, cnl=None, strType=sg.STREAM_NORMAL):
     self.transmitRate = 0
     self.bottleneckLinkID = None
     if cr is None:
         return
     #   fields up to this point are necessary for calcFairThroughput
     self.bottleneckLink = None
     self.useParallel = True
     self.tSeq = 0.0
     self.tParal = 0.0
     self.downloadedBit = 0
     self.sizeBit = s
     self.transmitPoint = None
     self.consumeRate = float(cr)
     self.srcIP = sip
     self.dstIP = dip
     self.links = []
     self.id = 0
     self.beingConsumed = False
     self.beingTransmitted = False
     self.consumePoint = 0
     self.consumedBit = 0
     self.bufferingBegin = 0.0
     self.eventRef_trComplete = None
     self.eventRef_consBegin = None
     self.eventRef_consComplete = None
     self.eventRef_bufferEmpty = None
     self.eventRef_expand = None
     self.eventRef_toLiveTRate = None
     self.stats_startTime = None
     self.stats_bufferingTime = 0.0
     self.stats_bufferingEvents = 0
     self.stats_bitRates = []
     self.collectBitrateStats = False
     self.stats_lastTransmitRate_time = 0
     self.stats_transmitRate_sumRates = 0
     self.stats_transmitRate_sumTime = 0
     self.interestingResult = False
     self.stats_events = []
     self.streamType = strType
     if strType == sg.STREAM_NORMAL or strType == sg.STREAM_NOISE:
         self.links.append(nl.netLink(sg.LAN_LINK_RATE, None, None))
     self.channel = cnl
     self.connectedToCache = False  # true when a stream is getting the data
     # from a cache node
     self.upCacheRef = None  # link to the upped level cache, the one
     # from which the stream gets its data
     self.downCacheRef = None  # link to the lower level cache, used to
     # enable cache hierarchy
     self.transmitingLive = False
     return
예제 #4
0
 def routeStreamPath_inclCache(self, path, s, curTime, first=True):
     cacheOnDemand = sg.args.ondemandCache
     nodeA = path[0]
     as_nodeA = sg.gnGraph.netGraph.node[nodeA]
     for nodeB in path[1:]:
         link_AB = sg.gnGraph.netGraph[nodeA][nodeB]
         # Creating a link between node A and B, if it does not exist yet
         if 'p2p_link' not in link_AB:
             # if one of the nodes is an 'access' AS node then the link
             # speed is set to BACKBONE_LINK_BANDWIDTH
             if sg.gnGraph.isAccessNode(
                     as_nodeA['type']
             ) or sg.gnGraph.isAccessNode(
                 sg.gnGraph.netGraph.node[nodeB]['type']
             ):
                 link_AB['p2p_link'] = \
                     nl.netLink(
                         sg.BACKBONE_LINK_BANDWIDTH,
                         nodeA,
                         nodeB
                     )
             else:
                 link_AB['p2p_link'] = \
                     nl.netLink(
                         sg.FAST_BACKBONE_LINK_BANDWIDTH,
                         nodeA,
                         nodeB
                     )
         if nodeA == path[0] or not sg.LOCAL_CACHE_ONLY:
             # increase the cache-init counter and check the threshold
             if 'nCacheRequests' not in as_nodeA:
                 as_nodeA['nCacheRequests'] = [0] * sg.NUMBER_CHANNELS
             as_nodeA['nCacheRequests'][s.channel] += 1
             if as_nodeA['nCacheRequests'][s.channel] >= \
                     sg.args.cachethreshold:
                 # threshold passed, add a cache
                 # (all checks are inside the 'addCacheToAS')
                 cache = None
                 if 'static_cache' in as_nodeA:
                     cache = self.addCacheToAS(
                         nodeA,
                         curTime,
                         s.channel,
                         static=True
                     )
                 elif cacheOnDemand and first:
                     cache = self.addCacheToAS(nodeA, curTime, s.channel)
                 if cache is not None\
                         and cache != s.downCacheRef \
                         and cache.attachNetDataStream(s, curTime):
                     # 'attachNetDataStream' returns False if cache is not
                     # ready yet, if connected -> stop routing
                     break
         # if the stream is not connected to a
         # cache @ node A (or there is no cache @ node A)
         if not s.connectedToCache:
             # add the link from node A to node B to the stream path
             # (! this does not mean adding stream to all links along
             # the path, this is done later)
             s.links.append(link_AB['p2p_link'])
         nodeA = nodeB
         as_nodeA = sg.gnGraph.netGraph.node[nodeA]
     # background noise streams: adding stream to all links along
     # the path at init time
     if not sg.simRef.simulatorReady and s.streamType == sg.STREAM_NOISE:
         for l in s.links:
             l.netDataStreams.append(s)
         self.initStreamsList.append(s)
     else:
         # schedule 'start streaming' events
         if not s.connectedToCache:
             sg.simRef.eventPush(
                 se.event(
                     curTime + sg.PROPAGATION_DELAY*len(path),
                     id(s),
                     sg.EVENT_STREAM_START,
                     s
                 )
             )
     return