Skip to content
04Connected Networks StudioPSUT · Networking and Communication
Connected Networks Studio

Python / Colab notebooks

85 local laboratory notebooks. Download the file, then upload it to Colab.

Primary course experiments · 21

N05 · Primary · Advanced networks

DNS & HTTP application services

Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.

Download Notebook ↓
Open Google Colab ↗
N07 · Primary · Advanced networks

Wireless contention & Wi-Fi performance concepts

Compare idle, success and collision counts with the independent slotted-access probability.

Download Notebook ↓
Open Google Colab ↗
N14 · Primary · Advanced networks

IPv6 Addressing & Subnetting

Convert 128-bit addresses between expanded and canonical forms, classify address ranges, calculate prefix membership and allocate child networks.

Download Notebook ↓
Open Google Colab ↗

Cross-listed experiments · 28

P43 · Cross-listed · Core IoT & programming

Lab 43 · MQTT → Telegraf → InfluxDB

Trace MQTT telemetry through Telegraf and InfluxDB; verify each stage independently.

Download Notebook ↓
Open Google Colab ↗
CR76 · Cross-listed · Cryptography Engineering

CR76 · IPsec AH/ESP transport and tunnel packet layout

AH provides integrity/authentication but no confidentiality. ESP can provide confidentiality and integrity; transport protects the upper-layer payload while tunnel carries an inner IP packet. This model omits algorithm-dependent padding and outer options except specified assumptions.

Download Notebook ↓
Open Google Colab ↗
CR81 · Cross-listed · Cryptography Engineering

CR81 · SSH transport, user authentication and channels

SSH first authenticates the server host key at transport layer, then authenticates the user, then opens multiplexed channels. Host-key trust and user-key authorization are distinct.

Download Notebook ↓
Open Google Colab ↗
CR82 · Cross-listed · Cryptography Engineering

CR82 · SSH tunnel endpoints and trust boundaries

Local forwarding carries bytes from a client-side listening socket over SSH to a server-side destination. Remote forwarding reverses the listener location. Encryption applies to the SSH segment, not automatically to destination traffic.

Download Notebook ↓
Open Google Colab ↗
CR83 · Cross-listed · Cryptography Engineering

CR83 · Firewall rule ordering and default policy

A firewall evaluates packet metadata against ordered rules. First matching rule wins in this model; otherwise default deny. Stateful filtering may permit return traffic for an established session.

Download Notebook ↓
Open Google Colab ↗
CR77 · Cross-listed · Cryptography Engineering

CR77 · TCP and TLS 1.2 handshake sequence

TCP establishes transport before TLS negotiation. The TLS 1.2 example uses authenticated ephemeral ECDHE; ChangeCipherSpec and Finished precede encrypted application data. Other TLS 1.2 cipher suites differ.

Download Notebook ↓
Open Google Colab ↗
CR78 · Cross-listed · Cryptography Engineering

CR78 · TLS 1.3 handshake and encrypted records

TLS 1.3 negotiates supported versions and key shares in hello messages, derives handshake keys, encrypts later handshake messages, and uses AEAD. Compatibility CCS is not a key-transition signal as in TLS 1.2.

Download Notebook ↓
Open Google Colab ↗
CR79 · Cross-listed · Cryptography Engineering

CR79 · TLS record framing and AEAD overhead

TLS 1.3 outer record header has 5 bytes; encrypted content contains plaintext, inner content type and optional padding, plus AEAD tag (16 bytes in this example). Outer content type is application_data for encrypted records.

Download Notebook ↓
Open Google Colab ↗
CR80 · Cross-listed · Cryptography Engineering

CR80 · Verified local TLS 1.2/1.3 and hostname failure

Use Python SSL MemoryBIO to conduct a real TLS handshake in process. Trust only a generated local CA; verify hostname; compare TLS 1.2 and 1.3 with the same data. No listener or public network is used.

Download Notebook ↓
Open Google Colab ↗
K03 · Cross-listed · Kali & IoT security

K03 · MQTT authentication & least privilege

Distinguish authentication and authorization using positive and negative MQTT 5 controls.

Download Notebook ↓
Open Google Colab ↗
K04 · Cross-listed · Kali & IoT security

K04 · TLS certificate trust & endpoint identity

Verify certificate trust and endpoint identity using correct and incorrect controls.

Download Notebook ↓
Open Google Colab ↗
K05 · Cross-listed · Kali & IoT security

K05 · Plaintext vs TLS packet observation

Compare controlled plaintext and TLS packet observations without mistaking absence of bytes for proof of security.

Download Notebook ↓
Open Google Colab ↗
S03 · Cross-listed · Advanced cybersecurity

MQTT topic authorization & least privilege

Separate device, operator and observer capabilities with explicit topic/action checks.

Download Notebook ↓
Open Google Colab ↗
NS01 · Cross-listed · IoT Security and Privacy

NS01 · tcpdump — packet capture and protocol filtering

Capture controlled local traffic and interpret headers, flags and packet counts.

Download Notebook ↓
Open Google Colab ↗

Additional prerequisite experiments · 36

R1 · Prerequisite · Core IoT & programming

Lab 1 · Hardware & first boot

Identify Ubuntu distribution, architecture and WSL environment; distinguish it from a physical Raspberry Pi.

Download Notebook ↓
Open Google Colab ↗
CR19 · Prerequisite · Cryptography Engineering

CR19 · AES · complete cipher and inverse

Encryption begins with AddRoundKey, then repeats SubBytes, ShiftRows, MixColumns and AddRoundKey. The last round omits MixColumns. Decryption starts with the final round key and reverses the operations: InvShiftRows, InvSubBytes, AddRoundKey, then InvMixColumns except at the end. Round states are column-major byte sequences. This is a raw single-block primitive, not an authenticated message-encryption system. Known-answer vector: plaintext 00112233445566778899AABBCCDDEEFF with key 000102030405060708090A0B0C0D0E0F yields 69C4E0D86A7B0430D8CDB78070B4C55A.

Download Notebook ↓
Open Google Colab ↗
CR35 · Prerequisite · Cryptography Engineering

CR35 · Modular clock and residue classes

For positive modulus n, a=qn+r with 0≤r<n. Congruence means equal residues, not equal integers. On the GF(17) clock, 35→1, −7→10 and −11→6. Addition and multiplication reduce after the operation.

Download Notebook ↓
Open Google Colab ↗
CR36 · Prerequisite · Cryptography Engineering

CR36 · Prime fields and composite rings

A field has additive and multiplicative identities and every nonzero element has a multiplicative inverse. Modulo a composite integer, zero divisors can exist; GF(pⁿ) is not ordinary integer arithmetic modulo pⁿ.

Download Notebook ↓
Open Google Colab ↗
CR37 · Prerequisite · Cryptography Engineering

CR37 · Modular inverses and division

An inverse x satisfies ax≡1 mod n. Division a/b means a·b⁻¹, defined only when gcd(b,n)=1. The lecture includes 421 mod 1009 and 10 mod 40 (no inverse).

Download Notebook ↓
Open Google Colab ↗
CR38 · Prerequisite · Cryptography Engineering

CR38 · Extended Euclidean algorithm: three phases

Forward division finds gcd; back-substitution rewrites it as ax+ny. Reduce x modulo n to obtain the inverse if gcd=1. Worked example: 20⁻¹ mod 23 = 15.

Download Notebook ↓
Open Google Colab ↗
CR41 · Prerequisite · Cryptography Engineering

CR41 · Repeated squaring and operation counts

Binary exponent bits select powers a^(2^i). Repeated squaring reduces every multiplication; the number of steps grows with the exponent bit length.

Download Notebook ↓
Open Google Colab ↗
CR44 · Prerequisite · Cryptography Engineering

CR44 · Primitive roots and discrete logarithms

The order of g is the first positive exponent giving 1. A primitive root modulo prime p has order p−1. Inversion of exponentiation is the discrete-logarithm problem.

Download Notebook ↓
Open Google Colab ↗
CR49 · Prerequisite · Cryptography Engineering

CR49 · Diffie–Hellman key agreement

For public prime q and generator g, Alice sends A=gˣᵃ mod q and Bob B=gˣᵇ mod q. Both compute g^(xa·xb) mod q independently. Private exponents stay local; DH alone does not authenticate peers or directly encrypt messages. q=23,g=5,xa=6,xb=15 gives A=8, B=19, B⁶ mod 23=2 and A¹⁵ mod 23=2.

Download Notebook ↓
Open Google Colab ↗
CR52 · Prerequisite · Cryptography Engineering

CR52 · Elliptic curves over prime fields

For prime p>3 use y²≡x³+ax+b mod p, with 4a³+27b² nonzero modulo p. Enumerate all matching y for each x. The group includes point at infinity O, which has no finite coordinate. Plot discrete points. p=17,a=b=2: (5,1) satisfies 1≡137 mod 17. There are 18 finite points plus infinity, order 19.

Download Notebook ↓
Open Google Colab ↗
CR53 · Prerequisite · Cryptography Engineering

CR53 · ECC point addition: point addition

For distinct points with unequal x, λ=(y₂−y₁)(x₂−x₁)⁻¹ mod p, x₃=λ²−x₁−x₂ mod p, y₃=λ(x₁−x₃)−y₁ mod p. P plus its inverse gives infinity; equal noninverse points use doubling. GF(17), a=b=2, P=(5,1), Q=(6,3): numerator=2, denominator=1, inverse=1, λ=2; x₃=10,y₃=6.

Download Notebook ↓
Open Google Colab ↗
CR54 · Prerequisite · Cryptography Engineering

CR54 · ECC doubling and GF(23) worked example

For doubling λ=(3x₁²+a)(2y₁)⁻¹ mod p. Use the coordinate formulas with P=Q. If y=0, doubling gives infinity. Add P to 2P to obtain 3P. GF(17), P=(5,1): numerator=77 mod 17=9, denominator=2, inverse=9, λ=13, 2P=(6,3), 3P=(10,6). GF(23), a=b=1,P=(3,10): 2P=(7,12),3P=(19,5).

Download Notebook ↓
Open Google Colab ↗
CR55 · Prerequisite · Cryptography Engineering

CR55 · ECC scalar multiplication and point order

Double-and-add reads scalar bits from least significant. Start at infinity, conditionally add the current point, then double the addend. Point order is the smallest positive t with tP=O, not necessarily group order. P=(5,1) over GF(17), a=b=2. 3=11₂: add P and 2P to obtain (10,6). P has order 19.

Download Notebook ↓
Open Google Colab ↗
CR59 · Prerequisite · Cryptography Engineering

CR59 · Hashing versus encoding and digest families

Encoding changes representation and is reversible without a secret. Hashing maps arbitrary bytes to a fixed-size digest; it is not encryption or sender authentication. MD5 and SHA-1 are historical, collision-broken algorithms, not suitable for new security designs. SHA-256, SHA-512 and SHA3-256 have different digest sizes and constructions. UTF-8 byte length may differ from character count. For abc, hexadecimal is 616263 and Base64 is YWJj. SHA-256 is ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.

Download Notebook ↓
Open Google Colab ↗
CR67 · Prerequisite · Cryptography Engineering

CR67 · HMAC inner and outer construction

SHA-256 uses a 64-byte block. Normalize K to K′ by hashing keys longer than 64 bytes, then zero-padding. Compute inner=H((K′ XOR ipad)||m), tag=H((K′ XOR opad)||inner), where ipad=36 repeated and opad=5c repeated. HMAC authenticates under a shared key; it neither encrypts nor inherently prevents replay. With 20 bytes of 0b and Hi There, RFC 4231 HMAC-SHA256 is b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7.

Download Notebook ↓
Open Google Colab ↗
CR70 · Prerequisite · Cryptography Engineering

CR70 · Digital signatures: ECDSA file verification

A digital signature binds a digest to a private signing key; a trusted public key verifies it. This lab uses P-256 ECDSA with SHA-256 from a vetted library. Signatures contain r and s; Python uses ASN.1 DER while Web Crypto returns raw r||s. Validity depends on trusted keys, not simply the presence of a signature. An original synthetic firmware message verifies with its own public key. A modified message and a different public key must be rejected. Signature bytes can vary between runs.

Download Notebook ↓
Open Google Colab ↗
CR73 · Prerequisite · Cryptography Engineering

CR73 · Key lifecycle and session-key distribution

Long-term keys authenticate identities; session keys protect one session. A KDC is a trusted intermediary. Rotation, expiration and revocation constrain use. This explicit model checks key validity and freshness before release.

Download Notebook ↓
Open Google Colab ↗
CR74 · Prerequisite · Cryptography Engineering

CR74 · X.509 certificate fields and local CA

X.509 binds a public key to subject identity via issuer signature; SAN identifies DNS names, validity limits time, key usage constrains purpose. Generate local certificates and verify the issuer signature. Signature verification alone is not full path validation.

Download Notebook ↓
Open Google Colab ↗
CR75 · Prerequisite · Cryptography Engineering

CR75 · Certificate trust chain and revocation decisions

A valid signature is insufficient: trust anchor, intermediates, validity, hostname and applicable revocation policy all matter. Revocation checking depends on client policy and infrastructure.

Download Notebook ↓
Open Google Colab ↗
K08 · Prerequisite · Kali & IoT security

K08 · Authenticated encryption & signatures

Verify AEAD, signatures and ECDH/HKDF behavior using positive and negative controls.

Download Notebook ↓
Open Google Colab ↗
K11 · Prerequisite · Kali & IoT security

K11 · Threat modeling & integrated security review

Combine schema and signed-manifest controls with STRIDE/DREAD and residual-risk analysis.

Download Notebook ↓
Open Google Colab ↗
S01 · Prerequisite · Advanced cybersecurity

IoT threat modelling & risk register

Trace threats across sensor, gateway, broker and dashboard trust boundaries; prioritize residual risk.

Download Notebook ↓
Open Google Colab ↗
M02 · Prerequisite · Machine Learning & Edge AI

Regression for sensor calibration

Fit ordinary least squares on two training devices; predict a reference temperature on the third.

Download Notebook ↓
Open Google Colab ↗
M03 · Prerequisite · Machine Learning & Edge AI

Fault classification & decision thresholds

Train a two-feature logistic classifier and interpret a confusion matrix on a separate device.

Download Notebook ↓
Open Google Colab ↗