Python Forum
configure delay on only one link using python3 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: configure delay on only one link using python3 (/thread-30434.html)



configure delay on only one link using python3 - HiImAl - Oct-21-2020

How can I configure the delay on ONLY ONE link (not on all) in python3 and mininet where I have link_parameters = {'delay': '%dms' % delay_ms}


     link_parameters = {'delay': '%dms' % delay_ms}
        logging.info('*** Add switches and links\n')
        logging.info("parameters: {}".format(link_parameters))
        #s0 = self.addSwitch('s0')
        #s1 = self.addSwitch('s1')
        ssource = None
        for i in range(1, switches+1):
            switch_current = self.addSwitch('s%d'%i)
            print("switch_current: {}".format(switch_current))
            if i == 1:
                print("\t add link h1 e switch_current=s%d" % (i))
                self.addLink(h1, switch_current, cls=TCLink, **link_parameters)
            else:
                print("\t add link switch_previous=s%d e switch_current=s%d"%(i-1, i))
                self.addLink(switch_previous, switch_current, cls=TCLink, **link_parameters)
    
            if i == switches:
                print("\t add link switch_current=s%d e h2" % (i))
                self.addLink(switch_current, h2, cls=TCLink, **link_parameters)
    
            switch_previous = switch_current
    
        #logging.info("parameters: {}".format(link_parameters))
         
    
        #self.addLink(s0, s1, cls=TCLink, **link_parameters)
        #self.addLink(s1, h2, cls=TCLink, **link_parameters)



RE: configure delay on only one link using python3 - HiImAl - Oct-21-2020

(Oct-21-2020, 01:54 AM)HiImAl Wrote: How can I configure the delay on ONLY ONE link (not on all) in python3 and mininet where I have link_parameters = {'delay': '%dms' % delay_ms} ? Basically I need to set the time (delay) of just one link round trip but I have no idea how to do this


     link_parameters = {'delay': '%dms' % delay_ms}
        logging.info('*** Add switches and links\n')
        logging.info("parameters: {}".format(link_parameters))
        #s0 = self.addSwitch('s0')
        #s1 = self.addSwitch('s1')
        ssource = None
        for i in range(1, switches+1):
            switch_current = self.addSwitch('s%d'%i)
            print("switch_current: {}".format(switch_current))
            if i == 1:
                print("\t add link h1 e switch_current=s%d" % (i))
                self.addLink(h1, switch_current, cls=TCLink, **link_parameters)
            else:
                print("\t add link switch_previous=s%d e switch_current=s%d"%(i-1, i))
                self.addLink(switch_previous, switch_current, cls=TCLink, **link_parameters)
    
            if i == switches:
                print("\t add link switch_current=s%d e h2" % (i))
                self.addLink(switch_current, h2, cls=TCLink, **link_parameters)
    
            switch_previous = switch_current
    
        #logging.info("parameters: {}".format(link_parameters))
         
    
        #self.addLink(s0, s1, cls=TCLink, **link_parameters)
        #self.addLink(s1, h2, cls=TCLink, **link_parameters)



RE: configure delay on only one link using python3 - HiImAl - Oct-21-2020

(Oct-21-2020, 01:09 PM)HiImAl Wrote:
(Oct-21-2020, 01:54 AM)HiImAl Wrote: How can I configure the delay on ONLY ONE link (not on all) in python3 and mininet where I have link_parameters = {'delay': '%dms' % delay_ms} ? Basically I need to set the time (delay) of just one link round trip but I have no idea how to do this


     link_parameters = {'delay': '%dms' % delay_ms}
        logging.info('*** Add switches and links\n')
        logging.info("parameters: {}".format(link_parameters))
        #s0 = self.addSwitch('s0')
        #s1 = self.addSwitch('s1')
        ssource = None
        for i in range(1, switches+1):
            switch_current = self.addSwitch('s%d'%i)
            print("switch_current: {}".format(switch_current))
            if i == 1:
                print("\t add link h1 e switch_current=s%d" % (i))
                self.addLink(h1, switch_current, cls=TCLink, **link_parameters)
            else:
                print("\t add link switch_previous=s%d e switch_current=s%d"%(i-1, i))
                self.addLink(switch_previous, switch_current, cls=TCLink, **link_parameters)
    
            if i == switches:
                print("\t add link switch_current=s%d e h2" % (i))
                self.addLink(switch_current, h2, cls=TCLink, **link_parameters)
    
            switch_previous = switch_current
    
        #logging.info("parameters: {}".format(link_parameters))
         
    
        #self.addLink(s0, s1, cls=TCLink, **link_parameters)
        #self.addLink(s1, h2, cls=TCLink, **link_parameters)



RE: configure delay on only one link using python3 - buran - Oct-21-2020

cross-posted at SO: https://stackoverflow.com/q/64470738/4046632