Skip to content

📝 Knowledge Test

/
Knowledge Test Score Board
—· 0%

Work through the questions below — your score updates as you go.

Keep going · grade bands mapped to DCU's honours scale

target20:00

Only your first attempt at each question counts toward this score. Reload the page to reset.

This section contains 20 interactive knowledge checks designed to test your understanding of the materials covered in Chapter 11. The questions cover TCP/IP fundamentals, network socket programming in Rust using TcpListener and TcpStream, building robust client-server architectures, and an introduction to advanced protocols like MQTT and HTTP for the IoT Edge.

Please remember that many of the quizzes have multiple correct answers, and you must select all applicable options to succeed. I have carefully balanced the lengths of the answers, so take your time to evaluate each option thoroughly.

Good luck!

Derek.


Part 1: Networking Fundamentals for the Edge

Section titled “Part 1: Networking Fundamentals for the Edge”
Q1
Concept Match

Match the Networking Layers

Drag each definition into its matching concept slot, then click Submit. Tap × to return a placed card to the pool.

IP Address
drag a definition here…
Port Number
drag a definition here…
TCP
drag a definition here…
UDP
drag a definition here…

Definition Pool

A connectionless protocol prioritising speed and low overhead over guaranteed reliability.
A connection-oriented protocol that ensures reliable, ordered, and error-checked delivery.
A unique numerical label assigned to each device connected to a computer network.
A 16-bit integer used to identify specific processes or services on a single device.
Q2
Quiz
Select 0/2

Why is TCP generally preferred over UDP for critical control applications on edge devices, such as industrial PLC units?

Because TCP uses a stateless architecture that allows it to operate without a permanent network connection.
Because TCP provides a smaller binary footprint, which is essential for devices with extremely limited flash memory.
Because TCP includes built-in flow control to prevent a fast sender from overwhelming a slower receiver.
Because TCP automatically handles packet retransmission and ensures that data arrives in the correct sequence.
Q3
Quiz
Select 0/2

Regarding network 'Sockets', which of the following statements accurately describes their role in software development?

They are physical hardware connectors found on the motherboard of high-performance edge gateways.
They are defined by the combination of an IP address and a 16-bit port number (e.g., 127.0.0.1:8080).
They are restricted to communicating only between different physical machines across a local area network.
They represent the software endpoint of a bidirectional communication link between two programs.
Q4
Code Cloze
Rust

Localhost and Loopback

Drag snippets from the pool into the blanks so the program produces the output shown, then click Submit.

1fn main() {
2 // The standard 'loopback' address for testing on the same machine
3 let local_addr = "·····";
4
5 // A common port number for development servers
6 let port = "·····";
7
8 let socket_addr = format!("{}:{}", local_addr, port);
9}

Available Snippets

localhost
80
0.0.0.0
127.0.0.1
192.168.1.1
8080
Q5
Concept Match

Match the Rust Networking Types

Drag each definition into its matching concept slot, then click Submit. Tap × to return a placed card to the pool.

TcpListener
drag a definition here…
TcpStream
drag a definition here…
incoming()
drag a definition here…
io::Error
drag a definition here…

Definition Pool

Represents a single active connection, allowing for bidirectional data transfer.
The error type returned by networking operations, covering timeouts and broken pipes.
A structure that binds to a port and waits for incoming connection requests.
An iterator that yields new connection attempts as they arrive at the listener.
Q6
Code Output
Rust

Predict the output: Binding to a Port

Read the code below, then choose the terminal output it produces and click Submit.

1use std::net::TcpListener;
2
3fn main() {
4 // Attempt to listen on port 80 (requires admin/root)
5 match TcpListener::bind("127.0.0.1:80") {
6 Ok(_) => println!("Success"),
7 Err(e) => println!("Error: {}", e.kind()),
8 }
9}
stdout
Success
stdout
Error: PermissionDenied
stdout
Error: ConnectionRefused
stdout
Error: NotFound
Q7
Quiz
Select 0/2

When using the listener.incoming() iterator, what exactly is yielded for each successful connection?

A Result type that must be unwrapped to handle potential connection failures.
The client's IP address and port number as a formatted String.
A TcpStream object representing the active communication channel.
A raw byte buffer containing the initial packet data from the client.
Q8
Code Cloze
Rust

Writing to a Network Stream

Drag snippets from the pool into the blanks so the program produces the output shown, then click Submit.

1use std::io::Write;
2use std::net::TcpStream;
3
4fn main() -> std::io::Result<()> {
5 let mut stream = TcpStream::connect("127.0.0.1:8080")?;
6
7 let message = "Status: OK";
8 // Convert the string to a byte slice and send it
9 stream.·····(message.·····())?;
10
11 Ok(())
12}

Available Snippets

to_string
push
write_all
as_bytes
into_bytes
send
Q9
Quiz
Select 0/2

In a typical edge sensor network, which entity usually assumes the 'Server' role?

The network router that manages the IP address allocation via DHCP.
The cloud-based database that stores historical readings for long-term analysis.
The individual battery-powered sensor node waiting for a command to sample data.
The central gateway or desktop dashboard that 'listens' for incoming data packets.
Q10
Code Order
Rust

The TCP Server Lifecycle

Drag the tiles to arrange the code in the correct order, then click Submit. Locked lines stay in place. Indentation is dynamically applied based on the location of braces.
let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
for stream in listener.incoming() {
let mut stream = stream.unwrap();
stream.write_all(b"ACK").unwrap();
stream.read(&mut buffer).unwrap();
let mut buffer = [0; 512];
}
Q11
Quiz
Select 0/2

Why is it crucial to spawn a new thread (or use async tasks) for each incoming connection in a production TCP server?

To prevent a single slow client from blocking the main listener loop and stalling other incoming connections.
Because the Rust standard library requires a thread-per-connection for memory safety verification.
To ensure that the client's IP address is correctly registered in the system's global routing table.
To allow the server to utilise multiple CPU cores for processing independent client requests in parallel.
Q12
Code Cloze
Rust

Concurrent Connection Handling

Drag snippets from the pool into the blanks so the program produces the output shown, then click Submit.

1for stream in listener.incoming() {
2 let stream = stream.unwrap();
3 // Offload each connection to its own thread
4 std::thread::·····(····· || {
5 handle_client(stream);
6 });
7}

Available Snippets

async
run
move
create
ref
spawn

Part 4: Data Transmission and Serialisation

Section titled “Part 4: Data Transmission and Serialisation”
Q13
Concept Match

Match the Data Representation

Drag each definition into its matching concept slot, then click Submit. Tap × to return a placed card to the pool.

Plain Text
drag a definition here…
Binary
drag a definition here…
JSON
drag a definition here…
Endianness
drag a definition here…

Definition Pool

Human-readable data (e.g., CSV or custom strings) easy to debug but higher overhead.
A popular text-based format for structured data, widely supported by web APIs.
The byte order (Big vs Little) used to represent multi-byte values in a binary stream.
Compact, efficient data representation (e.g., raw structs) ideal for bandwidth-limited radio links.
Q14
Quiz
Select 0/1

Which crate is the 'gold standard' for serialising and deserialising Rust data structures for network transmission?

serde
cargo
anyhow
tokio
Q15
Quiz
Select 0/1

In binary networking, why is 'Network Byte Order' (Big-Endian) historically significant?

Because it was the native format of the original 8-bit Intel processors used in the first edge sensors.
Because it provides a standard, consistent way to represent numbers across systems with different native architectures.
Because it is the only format supported by the standard Rust i32 and f64 types.
Because it automatically compresses the data by 50% during transmission across wireless links.
Q16
Code Cloze
Rust

Safe Buffer Initialisation

Drag snippets from the pool into the blanks so the program produces the output shown, then click Submit.

1fn handle_read(mut stream: TcpStream) {
2 // Create an empty byte buffer of 1024 bytes
3 let mut buffer = [·····; 1024];
4
5 // Read data from the stream into the buffer
6 let bytes_read = stream.·····(&mut buffer).unwrap();
7
8 // Convert the received bytes into a UTF-8 string slice
9 let msg = std::str::from_utf8(&buffer[..·····]).unwrap();
10}

Available Snippets

1024
read
0
len
bytes_read
u8
recv

Part 5: Advanced Networking and IoT Protocols

Section titled “Part 5: Advanced Networking and IoT Protocols”
Q17
Concept Match

Match the IoT Protocols

Drag each definition into its matching concept slot, then click Submit. Tap × to return a placed card to the pool.

HTTP
drag a definition here…
MQTT
drag a definition here…
WebSocket
drag a definition here…
CoAP
drag a definition here…

Definition Pool

A specialised protocol for restricted nodes and networks, similar to HTTP but over UDP.
A request-response protocol primarily used for web services and large document transfers.
A lightweight publish-subscribe protocol ideal for low-power sensors and unreliable networks.
A protocol providing full-duplex, persistent communication over a single TCP connection.
Q18
Quiz
Select 0/2

What is the primary benefit of the 'Publish-Subscribe' model used in MQTT compared to traditional HTTP?

It requires every device to have a public IP address to receive incoming notifications.
It provides a way for low-power sensors to receive data without knowing the specific identity of the sender.
It decouples data producers from consumers, allowing for extremely efficient one-to-many communication.
It forces devices to stay awake and connected at all times, ensuring 100% data reliability.
Q19
Quiz
Select 0/2

Why is 'Asynchronous Networking' (e.g., using the Tokio crate) preferred for high-concurrency edge gateways?

Because it is the only way to send data over encrypted TLS channels in the Rust ecosystem.
Because it allows the CPU to run significantly faster by bypassing the standard hardware interrupt system.
Because it enables a single OS thread to handle thousands of active connections by yielding during I/O wait times.
Because it eliminates the memory overhead of maintaining thousands of separate OS thread stacks.
Q20
Quiz
Select 0/1

In a bare-metal (#![no_std]) environment like an ESP32 microcontroller, how is networking typically handled?

By utilising specialised crates like 'embedded-nal' (Network Abstraction Layer) and vendor-specific HALs.
By bypassing the IP stack entirely and manually toggling the radio antenna pins at high frequency.
By using the standard library's std::net module, which is fully compatible with all wireless chips.
By running a full Linux kernel in a background task to provide the necessary socket support.

Congratulations on completing the Chapter 11 Knowledge Test! Review any questions you missed to ensure a solid grasp of Rust networking and client-server communication before exploring the final chapters on resource management and optimization.