Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

Within Mininet, create the following topology. Here h1 is a remote server (ie…

  1. User

    Within Mininet, create the following topology. Here h1 is a remote server (ie google.com) on the Internet that has a fast connection (1Gb/s) to your home router with a slow downlink connection (10Mb/s). The round-trip propagation delay, or the minimum RTT between h1 and h2 is 6ms. The router buffer size can hold 100 full sized ethernet frames (about 150kB with an MTU of 1500 bytes). Then do the following: Start a long lived TCP flow sending data from h1 to h2. Use iperf. . Send pings from h1 to h2 10 times a second and record the RTTs. .Plot the time series of the following: o The long lived TCP flow’s cwnd o The RTT reported by ping o Queue size at the bottleneck . Spawn a webserver on h1. Periodically download the index.html web page (three times every five seconds) from h1 and measure how long it takes to fetch it (on average). The starter code has some hints on how to do this. Make sure that the webpage download data is going in the same direction as the long-lived flow. The long lived flow, ping train, and web server downloads should all be happening simultaneously. Repeat the above experiment and replot all three graphs with a smaller router buffer size (Q=20 packets). write code in python

  2. Assistant

    Here is an example code in Python to create the desired Mininet topology and perform the experiments:

    from mininet.net import Mininet
    from mininet.node import RemoteController
    from mininet.link import TCLink
    
    def create_topology():
        net = Mininet(controller=RemoteController)
        net.addController('c0')
    
        h1 = net.addHost('h1')
        h2 = net.addHost('h2')
        router = net.addSwitch('router')
    
        net.addLink(h1, router, bw=10, delay='6ms', max_queue_size=100)
        net.addLink(router, h2)
    
        net.start()
    
        return net, h1, h2
    
    def start_tcp_flow(h1, h2):
        h2.cmd('iperf -s &')  # Start iperf server on h2
        h1.cmd('iperf -c {} -t 10'.format(h2.IP()))  # Start iperf client on h1 for 10 seconds
    
    def measure_rtt(h1, h2):
        result = h1.cmd('ping -c 10 {}'.format(h2.IP()))
        # Parse the ping result to extract RTT values
        rtt_values = []
        for line in result.split('\n'):
            if 'time=' in line:
                rtt = line.split('time=')[1].split(' ')[0]
                rtt_values.append(float(rtt))
        return rtt_values
    
    def measure_queue_size(router):
        queue_size = router.cmd('tc qdisc show dev {}'.format(router.intfs[1]))
        return int(queue_size.split('len ')[1])
    
    def start_web_server(h1):
        h1.cmd('python3 -m http.server 80 &')  # Start web server on h1
    
    def measure_webpage_download_time(h1, num):
        download_times = []
        for _ in range(num):
            time = h1.cmd('curl -o /dev/null -w "%{{time_total}}" http://{}:80/index.html'.format(h1.IP()))
            download_times.append(float(time))
        return download_times
    
    def main():
        net, h1, h2 = create_topology()
        start_tcp_flow(h1, h2)
        rtt_values = measure_rtt(h1, h2)
        queue_sizes = []
        web_download_times = []
    
        for _ in range(10):
            queue_sizes.append(measure_queue_size(net.get('router')))
            web_download_times.extend(measure_webpage_download_time(h1, 3))
            time.sleep(0.1)  # Wait 0.1s between pings
    
        # Plot the time series of TCP cwnd, ping RTT, and queue size
        # Use matplotlib to plot the graphs
    
        # Repeat the experiment with a smaller router buffer size (Q=20)
        net.stop()
        net, h1, h2 = create_topology()
        h1.cmd('tc qdisc change dev h1-eth0 root netem delay 6ms limit 20')
        start_tcp_flow(h1, h2)
        rtt_values = measure_rtt(h1, h2)
        queue_sizes = []
        web_download_times = []
    
        for _ in range(10):
            queue_sizes.append(measure_queue_size(net.get('router')))
            web_download_times.extend(measure_webpage_download_time(h1, 3))
            time.sleep(0.1)  # Wait 0.1s between pings
    
        # Plot the time series of TCP cwnd, ping RTT, and queue size with smaller buffer size
    
    if __name__ == '__main__':
        main()
    

    Note that this code assumes you have Mininet and necessary dependencies installed. Also, you might need to modify the commands based on your specific network setup. Make sure to install iperf and curl on the hosts h1 and h2 respectively. You will also need to install matplotlib for plotting the graphs.