Introduction - Computer Networks¶
Learning Goals¶
After this week, you will understand the following concepts
- Physical Media
- Packet switching vs. Circuit switching
- Delay, loss and throughput
- Packet Sniffer
- Accessing a Server and familarizing with Linux
Introduction Lab¶
Intro¶
This lab introduces you to the tools you will use throughout the course. Therefore, it is important that you read carefully the instructions bellow. This introductory lab consists of two parts:
1. Server¶
This part will introduce you to the remote server, how to connect to your server, and how to run JupyterLab on the server. You will also learn to use SSH/SCP and clone the course repository.
2. Introduction to Linux¶
This part will introduce you to the basic concepts of Linux and the command line interface. You will learn to navigate the file system and use the essential commands.
Important
Throughout the introductory lab (and later labs) we mention the use of the Sahara PCs.
The Sahara lab is under construction until February 2026, but the labs are doable on your personal computers.
- Windows users should install WSL, which will allow Linux commands within Windows. Powershell is preinstalled on Windows and can work as an alternative to WSL (not supported by TAs).
- Mac users should be fine with the default terminal.
Ask the TAs if you have any questions.
Milestone 1 - Server¶
In this course, you will use a server, which is a Virtual Machine (VM) running a Linux distribution called Ubuntu. You will use a server hosted on NTNU's server infrastructure. These servers are available 24/7 and can be accessed via NTNU's internal network. If you are not on campus, you can connect to the server using the (NTNU VPN). To connect to the server, you will be using PCs in (Sahara lab).
1.1 Connecting to the Server¶
- Before accessing the server, you need to open the Linux terminal in the Sahara PC.
There are various ways to open the terminal.
For example, you can use the keyboard and press the
Ctrl+Alt+T, or navigate to the menu option at the bottom of the screen, click the application meny, find the terminal icon and launch it.
Note
The keyboard shortcut to copy text within a Linux terminal is Ctrl+Shift+C.
You can use Ctrl+Shift+X for cutting, and Ctrl+Shift+V for pasting._
-
To access the remote server securely, we will use SSH (Secure Shell) protocol.
-
You can access the server through SSH by running the following command in the terminal:
ssh <your_NTNU_username>@team<your_team_number>.ttm4200.iaas.iik.ntnu.no.
Replace
<your_NTNU_username>with your NTNU username, and<your_team_number>with your team number that can be found in Canvas".The password is the same as your NTNU password. Note that every team member can access the team's server with their own NTNU credentials.
When entering password in the Linux terminal, you cannot see what you are typing.
Note
In all the following commands, you need to replace what is inside <...> with your own values.
- You can exit the server by typing the following command in the terminal:
exit.
The connection to the server is closed.
SSH Key¶
Instead of using the password every time you connect to the server, you can use an SSH key:
- Generate an SSH key on Sahara PC:
Replace
<key_name>with a name for the key, and<your_email>with your email address.You will be asked to enter a passphrase to protect the key. Leave it empty for now. This will generate two files:
~/.ssh/<key_name>and~/.ssh/<key_name>.pub. The first file is the private key, and the second file is the public key.
~is used to denote the home directory (/home/<username>) of the user. This will be explained more in depth later in this lab.
- Assosiate the public key from Sahara PC with the server. This will add the key to the authorized keys file:
cat ~/.ssh/<key_name>.pub | \
ssh <your_NTNU_username>@team<your_team_number>.ttm4200.iaas.iik.ntnu.no \
'sudo tee -a ~/.ssh/authorized_keys'
The
\is not a part of the command in itself, but is used when writing a command over multiple lines.
Note
This key will only work for the user who generated the key. If other users log into the Sahara PC for other lab sessions, these steps have to be repeated.
- Then, from Sahara PC, connect to the server using the private key:
SSH Config¶
Instead of typing the username and the IP address every time you connect to the server, you can add the following lines to ~/.ssh/config file on Sahara PC:
Host ntnu_server
HostName team<your_team_number>.ttm4200.iaas.iik.ntnu.no
User <your_NTNU_username>
IdentityFile ~/.ssh/<key_name>
If you have not used SSH before, you may not have a
~/.ssh/configfile. You can create it by runningtouch ~/.ssh/config. To edit the file, you can usenano ~/.ssh/configcommand. To exit and save changes, press 'Ctrl + X' and type 'yes'.
Then, you can connect to the server by running ssh ntnu_server.
Note
You can follow these instructions and use your computer to connect to the server.
If you have Windows OS, use Sahara PC or a WSL.
Nevertheless, we recommend getting familiar with the instructions within this document, as the labs in this course are designed for Sahara PCs.
Copying Files to/from the Server¶
You can use scp to copy files and directories to/from the server. For example, you can run the following commands on Sahara PC:
- To copy a file from Sahara PC to the server:
scp <local_file> ntnu_server:~/<destination_directory>.
- To copy file from the server:
scp ntnu_server:~/<source_file> <local_directory>.
- To copy directories add the
-rflag:
scp -r <local_directory> ntnu_server:~/<destination_directory>.
Task
Show your TA that you can connect to the server using ssh ntnu_server
Task
Show your TA that you can copy a file to/from the server using scp
Task
Show your TA that you can copy a directory to/from the server using scp
1.2 Running JupyterLab on the Server¶
(JupyterLab) is a web-based interactive development environment for Jupyter notebooks, code, and data. You can run JupyterLab on the server and access it from Sahara PC. To do so, you need to establish an (SSH tunnel) from Sahara PC to the server.
- On the Sahara PC, run the following command:
This will establish an SSH tunnel from port 8888 in Sahara PC to port 8888 in the server. The first port number is the port in Sahara PC, and the second port is the port in the server. You can use any port number above 1024 and below 65535. You can also use different port numbers for the two ports, but using the same port number is easier.
- On the server, start JupyterLab:
The port number should be the same as the second port number in the SSH tunnel.
- On Sahara PC's browser, type
localhost:8888to show JupyterLab. You can now use JupyterLab as you would do on Sahara PC, but it is actually running on the server. If needed, copy the token value from the terminal to the browser in the fieldPassword or token:
The port number should be the same as the first port number in the SSH tunnel. If JupyterLab asks you for a token, you can find it in the terminal where you started JupyterLab in the server.
1.3 Course Repository¶
We will use a (Git) repository to distribute the course material throughout the semester.
- Clone the course repository to your server using the following command:
- We will update the repository with new assignments. You need to run these commands at the beginning of each lab. To get the latest version of the course material, run the following commands:
- You might need to set your username and email for git, when committing your changes for the first time. To do this, use the following commands:
Milestone 2 - Introduction to Linux¶
This is the last step that you have to follow on this website.
Next task
Run JupyterLab on the server and open the notebook ~/labs/lab0/tasks_lab0.ipynb.
Follow the instructions in the notebook to complete the tasks.
Info
We will use JupyterLab for the rest of the course.