Prelab 7: Networking

In this lab you'll extend your database program to be accessible over a network. To do this, you and your partner will get your computers to talk to each other.

In order to make sure this goes swimmingly, you should connect both your computers to the wifi and test it out before lab.

Step 1: Pick a lab partner and sit down with them.

Schedule a little time to do this before the lab.

Step 2: Make sure your Linux can talk to each other

Port Forwarding Setup for WSL2

First, launch your Ubuntu in WSL2 (and do nothing yet). Then Back to Windows, go the search bar and search the keyword "powershell", and you should see the app "Windows PowerShell" pop up. Then you can find the option to run as Administrator, as shown in the picture below:

Once you have the PowerShell open, copy and paste this command into the PowerShell and hit enter to run it:

  netsh interface portproxy add v4tov4 listenport=20000 listenaddress=0.0.0.0 connectport=20000 connectaddress=$(bash -c "ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'")

Then run another command line to configure the Windows FireWall:

  New-NetFireWallRule -DisplayName 'WSL2 CSSE132 Firewall Unlock' -Direction Inbound -LocalPort 20000 -RemoteAddress '137.112.0.0/16','192.168.0.0/16' -Action Allow -Protocol TCP

As the result, you should see the output like the picture shown below


You will want to test your work in this lab by connecting to your partner's Linux and having your partner connect to yours.

First, make sure your laptop (and your partner's laptop) are connected to the Rose secured network via WiFi (eduroam) and that they are both registered.

Ping each other

Once you and your partner have completed the above steps, try to connect to each other's computers:

  1. In Your WSL2 terminal, launch a server using port 20000 (the -l is a lowercase L for 'listen')

    nc -l 20000
    
  2. Have your partner try to connect to your laptop:

    • First, you need find to your IP address so that your partner can use to connect. To find your IP, you can run the following command in Windows PowerShell
    ipconfig
    

    Your IP (in the WiFi part) can be found as the picture shown below

    • Now your partner can use the following command (in Ubuntu/WSL2) to connect to you.
    nc <your_ip> 20000
    

    Replace <your_ip> here with the your IP.

  3. When it connects, try sending lines of text back and forth by typing and hitting enter. Type Control-D to exit.

  4. If you have any trouble connecting, ask your classmates or instructor for help.

  5. Repeat on your partner's Linux.

Finishing the prelab

In the lab, you'll be creating software to communicate between different programs. Be prepared to connect your partner's Linux to yours!