Revision 2e3258d2 mininet/link.py

View differences:

mininet/link.py
226 226
    # For higher data rates, we will probably need to change them.
227 227
    bwParamMax = 1000
228 228

  
229
    def __init__( self, name, node=None, port=None, link=None, mac=None, **params ):
230
        super(TCIntf,self).__init__(name, node, port, link, mac, **params)
231
        self.params = params
232
        self.config( **params )
233

  
229 234
    def bwCmds( self, bw=None, speedup=0, use_hfsc=False, use_tbf=False,
230 235
                latency_ms=None, enable_ecn=False, enable_red=False ):
231 236
        "Return tc commands to set bandwidth"
......
278 283
        return cmds, parent
279 284

  
280 285
    @staticmethod
281
    def delayCmds( parent, delay=None, jitter=None,
286
    def delayCmds( parent, delay=None, jitter=None, delay_distribution=None,
282 287
                   loss=None, max_queue_size=None ):
283 288
        "Internal method: return tc commands for delay and loss"
284 289
        cmds = []
......
290 295
            error( 'Bad loss percentage', loss, '%%\n' )
291 296
        else:
292 297
            # Delay/jitter/loss/max queue size
293
            netemargs = '%s%s%s%s' % (
298
            netemargs = '%s%s%s%s%s' % (
294 299
                'delay %s ' % delay if delay is not None else '',
295 300
                '%s ' % jitter if jitter is not None else '',
301
                'distribution %s ' % delay_distribution if delay_distribution is not None else '',
296 302
                'loss %d ' % loss if loss is not None else '',
297 303
                'limit %d' % max_queue_size if max_queue_size is not None
298 304
                else '' )
......
309 315
        debug(" *** executing command: %s\n" % c)
310 316
        return self.cmd( c )
311 317

  
312
    def config( self, bw=None, delay=None, jitter=None, loss=None,
318
    def config( self, bw=None, delay=None, jitter=None, loss=None, delay_distribution=None,
313 319
                disable_gro=True, speedup=0, use_hfsc=False, use_tbf=False,
314 320
                latency_ms=None, enable_ecn=False, enable_red=False,
315 321
                max_queue_size=None, **params ):
316 322
        "Configure the port and set its properties."
317 323

  
318
        result = Intf.config( self, **params)
324
        result = super(TCIntf, self).config( self, **params)
319 325

  
320 326
        # Disable GRO
321 327
        if disable_gro:
......
344 350

  
345 351
        # Delay/jitter/loss/max_queue_size using netem
346 352
        delaycmds, parent = self.delayCmds( delay=delay, jitter=jitter,
353
                                            delay_distribution=delay_distribution,
347 354
                                            loss=loss,
348 355
                                            max_queue_size=max_queue_size,
349 356
                                            parent=parent )
......
525 532
    def __init__( self, node1, node2, port1=None, port2=None,
526 533
                  intfName1=None, intfName2=None,
527 534
                  addr1=None, addr2=None, **params ):
535
        if 'params1' in params.keys():
536
            prms1 = params['params1']
537
        else:
538
            prms1 = None
539
        if 'params2' in params.keys():
540
            prms2 = params['params2']
541
        else:
542
            prms2 = None
528 543
        Link.__init__( self, node1, node2, port1=port1, port2=port2,
529 544
                       intfName1=intfName1, intfName2=intfName2,
530 545
                       cls1=TCIntf,
531 546
                       cls2=TCIntf,
532 547
                       addr1=addr1, addr2=addr2,
533
                       params1=params,
534
                       params2=params )
548
                       params1=prms1,
549
                       params2=prms2 )

Also available in: Unified diff