On Mac, port 5000 may already be used, so you need to choose a different one (5001 should work).
On Windows, remember to add .exe
after the command qemu-system-aarch64
.
When running ifconfig
(or ip addr
) I variously see the interface eth0
or an interface called usb0
. I am not quite sure why.
(On my personal Ubuntu VM the corresponding interface is called enp0s3
. Apparently this has something to do with the systemd manager that Debian, on which both Ubuntu and Raspberry Pi OS are based, uses.)
Instead of the command netstat -t -l
you can also just run netstat -tl
. When running this command you will see that the machine is listening on 0.0.0.0:ssh
. Here ssh
just stands for the standard SSH port 22, and the IP address 0.0.0.0
means that it is listening on all IP addresses on the machine.
Running netstat -t
on my machine I see a connection with local address 10.0.2.15:ssh
and foreign address 10.0.2.2:1136
, both of which are private network addresses. (Indeed, from running ifconfig
we see that the network mask is 255.255.255.0
, so they are indeed on the same network, namely 10.0.2.0/24
.) Hence our IP address, and the IP address we are connected to, are not public, indicating that NAT is used by the host machine to create a private network on which the Raspberry Pi is located.
Running netstat
(or netstat -n
) on my Windows host tells me that I am connected on localhost:5555
to localhost:1136
(recall that localhost
is 127.0.0.1
). That is, the ports are the same but the IP addresses are different: Recall that an IP address is associated with a network layer network interface, not the machine itself. The host machine thus creates a (virtual) interface with IP address 10.0.2.2
to which the Raspberry Pi can connect.
(On my personal Ubuntu VM I use port forwarding to redirect data from host to guest, and I see exactly the same behaviour. So presumably that's what's happening?)
Here you will probably see two connections, one with local address localhost:4321
and one with foreign address localhost:4321
. This is simply because the machine is connected to itself on two different ports, both of which are both local and foreign.
On Windows, instead of Telnet you can also install and use Nmap, which ships with the tool Ncat (command ncat
) corresponding to netcat on UNIX. Apparently there is an issue with the latest version of Nmap, so installing the previous version 7.92 (download link here) is recommended.
On Windows you can again use Ncat instead of Telnet.
Note the behaviour of the program so far: When a client
The desired behaviour is as follows: The server
In the tunneling hand-in the desired behaviour is slightly different, so don't be confused by the comments regarding the hand-in. (In the hand-in we do need to worry about blocking.)
No hand-in this week. (For notes on hand-in 9, see week 14.)
For more on how virtual machines deal with networking, the VirtualBox manual covers many topics that are relevant for other virtualisation software packages such as QEMU and VMWare Workstation (Player).