opennetworkinglab / ngsdn-tutorial

Hands-on tutorial to learn the building blocks of the Next-Gen SDN architecture
https://www.opennetworking.org/ng-sdn/
Apache License 2.0
317 stars 186 forks source link

[question] Running Xterm #85

Closed elhpavtat closed 2 years ago

elhpavtat commented 2 years ago

Hello!

I have a problem with xterm not working in mininet. I have spent several days trying to figure it out myself and have tried many instructions on the internet. Eventually, I downloaded VM mininet from http://mininet.org/ and xterm works when I do "sudo -E mn". Thus it can be assumed that I have X11 Forwarding configured correctly. This worked without any further manipulation.

After connecting via SSH via PUTTY with X11 Forwarding enabled, I can run xterm or gedit, all of which work from the VM. However, it doesn't work xterm in mininet.

DISPLAY=192.168.56.1:0.0 - IP of my windows notebook with VcXsrv X; 192.168.56.104 - IP of the VM with ngsdn;

sdn@tutorial-vm:~/ngsdn-tutorial$ cat /etc/ssh/sshd_config |grep X11
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
sdn@tutorial-vm:~/ngsdn-tutorial$ cat /etc/ssh/ssh_config |grep X11
   ForwardX11 yes
   ForwardX11Trusted yes
sdn@tutorial-vm:~/ngsdn-tutorial$
sudo -E make mn-cli
mininet> xterm h1b
Error: Cannot connect to display
mininet>
mininet> h1b echo $DISPLAY $XAUTHORITY

mininet>

It looks as if some parameters are not being passed to the mininet. Could you tell me what to do or check on VM? I understand that this is not directly related to NGSDN, but this functionality may be important for some users. On a running VM from mininet.org:

mininet> h1 echo $DISPLAY $XAUTHORITY
localhost:10.0
mininet>

Thank you very much, any help would be appreciated!

ederollora commented 2 years ago

Hi,

So, what I understand is that... xterm does not work in your NG-SDN tutorial VM. Is that correct? Or is it a VM you built yourself? I do not remember having any issue with xterm using the VM provided in the README though.

Cheers,

elhpavtat commented 2 years ago

Hi,

Yes, it is NG-SDN tutorial VM.

ederollora commented 2 years ago

Hi,

I wonder if you download the VM again and run any exercise, do you have the same problem? This is to debug if the problem is for a misconfiguration that you might have made (and not noticed) or if the problem is the VM as it was exported, or your VirtualBox or another different thing.

Cheers,

elhpavtat commented 2 years ago

Hi, Yes, all right, thank you. I'll do it now and let you know the result.

Thank you!

elhpavtat commented 2 years ago

Hi, I downloaded and completely reinstalled the VM in Virtualbox. I checked that X11 forwarding works in VM, but does not work in mininet. I ran xterm and gedit in VM and it works. I performed: sudo -E make start and sudo -E make mn-cli.

Any help would be appreciated! Thanks!

ederollora commented 2 years ago

Hi,

The problem here is that Mininet runs in a container, that's why h1a xterm fails (no xterm installed in the container). And that's probably why the xterm installed in the Ubuntu host has issues to access Mininet hosts' context. Consider that I am not completely sure about the issue, so these are just assumptions.

So, what to do? You do not have many options to run xterm or get a GUI from a Mininet host context (like Firefox or Wireshark). You can still get a direct CLI to the host (without using Mininet).

The first thing is to access Mininet container CLI: sudo docker exec -it mininet bash

To get a CLI for h1a or any name: lsns | grep h1a -m1 | awk '{print $4}'

The number from the previous command should replace PID_HERE: nsenter --target PID_HERE --mount --uts --ipc --net --pid

At this point I have to say that the only way to have xterm is to install it in the container (you might have to build a custom Mininet container or edit the one you have). Then I am not sure that even if you had xterm, you will still have problems with the DISPLAY issue. You would have to follow something like this , this or this websites.

Cheers,

elhpavtat commented 2 years ago

Thank you, it really works! I have accessed the hosts in the mininet. As I understand it, to add hping3, tcpreplay, tcpdump or scapy there I need to rebuild the container to generate traffic from one host to another.

Thank you so much!!

ederollora commented 2 years ago

Now, if you need something like hping3 or even if you need to install xterm then do:

sudo docker exec -it mininet bash

Update pkg list:

apt update --allow-unauthenticated --allow-insecure-repositories

and now install the package you need:

apt install <pkg>

I am not sure if these changes are consistent across reboots, so you need to check that out.

Cheers,

ederollora commented 2 years ago

Oh and for tcpdump, there is already a command for that here

elhpavtat commented 2 years ago

Thank you very much, Sir! You have helped me a lot! I lost a week trying to figure it out, but now I can move forward! Thank you for your kindness! I wish you all the best! And I'll get on with my project!

ederollora commented 2 years ago

No problem. You are very welcome to ask for help or report issues, and the community tries to help as much as possible.

Cheers,

elhpavtat commented 2 years ago

Hello @ederollora , I hope you are very well! Sorry about that, can you tell me how to look at the switch logs? In the log, I would like to see which packet came in, how it was sorted into headers and then for each table: whether there was a match and what was done

Using mininet> dump I found my switch ID and accessed the cli, can you please tell me how to find the logs?

Thank you so much!