Lab 37 · TCP echo server and client
Establish a TCP echo exchange and verify its acknowledgment.
85 local laboratory pages, including cross-listed and prerequisite experiments.
Establish a TCP echo exchange and verify its acknowledgment.
Compare UDP delivery with a running, stopped and restarted receiver.
Inspect internet time and HTTPS connectivity observations.
Explain the limitations of Bluetooth in WSL.
Use the documented TCP substitute to exchange Bluetooth-style messages.
Exchange mock humidity measurements over TCP.
Exchange mock humidity measurements over UDP.
Compute IPv4 header checksum and Ethernet frame size; distinguish payload, packet and frame.
Calculate network, mask, host range and broadcast from an address/prefix.
Identify which IPv4 address must be resolved on a local link.
Explore leases, four-message allocation and pool exhaustion.
Read DNS header, transaction ID, query name and response code; verify actual local DNS-format and HTTP exchanges.
Compare slow start, additive increase and timeout in an RTT-round model.
Compare idle, success and collision counts with the independent slotted-access probability.
Investigate the overlap between advertising times and scanning windows.
Calculate weighted shortest paths and distinguish route failure from radio failure.
Calculate transmission time as a function of spreading factor, bandwidth, coding rate and payload.
Inspect actual CoAP-format GET and response bytes; compare loss recovery.
Evaluate whether compressed IPv6/UDP data fits a constrained IEEE 802.15.4 frame.
Compare controller-computed route and link failure; evaluate cost-based policy.
Convert 128-bit addresses between expanded and canonical forms, classify address ranges, calculate prefix membership and allocate child networks.
Navigate a disposable practice directory and verify file operations.
Publish environmental measurements to ThingSpeak and verify the upload result.
Build the Arduino serial exercise and verify serial LED control.
Decode serial telemetry and verify its logging or upload.
Trace MQTT telemetry through Telegraf and InfluxDB; verify each stage independently.
Configure Grafana queries and verify the corresponding stored records.
Upload a measurement to ThingSpeak and inspect the result.
Retrieve channel measurements using the correct read credentials.
Publish MQTT telemetry using a consistent broker and topic.
Receive MQTT telemetry and verify Node-RED behavior independently.
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.
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.
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.
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.
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.
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.
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.
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.
Inventory and initialize dedicated local teaching brokers.
Distinguish authentication and authorization using positive and negative MQTT 5 controls.
Verify certificate trust and endpoint identity using correct and incorrect controls.
Compare controlled plaintext and TLS packet observations without mistaking absence of bytes for proof of security.
Verify mutual TLS trusted exchange and explicit certificate rejections.
Evaluate necessary and prohibited communication flows in a fixed IoT topology.
Separate device, operator and observer capabilities with explicit topic/action checks.
Capture controlled local traffic and interpret headers, flags and packet counts.
Measure open and closed TCP ports on an owned loopback service.
Compare deadline feasibility and telemetry volume for two inference placements.
Identify Ubuntu distribution, architecture and WSL environment; distinguish it from a physical Raspberry Pi.
Evaluate Python expressions in the REPL and distinguish Python from Bash.
Create, save and execute a Python file.
Read mock DHT22 temperature/humidity and interpret retries.
Append sensor records to CSV and verify newly written rows.
Write and query InfluxDB records using the configured credentials.
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.
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.
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ⁿ.
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).
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.
Binary exponent bits select powers a^(2^i). Repeated squaring reduces every multiplication; the number of steps grows with the exponent bit length.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
A valid signature is insufficient: trust anchor, intermediates, validity, hostname and applicable revocation policy all matter. Revocation checking depends on client policy and infrastructure.
Verify Kali dependencies and authorized training scope.
Verify SHA-256 and HMAC behavior for original and modified telemetry.
Reject duplicate, stale and altered authenticated messages.
Verify AEAD, signatures and ECDH/HKDF behavior using positive and negative controls.
Minimize and pseudonymize fictional telemetry; explain residual linkage risk.
Inspect credential permissions without printing secrets.
Combine schema and signed-manifest controls with STRIDE/DREAD and residual-risk analysis.
Trace threats across sensor, gateway, broker and dashboard trust boundaries; prioritize residual risk.
Prepare sensor observations, impute missing values and keep device groups separate.
Fit ordinary least squares on two training devices; predict a reference temperature on the third.
Train a two-feature logistic classifier and interpret a confusion matrix on a separate device.
Quantize a small fixed linear model and evaluate numerical error and saturation.