0% found this document useful (0 votes)
26 views

LabSDN Use Mininet With Command

Uploaded by

yahwiasd
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

LabSDN Use Mininet With Command

Uploaded by

yahwiasd
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

SOFTWARE DEFINED NETWORKING

Lab 1: Use Mininet with commands

Nhóm học phần:


Mã Sinh viên, Họ và Tên:

1)
2)
3)

MỤC LỤC
1. Overview.............................................................................................................1
2. Objectives...........................................................................................................1
3. Lab settings........................................................................................................2
4. Introduction to Mininet.....................................................................................2
5. Invoke Mininet using the CLI..........................................................................3
5.1. Invoke Mininet using the default topology................................................................3
5.2. Test connectivity........................................................................................................8
6. Invoke Mininet with custom topology..............................................................9
7. Build and emulate a network in mininet.......................................................10
8. References.........................................................................................................11

>> Yêu cầu chụp hình ảnh là kết quả thực hành của SV. Không sử dụng lại hình ảnh của
bài lab.

1. Overview
This lab provides an introduction to Mininet, a virtual testbed used for testing network
tools and protocols. It demonstrates how to invoke Mininet from the command-line
interface (CLI) utility and how to build and emulate topologies using a graphical user
interface (GUI) application. In this lab we will use Containernet, a Mininet network
emulator fork that allows to use Docker containers as hosts in emulated network
topologies. However, all the concepts covered are bounded to Mininet.

2. Objectives
By the end of this lab, students should be able to:

KhoaCNTT-Trường ĐHBK, ĐHĐN


1. Understand what Mininet is and why it is useful for testing network topologies.
2. Invoke Mininet from the CLI.
3. Construct network topologies using the GUI.
4. Save/load Mininet topologies using the GUI.
5. Configure the interfaces of a router using the CLI.

3. Lab settings
The information in Table 1 provides the credentials of the machine containing
Mininet.
Table 1. Credentials to access Client1 machine.

Device Account Password

Client1 admin password

4. Introduction to Mininet
Mininet is a virtual testbed enabling the development and testing of network tools and
protocols. With a single command, Mininet can create a realistic virtual network on any
type of machine (Virtual Machine (VM), cloud-hosted, or native). Therefore, it provides
an inexpensive solution and streamlined development running in line with production
networks1. Mininet offers the following features:

• Fast prototyping for new networking protocols.


• Simplified testing for complex topologies without the need of buying expensive
hardware.
• Realistic execution as it runs real code on the Unix and Linux kernels.
• Open source environment backed by a large community contributing extensive
documentation.

Figure 1. Hardware network vs. Mininet emulated network.

KhoaCNTT-Trường ĐHBK, ĐHĐN


Mininet is useful for development, teaching, and research as it is easy to customize
and interact with it through the CLI or the GUI. Mininet was originally designed to
experiment with OpenFlow2 and Software-Defined Networking (SDN)3. This lab,
however, only focuses on emulating a simple network environment without SDN-based
devices.

Mininet’s logical nodes can be connected into networks. These nodes are sometimes
called containers, or more accurately, network namespaces. Containers consume
sufficiently fewer resources that networks of over a thousand nodes have created, running
on a single laptop. A Mininet container is a process (or group of processes) that no longer
has access to all the host system’s native network interfaces. Containers are then assigned
virtual Ethernet interfaces, which are connected to other containers through a virtual
switch4. Mininet connects a host and a switch using a virtual Ethernet (veth) link. The
veth link is analogous to a wire connecting two virtual interfaces, as illustrated below.

Figure 2. Network namespaces and virtual Ethernet links.

5. Invoke Mininet using the CLI


The first step to start Mininet using the CLI is to start a Linux terminal.
5.1. Invoke Mininet using the default topology
Step 1. Remote access: from windows, run: cmd
Type the following command to connect remote host

C:\Users\ABC>ssh [email protected] -p 15
[email protected]'s password:

KhoaCNTT-Trường ĐHBK, ĐHĐN


Step 2. To start a minimal topology, enter the command shown below. When
prompted for a password, type and hit enter. Note that the password will not be visible as
you type it.

ubuntu@vmsdn:~$ sudo mn --controller=remote,ip=127.0.0.1,port=6653

Có thể chạy lại nhiều lần để vào dấu nhắc lệnh mininet>

Figure 4. Starting Mininet using the CLI.

KhoaCNTT-Trường ĐHBK, ĐHĐN


The above command starts Mininet with a minimal topology, which consists of a
switch connected to two hosts as shown below.

Figure 5. Mininet’s default minimal topology.

Mininet initializes the topology and launches its command line interface which looks
like this:
mininet>

Step 3. To display the list of Mininet CLI commands and examples on their usage,
type the following command:
help

KhoaCNTT-Trường ĐHBK, ĐHĐN


Figure 6. Mininet’s command.

Step 4. To display the available nodes, type the following command:


mininet> nodes

Figure 7. Mininet’s command.

The output of this command shows that there is a controller, two hosts (host h1 and
host h2), and a switch (s1).

Step 5. It is useful sometimes to display the links between the devices in Mininet to
understand the topology. Issue the command shown below to see the available links.
mininet> links
mininet> ports
mininet> net

KhoaCNTT-Trường ĐHBK, ĐHĐN


Figure 8. Mininet’s command.

The output of this command shows that:

1. Host h1 is connected using its network interface h1-eth0 to the switch on interface
s1-eth1.
2. Host h2 is connected using its network interface h2-eth0 to the switch on interface
s1-eth2.
3. Switch s1:
a. has a loopback interface lo.
b. connects to h1-eth0 through interface s1-eth1.
c. connects to h2-eth0 through interface s1-eth2.
4. Controller c0 is the brain of the network, where it has a global knowledge about
the network. A controller instructs the switches on how to forward/drop packets in
the network.

Mininet allows you to execute commands on a specific device. To issue a command


for a specific node, you must specify the device first, followed by the command.

Step 6. To proceed, issue the command:


mininet> h1 ifconfig

KhoaCNTT-Trường ĐHBK, ĐHĐN


Figure 9. Output of command.

This command executes the Linux command on host h1. The command shows host
h1’s interfaces. The display indicates that host h1 has an interface h1-eth0 configured
with IP address 10.0.0.1, and another interface lo configured with IP address 127.0.0.1
(loopback interface).

5.2. Test connectivity


Mininet’s default topology assigns the IP addresses 10.0.0.1/8 and 10.0.0.2/8 to host
h1 and host h2 respectively. To test connectivity between them, you can use the ping
command.

Step 1. On the CLI, type the command shown below. This command tests the
connectivity between host h1 and host h2. To stop the test, press Ctrl + c . The figure
below shows a successful connectivity test. Host h1 (10.0.0.1) sent four packets to host
h2 (10.0.0.2) and successfully received the expected responses.
mininet> h1 ping 10.0.0.2

KhoaCNTT-Trường ĐHBK, ĐHĐN


Figure 2.1.Connectivity test between host h1 and host h2.

Step 2. Mininet command


mininet> help
mininet> nodes
mininet> net
mininet> h1 ifconfig
mininet> h1 ping h2
mininet> dump
mininet> h1 pwd
mininet> h1 ls
mininet> xterm h1
mininet> xterm h2 h3 h4

Step 3. Stop the emulation by typing the following command:


exit

The command sudo mn -c is often used on the Linux terminal (not on the Mininet CLI)
to clean a previous instance of Mininet (e.g., after a crash).

6. Invoke Mininet with custom topology


- Tạo topology chỉ định giá link:
sudo mn --link tc,bw=10,delay=10ms

- Tạo topology với size và type khác:


VD1: 4 host kết nối đến 1 switch
sudo mn --topo single,4

KhoaCNTT-Trường ĐHBK, ĐHĐN


VD2: Mỗi switch có 1 host và các switch kết nối trên 1 dòng
sudo mn --topo linear,4

Console vào host:


mininet> xterm h1 h2

 Ping giữa 2 hosts:


mininet> h1 ping h2 -c 3
 Ping thử giữa các hosts:
mininet> pingall
 Hiển thị TCP bandwidth:
mininet> iperf
 Mininet Sanity Check: Do a quick check by running the following commands:
sudo mn -c
sudo mn --test pingall

KhoaCNTT-Trường ĐHBK, ĐHĐN


7. Build and emulate a network in mininet
sudo mn --controller=remote,ip=127.0.0.1,port=6653
sudo mn --controller=remote,ip=192.168.1.16,port=6653
sudo mn --topo linear,3 --mac --switch ovs,protocols=OpenFlow13 --
controller=remote,ip=127.0.0.1
sudo mn --topo linear,3 --mac --switch ovs,protocols=OpenFlow13 --
controller=remote,ip=192.168.1.16

sudo mn --topo linear,3 --mac --switch ovs,protocols=OpenFlow13 --


controller=remote,ip=127.0.0.1,port=6653

sudo mn --topo linear,3 --mac --switch ovs,protocols=OpenFlow13 --


controller=remote,ip=192.168.1.16,port=6653

sudo mn --topo tree,depth=2,fanout=3 --mac --switch ovsk --


controller=remote,ip=127.0.0.1,port=6653
sudo mn --topo tree,2,2 --mac --switch ovs,protocols=OpenFlow14 --controller
remote,ip=192.168.1.16
sudo mn --topo=tree,3 --mac --switch=ovsk --controller=remote,ip=192.168.1.16

sudo mn --topo tree,depth=3,fanout=4


sudo mn --topo torus,3,3 --controller remote,ip=127.0.0.1
sudo mn --controller remote,ip=127.0.0.1 --topo torus,3,3

8. References
[1]. http://manpages.ubuntu.com/manpages/xenial/man1/mn.1.html
[2]. Mininet walkthrough. [Online]. Available: http://Mininet.org.
[3]. B. Lantz, G. Gee, “MiniEdit: a simple network editor for Mininet,” 2013. [Online]. Available:
https://github.com/Mininet/Mininet/blob/master/examples.

(Tài liệu lưu hành nội bộ)


-----------------------------------------------

KhoaCNTT-Trường ĐHBK, ĐHĐN

You might also like