# Installing ONOS 2.0.0 for Mininet 2.3.0
> This online note is on progress. Some part of it are not well structured and still in Bahasa Indonesia.
## Disclaimer
Steps described in this guide may be slightly different than what other has done. However these steps are the one that was proven in my setting.
My settings are:
* Hardware: 16 GB RAM, 8 core processor, virtualization enabled in BIOS.
* Windows 10 installed on the hardware.
* VirtualBox 6.1 (I guess VirtualBox's version does not really matter) installed on Windows 10.
* Mininet VM installed on VirtualBox. This VM's image was obtained from [here](https://github.com/mininet/mininet/releases/). I am using Mininet 2.3.0. on Ubuntu Server 16.04.7
Installing Mininet's image into VM in VirtualBox is quite straight-forward. After installed, you can run and login with the default username `mininet` and password `mininet`.
## What is ONOS?
https://github.com/opennetworkinglab/onos#readme
## What is Mininet?
https://github.com/mininet/mininet/wiki/Mininet-2.3.0-Release-Notes
## Preparation
PASTIKAN IP SUDAH STATIC
dan setelah reboot pun WEB GUI hanya bisa diakses dg IP tersebut.
karena sepertinya ada bug.
Pastikan VM tempat ONOS memiliki RAM minimal 2GB. Kalau tidak, ONOS mungkin tetap bisa berjalan namun port 6633 atau 6653 tidak mau terbuka.
### Seting IP di VM
Known limitations:
* interface jenis NAT mungkin tidak bisa dikasih static IP karena takut bentrok dg VM lain.
* interface jenis Bridge tidak bisa dikasih static IP karena IP harus DHCP berdasarkan LAN dari Host.
* interface jenis Host Only bisa dibikin static dg aman (atau DHCP dari VBox's network manager), tapi tidak bisa internetan.
Jadi, buatlah 2 interface:
1. bridge (agar bisa internetan sekaligus diping dari host setelah diketahui IPnya)
1. host only (dibuat static, untuk diping/ssh/http)
This interface harus diseting juga adapter virtualBox nya agar range IP dhcp nya cocok dg IP static yg dipakai
The order of these two interfaces are not imporant, but you have to know from inside the OS (i.e. from command line) which one is which, because the numbering in ubuntu server may not be in the same order as the one in VirtualBox.
bila setiap reboot ada error "A start job is running for raise network interfaces (2 minutes of 5 mins 1 sec)", edit /etc/network/interfaces: ganti "auto" mjd "allow-hotplug" utk interface yg beneran (yg bukan loopback) yg mungkin putus nyambung.
> You can type `sudo reboot` command to restart the VM and push the OS to detect and apply the most recent network configuration.
lalu pas instal onos, disable interface yg bridge (unplug, dan di /etc/network/interface, biarkan dhcp) dan reboot dulu
baru deh install onos, set it as service, jalankan, dan tes apakah beneran jalan
utk testing GUI, tunggu 1-3 menit.
## Installing ONOS
```bash=
sudo adduser sdn --system --group
sudo apt update
sudo apt install git zip curl unzip python-minimal openjdk-8-jdk -y
sudo mkdir -p /opt && cd /opt
sudo wget http://repo1.maven.org/maven2/org/onosproject/onos-releases/2.0.0/onos-2.0.0.tar.gz
sudo tar xzf onos-2.0.0.tar.gz
sudo mv onos-2.0.0 onos
```
Yang dilakukan perintah-perintah di atas adalah:
Tambahkan user baru untuk menjadi owner dari ONOS yang akan berjalan sebagai service di Ubuntu. In this example, the new user is called `sdn`.
bila ONOS berjalan tidak sebagai service, akan ada masalah saat ONOS mencoba memakai port utk CLInya (8101), untuk GUInya (8181), atau untuk terhubung ke switch (6633 atau 6653.)
Install java 8 atau 11
Membuat folder yang akan menjadi tempat file-file ONOS. Ini dilakukan untuk keseragaman demi memudahkan pembahasan berikutnya.
Download ONOS release. In this example I used ONOS 2.0.0. After downloaded, I extracted the archive, and rename the extracted folder, just to make the later steps easier.
If you want to directly run ONOS (not as a service, thus it cannot listen on port 6633 or 6653 for accepting connection from OVS on Mininet VM. It will only listen on port 8181 for web GUI), you can call the following command:
```bash=
sudo /opt/onos/bin/onos-service start
```
To stop it, just press CTRL+C.
Next, it is not a good practice to run ONOS (or other application) as root if it is not intended as 'root'-related activities. Hence, let's change the owner of `onos` folder, and subsequently edit `options` file as `sdn` (not as root). This file can be used to define ONOS' startup configuration.
```bash=
sudo chown -R sdn:sdn onos
sudo -u sdn nano /opt/onos/options
```
Inside `options` file, add the following lines:
```bash=
# running onos with user sdn
export ONOS_USER=sdn
# default active drivers and openflow
export ONOS_APPS=drivers,openflow,gui2
```
Now let's include ONOS as a service in Ubuntu. In my version of Ubuntu, I used the following commands:
```bash=
sudo cp /opt/onos/init/onos.initd /etc/init.d/onos
sudo cp /opt/onos/init/onos.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable onos
```
Finally, we can start ONOS service (this command is not required upon the next reboot, because ONOS will start automatically):
```bash=
sudo systemctl start onos
```
And just in case you want to stop it, just fire this command:
```bash=
sudo systemctl stop onos
```
## Checking if ONOS is running correctly
To check if ONOS is running correctly, we need to check if the service is running and ports 8181, 8101, 6633 and 6653 are listening. To do that, use these commands (can also be used next time, e.g. after reboot, when you want to check if ONOS runs correctly):
```bash=
sudo systemctl status onos
sudo netstat -tunlp | grep "8101\|8181\|6633\|6653"
```
## Accessing ONOS' web GUI
After ONOS is running, we can access the web GUI at `http://ONOS_IP:8181/onos/ui` from any modern browser from any computer that can access ONOS_IP (replace ONOS_IP with IP of the machine that runs ONOS). Default username and password for ONOS web GUI is `onos`:`rocks`.
## ONOS API
ip_onos:8181/onos/v1/docs/ --> utk membaca API doc // swagger interface
## Connecting Mininet and ONOS
sudo mn --controller remote,ip=192.168.100.100
sudo mn --controller remote,ip=127.0.0.1
mininet> iperf
$ cd /namaFolder
$ sudo mn -c
$ sudo mn
mininet> h1 ping -c100 -s1000 h2 > coba.csv
hasil `coba.csv` akan muncul di folder `namaFolder`.
## Accessing ONOS' CLI
bikin rsa key pair utk user "root"
sudo ssh-keygen -t rsa
lanjutkan dg memilih tempat penyimpanan *.pub file, passprhase, dst.
#lalu jalankan ini utk menambahkan rsa key utk user "root"
sudo /opt/onos/bin/onos-user-key root /root/.ssh/id_rsa.pub
#lalu jalankan CLI:
sudo /opt/onos/bin/onos
## Uninstal/Removing (e.g. before reinstalling) ONOS
utk mencegah onos dari autorun saat bootup:
`sudo systemctl disable onos`
"sudo reboot" dan cek "sudo systemctl status onos" utk cek apakah onos masih running apa nggak after startup. kalo masih running juga:
`sudo rm /etc/init.d/onos
sudo rm /etc/systemd/system/onos.service`
hapus file2 onos
`sudo rm -rf /opt/onos`
# ONOS CLI
onos> feature:install onos-netconf