项目作者: PrincetonUniversity

项目描述 :
SDN Coursera课程
高级语言: Python
项目地址: git://github.com/PrincetonUniversity/Coursera-SDN.git
创建时间: 2015-05-24T18:42:33Z
项目社区:https://github.com/PrincetonUniversity/Coursera-SDN

开源协议:

下载


Coursera SDN Virtual Machine Setup

Setting up the course VM

Prerequisite

To get started install these softwares on your host machine:

  1. Install Vagrant, it is a wrapper around virtualization softwares like VirtualBox, VMWare etc.: http://www.vagrantup.com/downloads

  2. Install VirtualBox, this would be your VM provider: https://www.virtualbox.org/wiki/Downloads

  3. Install Git, it is a distributed version control system: https://git-scm.com/downloads

  4. Install X Server and SSH capable terminal

    • For Windows install Xming and Putty.
    • For MAC OS install XQuartz and Terminal.app (builtin)
    • Linux comes pre-installed with X server and Gnome terminal + SSH (buitlin)

Basics

  • Clone the course repository from Github:

    1. $ git clone https://github.com/PrincetonUniversity/Coursera-SDN
  • Change the directory to Coursera-SDN:

    1. $ cd Coursera-SDN
  • Now run the vagrant up command. This will read the Vagrantfile from the current directory and provision the VM accordingly:

    1. $ vagrant up

If you want to tear down your vagrant session, you have multiple options to do so, each has its pros and cons. These options are as follows:

  • vagrant suspend: With this option you will be able to save the state of the VM and stop it.
  • vagrant halt: This will gracefully shutdown the guest operating system and power down the guest machine.
  • vagrant destroy: If you want to remove all traces of the guest machine from your system, this is the command you should use. It will power down the machine and remove all guest hard disks

Go here for more information about vagrant teardown.

Note: By default it will instantiate a 64 bit VM. In case you want to run a 32 bit VM, you will need to change the config.vm.box_url parameter in the Vagrantfile as shown below:

  1. ## 64 bit Vagrant Box
  2. #config.vm.box_url = "https://d396qusza40orc.cloudfront.net/sdn1/srcs/Vagrant%20Box/coursera-sdn-2015_64bit.box"
  3. ## 32 bit Vagrant Box
  4. config.vm.box_url = "https://d396qusza40orc.cloudfront.net/sdn1/srcs/Vagrant%20Box/coursera-sdn-2015_32bit.box"
  • Now SSH into the VM:
    1. $ vagrant ssh
  • Programming assignments: You will find the programming assignments in the vm under the directory: /vagrant/assignments.

    1. vagrant@coursera-sdn:~$ ls /vagrant/
    2. assignments README.md setup Vagrantfile
  • To perform a simple test to check if your VM setup is correct, run the command:

    1. sudo mn

    This will start a Mininet bash terminal. Type xterm h1 h2 in this terminal. If two external terminals pop out, then your setup worked as expected.

Notes and Tips for running vagrant and the course VM

  • Follow the instructions closely
  • If you are running a 64bit OS, run a 64 bit VM
  • If you are running a 32bit OS, run a 32 bit VM
  • Disable Hyper-V on Windows
  • Enable Virtualization support on the host (BIOS setup)
  • The VM runs 192.168.0.0/24 as default network, if you use that network locally you need to change it (edit Vagrantfile: config.vm.network :private_network, ip: “192.168.0.100”)
  • The host machine needs to run an X server (it’s native on Linux; OS X and Windowns require the installation of an X Server)
  • Alternative methods to ssh to the VM: run “ssh -X vagrant@192.168.0.100” password is vagrant
  • If you see “ssh_exchange_identification: read: Connection reset by peer” when trying to connect using “vagrant ssh” use the alternative method provided above since it has been reported as a valid workaround, this issue is under investigation
  • The shared folder: “Coursera-SDN” git cloned folder for the host and /vagrant for the guest
  • Some students reported that on old/slower machines some assignments might fail because of extra delay on the computation wich translates to increaced delay on ping request/response. The original default vagrant configuration for VBox was 2Gb RAM and 1 CPU with 50% cap. We changed this to 1GB RAM and 1 CPU with no cap. We think this new configuration will be good for most, but if you want to you can always tweek this to your requirements or likings (edit the line that starts with “# CPU & RAM” on Vagrantfile)

Sample setup output for reference

  • Following output is from MacOS
  1. Coursera-SDN TestUser$ vagrant up
  2. Bringing machine 'default' up with 'virtualbox' provider...
  3. ==> default: Clearing any previously set network interfaces...
  4. ==> default: Preparing network interfaces based on configuration...
  5. default: Adapter 1: nat
  6. default: Adapter 2: hostonly
  7. ==> default: Forwarding ports...
  8. default: 6633 => 6635 (adapter 1)
  9. default: 22 => 2222 (adapter 1)
  10. ==> default: Booting VM...
  11. ==> default: Waiting for machine to boot. This may take a few minutes...
  12. default: SSH address: 127.0.0.1:2222
  13. default: SSH username: vagrant
  14. default: SSH auth method: private key
  15. default: Warning: Connection timeout. Retrying...
  16. default: Warning: Connection timeout. Retrying...
  17. default: Warning: Remote connection disconnect. Retrying...
  18. ==> default: Machine booted and ready!
  19. ==> default: Checking for guest additions in VM...
  20. ==> default: Setting hostname...
  21. ==> default: Configuring and enabling network interfaces...
  22. ==> default: Mounting shared folders...
  23. default: /vagrant => /Users/TestUser/git/Coursera-SDN
  24. TestUser-MBP:Coursera-SDN TestUser$ vagrant ssh
  25. Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-49-generic x86_64)
  26. * Documentation: https://help.ubuntu.com/
  27. System information disabled due to load higher than 1.0
  28. Get cloud support with Ubuntu Advantage Cloud Guest:
  29. http://www.ubuntu.com/business/services/cloud
  30. Last login: Mon May 25 18:00:05 2015 from 10.0.2.2
  31. vagrant@coursera-sdn:~$ ls /vagrant/
  32. assignments README.md setup Vagrantfile
  33. vagrant@coursera-sdn:~$ sudo mn
  34. *** Creating network
  35. *** Adding controller
  36. *** Adding hosts:
  37. h1 h2
  38. *** Adding switches:
  39. s1
  40. *** Adding links:
  41. (h1, s1) (h2, s1)
  42. *** Configuring hosts
  43. h1 h2
  44. *** Starting controller
  45. c0
  46. *** Starting 1 switches
  47. s1 ...
  48. *** Starting CLI:
  49. mininet> help
  50. Documented commands (type help <topic>):
  51. ========================================
  52. EOF gterm iperfudp nodes pingpair py switch
  53. dpctl help link noecho pingpairfull quit time
  54. dump intfs links pingall ports sh x
  55. exit iperf net pingallfull px source xterm
  56. You may also send a command to a node using:
  57. <node> command {args}
  58. For example:
  59. mininet> h1 ifconfig
  60. The interpreter automatically substitutes IP addresses
  61. for node names when a node is the first arg, so commands
  62. like
  63. mininet> h2 ping h3
  64. should work.
  65. Some character-oriented interactive commands require
  66. noecho:
  67. mininet> noecho h2 vi foo.py
  68. However, starting up an xterm/gterm is generally better:
  69. mininet> xterm h2
  70. mininet> h1 ifconfig
  71. h1-eth0 Link encap:Ethernet HWaddr 12:1e:ad:14:fe:b3
  72. inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0
  73. inet6 addr: fe80::101e:adff:fe14:feb3/64 Scope:Link
  74. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  75. RX packets:14 errors:0 dropped:0 overruns:0 frame:0
  76. TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
  77. collisions:0 txqueuelen:1000
  78. RX bytes:1128 (1.1 KB) TX bytes:648 (648.0 B)
  79. lo Link encap:Local Loopback
  80. inet addr:127.0.0.1 Mask:255.0.0.0
  81. inet6 addr: ::1/128 Scope:Host
  82. UP LOOPBACK RUNNING MTU:65536 Metric:1
  83. RX packets:0 errors:0 dropped:0 overruns:0 frame:0
  84. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
  85. collisions:0 txqueuelen:0
  86. RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
  87. mininet>
  88. mininet>
  89. mininet> h1 ping h2
  90. PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
  91. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=2.15 ms
  92. 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.331 ms
  93. 64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.165 ms
  94. 64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.073 ms
  95. 64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=0.085 ms
  96. 64 bytes from 10.0.0.2: icmp_seq=6 ttl=64 time=0.035 ms
  97. 64 bytes from 10.0.0.2: icmp_seq=7 ttl=64 time=0.099 ms
  98. 64 bytes from 10.0.0.2: icmp_seq=8 ttl=64 time=0.088 ms
  99. 64 bytes from 10.0.0.2: icmp_seq=9 ttl=64 time=0.139 ms
  100. 64 bytes from 10.0.0.2: icmp_seq=10 ttl=64 time=0.089 ms
  101. ^C
  102. --- 10.0.0.2 ping statistics ---
  103. 10 packets transmitted, 10 received, 0% packet loss, time 9016ms
  104. rtt min/avg/max/mdev = 0.035/0.326/2.156/0.614 ms
  105. mininet> pingall
  106. *** Ping: testing ping reachability
  107. h1 -> h2
  108. h2 -> h1
  109. *** Results: 0% dropped (2/2 received)
  110. mininet> pingallfull
  111. *** Ping: testing ping reachability
  112. h1 -> h2
  113. h2 -> h1
  114. *** Results:
  115. h1->h2: 1/1, rtt min/avg/max/mdev 0.850/0.850/0.850/0.000 ms
  116. h2->h1: 1/1, rtt min/avg/max/mdev 0.114/0.114/0.114/0.000 ms
  117. mininet> pingpairfull
  118. h1 -> h2
  119. h2 -> h1
  120. *** Results:
  121. h1->h2: 1/1, rtt min/avg/max/mdev 0.243/0.243/0.243/0.000 ms
  122. h2->h1: 1/1, rtt min/avg/max/mdev 0.122/0.122/0.122/0.000 ms
  123. mininet> time
  124. *** Elapsed time: 0.000005 secs
  125. mininet> nodes
  126. available nodes are:
  127. c0 h1 h2 s1
  128. mininet> quit
  129. *** Stopping 1 controllers
  130. c0
  131. *** Stopping 2 links
  132. ..
  133. *** Stopping 1 switches
  134. s1
  135. *** Stopping 2 hosts
  136. h1 h2
  137. *** Done
  138. completed in 324.923 seconds
  139. vagrant@coursera-sdn:~$ exit
  140. logout
  141. Connection to 127.0.0.1 closed.