Colab Notebooks
A Colab Notebook is a web page containing Python programs and Linux commands that can be executed interactively and run on a Google machine ("in the cloud").
Colab is similar to Jupyter, a tool for interactive execution of Python programs. Programs in a Jupyter notebook, however, are executed on the same machine that is accessing the notebook. Python and Jupyter must thus be installed on that machine. Colab can instead be used with a browser, without installing anything.
Notebooks for this course
Each notebook is self-contained and briefly describes the code cells it contains. You are not required to learn or understand how that code works. Just execute the code cells and read the textual explanations in the notebook.
If you want, you may obtain a detailed explanation of code cells, either by asking Gemini (the Google AI assistant) on the right of the Colab window or by asking ChatGPT as in this example.
Several notebooks analyze packet captures. These are files in a standard format (.pcap
or .pcapng
) containing the network traffic sent and received by a particular computer.
Depending on the notebook, the analysis of a packet capture is done in two ways:
-
By executing Python code that uses the Scapy library. The Python code loads a packet capture in memory and then displays the content of selected messages in the capture.
-
By executing the tshark program available in Linux.
How do I execute a Notebook?
A notebook is a sequence of text cells and of code cells. A code cell may contain either Python code or Linux commands. Linux commands must begin with the !
character.
To run a code cell just click on the triangle on the left.
Notebooks are meant to be read and executed from the beginning, in sequence. However, you can go back and forth as you want: you can execute (and re-execute) cells in any order. While a cell is running, no other cell can be run.
Usage of a notebook is possible only to users logged in on Google.
Where is code executed?
Code cells are executed by a Linux virtual machine hosted on the Google cloud and private of the user that is using the notebook.
Such a machine is volatile, i.e., once the notebook is closed all the state of the machine, including files, is lost (maybe not immediately).
The machine is configured with several limitations. The most important one is that you cannot run any server (more precisely, you could run servers but those servers would not be reachable from other machines).
Is a notebook private?
Each user has a private execution environment, even if multiple users access the same notebook at the same time.
You can modify the notebook (by adding/modifying text/code cells) as you want. The modified copy will be visible only to yourself. If you want to save the modified copy, the notebook will force you to save it with a different name.