Computer Network Architecture Exercises

This chapter collects exercises on computer network architecture, covering basic concepts, performance metrics, the layered structure, the OSI model, the TCP/IP model, and network devices.

Fundamental Concept Exercises

1. Briefly describe the three main functions of a computer network.

Data CommunicationResource SharingDistributed Processing

Approach

Group the functions by what the network does for its users: carrying data between machines, letting several machines use the same resources, and spreading a workload across many machines.

Steps

  1. Identify the communication function and describe it as the transfer and exchange of data between computers.
  2. Identify the sharing function and describe it as the shared use of hardware, software, and data.
  3. Identify the distributed processing function and describe it as a task split across several computers that work together.
  4. Check that each function is stated once and that none of them overlaps with the others.

Answer

The three main functions of a computer network are:

  1. Data Communication

    • Transfers and exchanges data between different computers
  2. Resource Sharing

    • Shares hardware, software, and data resources
  3. Distributed Processing

    • Assigns tasks to several computers that complete them together

2. By geographic range, how can computer networks be classified, and what are the characteristics of each class?

WANMANLANPANNetwork Classification

Approach

Classify networks by the area they cover, from the smallest (a personal area network) to the largest (a wide area network), and for each class state its coverage, distance, rate, typical use, and technical trait.

Steps

  1. Start with the widest class and work down to the narrowest.
  2. For each class, note the coverage area, the transmission distance, the transmission rate, the typical applications, and the main technical characteristic.
  3. Compare the rates: the wider the area, the lower the typical rate.
  4. Confirm that the typical applications match the scale of each class.

Answer

By geographic range, computer networks fall into four classes:

Wide Area Network (WAN):

  • Coverage: spans cities, countries, or the whole globe
  • Transmission distance: tens to thousands of kilometres
  • Transmission rate: relatively low, typically a few Mbps to a few Gbps
  • Typical applications: the Internet, corporate WANs
  • Technical characteristic: uses public communication facilities, so the cost is high

Metropolitan Area Network (MAN):

  • Coverage: covers a single city or region
  • Transmission distance: a few to tens of kilometres
  • Transmission rate: moderate, typically tens of Mbps to a few Gbps
  • Typical applications: city networks, campus networks
  • Technical characteristic: sits between a LAN and a WAN

Local Area Network (LAN):

  • Coverage: within a building or a campus
  • Transmission distance: a few hundred metres to a few kilometres
  • Transmission rate: high, typically 10Mbps to 10Gbps
  • Typical applications: office networks, home networks
  • Technical characteristic: high rate, low delay, relatively low cost

Personal Area Network (PAN):

  • Coverage: around a single person’s devices
  • Transmission distance: a few to tens of metres
  • Transmission rate: low, typically a few Mbps to a few hundred Mbps
  • Typical applications: Bluetooth devices, wireless earphones
  • Technical characteristic: short range, low power consumption

Performance Metric Exercises

3. Briefly describe the components of network delay.

Transmission DelayPropagation DelayProcessing DelayQueuing Delay

Approach

Split the total delay into the four contributions a packet experiences on its way from source to destination, and give the formula and the influencing factors for each.

Steps

  1. Start with the transmission delay, which depends on the data length and the rate.
  2. Add the propagation delay, which depends on the distance and the propagation speed.
  3. Add the processing delay, which depends on the speed of the intermediate devices.
  4. Add the queuing delay, which depends on congestion and the queue length.
  5. Note that the first two are fixed by the path, while the last two vary with load.

Answer

Network delay consists of the following parts:

Transmission Delay:

  • Definition: the time required for data to move from the sending end to the receiving end
  • Formula: transmission delay = data length / transmission rate
  • Influencing factors: data size, transmission rate

Propagation Delay:

  • Definition: the time a signal takes to propagate through the transmission medium
  • Formula: propagation delay = distance / propagation speed
  • Influencing factors: transmission distance, medium type

Processing Delay:

  • Definition: the time a router or switch spends processing a packet
  • Influencing factors: device performance, queue length

Queuing Delay:

  • Definition: the time a packet waits in a router queue
  • Influencing factors: network congestion, queue length
Transmission DelayPropagation DelayTotal DelayCalculation

Approach

Compute the transmission delay and the propagation delay separately, then add them. The first term depends on the size of the packet and the rate; the second depends on the distance and the propagation speed.

Steps

  1. Convert 1000 bytes to bits and compute the transmission delay: 1000 bytes / (10×10^6 bps).
  2. Convert 1000 kilometres to metres and compute the propagation delay: 1000×10^3 m / (2×10^8 m/s).
  3. Add the two terms.

Answer

The computation:

  1. Transmission delay = data length / transmission rate = 1000 bytes / (10×10^6 bps) = 0.8 ms
  2. Propagation delay = distance / propagation speed = 1000×10^3 m / (2×10^8 m/s) = 5 ms
  3. Total delay = transmission delay + propagation delay = 0.8 + 5 = 5.8 ms

Layered Structure Exercises

5. Briefly describe the three elements of a network protocol.

ProtocolSyntaxSemanticsTiming

Approach

A protocol is complete only when it specifies what the bits look like, what they mean, and when they are exchanged. Cover the three elements in that order.

Steps

  1. State the syntax: the data format, the encoding, field lengths and ordering, control characters, and special symbols.
  2. State the semantics: the meaning of control information, the interpretation of operations, and error handling.
  3. State the timing: the order of events, the requirements for matching speeds, and synchronisation.
  4. Check that each element answers a different question: form, meaning, and order.

Answer

The three elements of a network protocol are:

Syntax:

  • Data format and encoding
  • Field lengths and ordering
  • Control characters and special symbols

Semantics:

  • The meaning of control information
  • The interpretation of each operation
  • How errors are handled

Timing:

  • The order in which events occur
  • Requirements for matching speeds
  • Synchronisation and asynchronous mechanisms

6. Compare connection-oriented service with connectionless service.

Connection-Oriented ServiceConnectionless ServiceTCPUDP

Approach

Compare the two services on the same four axes: how the transfer is set up, what the advantages are, what the disadvantages are, and which protocol realises each of them.

Steps

  1. Describe the connection-oriented model: establish, transfer, release.
  2. Describe the connectionless model: send directly, with no setup.
  3. Weigh the reliability and ordering guarantees against the overhead and latency.
  4. Attach the typical protocol to each side.

Answer

Connection-Oriented Service:

  • Characteristics: establishes a connection, transfers data, releases the connection
  • Advantages: high reliability, ordering guaranteed
  • Disadvantages: larger overhead, higher latency
  • Typical application: the TCP protocol

Connectionless Service:

  • Characteristics: sends data directly, with no connection to set up
  • Advantages: small overhead, low latency
  • Disadvantages: lower reliability, no ordering guarantee
  • Typical application: the UDP protocol

OSI Model Exercises

7. List the seven layers of the OSI model and the main function of each.

OSI ModelLayer FunctionsEncapsulation

Approach

Walk the stack from the bottom up. For each layer, state what it does and what its principal task is, so that the seven entries together describe a complete transfer.

Steps

  1. Start at the physical layer, which moves raw bits over the medium.
  2. Move up through the data link, network, and transport layers, which add framing, routing, and reliable end-to-end transfer.
  3. Continue with the session and presentation layers, which manage sessions and the representation of data.
  4. Finish with the application layer, which delivers network services to users.
  5. Check that the seven functions do not overlap and jointly cover the whole path.

Answer

The seven layers of the OSI model and their main functions:

Physical Layer:

  • Function: transmission of bit streams
  • Principal task: carry raw bit streams over a physical transmission medium

Data Link Layer:

  • Function: framing, error detection, flow control
  • Principal task: transfer frames reliably between adjacent nodes

Network Layer:

  • Function: route selection, packet forwarding
  • Principal task: transfer packets between different networks

Transport Layer:

  • Function: reliable end-to-end transfer, flow control
  • Principal task: provide a reliable data transfer service between end systems

Session Layer:

  • Function: session management, establishing and releasing sessions
  • Principal task: establish, manage, and terminate sessions

Presentation Layer:

  • Function: data format conversion, encryption and decryption
  • Principal task: convert formats, encrypt and decrypt, and compress and decompress data

Application Layer:

  • Function: provides network application services to users
  • Principal task: provide the various network application services

8. Briefly describe the similarities and differences between the OSI model and the TCP/IP model.

OSI ModelTCP/IP ModelLayer MappingModel Comparison

Approach

State the points of agreement first, then the differences along three axes — the number of layers, the balance between theory and practice, and the range of protocols supported — and finish with the layer-by-layer mapping.

Steps

  1. List the shared characteristics.
  2. Compare the number of layers.
  3. Compare theoretical rigour against practical value.
  4. Compare the protocol coverage.
  5. Map each OSI layer onto the TCP/IP layer that covers it.

Answer

Similarities:

  • Both use a layered structure
  • Both define standards for network communication
  • Both support many network protocols

Differences:

Number of layers:

  • OSI model: seven layers, divided in fine detail
  • TCP/IP model: four layers, divided simply

Theoretical rigour:

  • OSI model: stronger on theory, highly standardised
  • TCP/IP model: stronger on practice, widely deployed

Protocol support:

  • OSI model: supports many network protocols
  • TCP/IP model: mainly supports the TCP/IP protocol family

Layer correspondence:

  • The physical and data link layers of OSI ≈ the network access layer of TCP/IP
  • The network layer of OSI ≈ the internet layer of TCP/IP
  • The transport layer of OSI ≈ the transport layer of TCP/IP
  • The session, presentation, and application layers of OSI ≈ the application layer of TCP/IP

TCP/IP Model Exercises

9. Briefly describe the four layers of the TCP/IP model and the function of each.

TCP/IP ModelNetwork Access LayerInternet LayerTransport LayerApplication Layer

Approach

Describe the four layers from the bottom up. For each one, state its function, the protocols that belong to it, and its principal task.

Steps

  1. Start with the network access layer, which carries data over the physical medium.
  2. Move up to the internet layer, which handles addressing and routing.
  3. Move up to the transport layer, which provides end-to-end data transfer.
  4. Finish with the application layer, which provides the application services.
  5. Check that the protocols listed under each layer belong to it.

Answer

The four layers of the TCP/IP model and their functions:

Network Access Layer:

  • Function: physical transmission and framing
  • Protocols: Ethernet, WiFi, PPP, ARP, and so on
  • Principal task: transfer data over a physical transmission medium

Internet Layer:

  • Function: IP addressing, route selection, packet forwarding
  • Protocols: IP, ICMP, IGMP, OSPF, and so on
  • Principal task: transfer packets between different networks

Transport Layer:

  • Function: end-to-end transfer, reliable transfer, flow control
  • Protocols: TCP, UDP
  • Principal task: provide a data transfer service between end systems

Application Layer:

  • Function: provides the various network application services to users
  • Protocols: HTTP, FTP, SMTP, DNS, and so on
  • Principal task: provide network application services

10. Compare the characteristics of TCP and UDP.

TCPUDPFlow ControlCongestion Control

Approach

Compare the two protocols on the same six axes: connection model, reliability, flow control, congestion control, transmission efficiency, and typical use.

Steps

  1. State how each protocol sets up or avoids a connection.
  2. Compare the reliability guarantees.
  3. Compare the presence of flow control and congestion control.
  4. Compare the transmission efficiency.
  5. List the applications that suit each protocol.

Answer

TCP (Transmission Control Protocol):

  • Connection model: connection-oriented
  • Reliability: reliable transfer
  • Flow control: has flow control
  • Congestion control: has congestion control
  • Transmission efficiency: relatively lower
  • Typical use: HTTP, FTP, SMTP, and so on

UDP (User Datagram Protocol):

  • Connection model: connectionless
  • Reliability: unreliable transfer
  • Flow control: no flow control
  • Congestion control: no congestion control
  • Transmission efficiency: relatively higher
  • Typical use: DNS, DHCP, streaming media, and so on

Network Device Exercises

11. Briefly describe where the various network devices sit in the OSI model and what they do.

RepeaterHubBridgeSwitchRouterGateway

Approach

Group the devices by the layer they work at, and for each device give a one-line summary of its function and its usual role.

Steps

  1. List the physical layer devices and their functions.
  2. List the data link layer devices and their functions.
  3. List the network layer devices and their functions.
  4. List the multi-layer devices and their functions.

Answer

Physical layer devices:

  • Repeater: amplifies and regenerates signals, extending the distance of the network
  • Hub: multi-port signal broadcast, used to build star topologies

Data link layer devices:

  • Bridge: frame forwarding and filtering, connects different segments
  • Switch: intelligent frame forwarding, the core device of a LAN

Network layer devices:

  • Router: packet routing and forwarding, connects different networks

Multi-layer devices:

  • Gateway: protocol and format conversion, connects heterogeneous networks

12. Compare the functional differences between a switch and a router.

SwitchRouterMAC AddressIP Address

Approach

Compare the two devices along five axes: the layer they work at, their main functions, the address they forward on, the scope in which they are used, and their performance profile.

Steps

  1. State the operating layer of each device.
  2. State the main functions of each device.
  3. State the address each device forwards on.
  4. State the scope of use.
  5. State the performance characteristic of each.

Answer

Switch:

  • Operating layer: data link layer
  • Main functions: frame forwarding, MAC address learning, VLAN support
  • Forwarding basis: the MAC address
  • Scope of use: inside a local area network
  • Performance characteristic: fast forwarding, low latency

Router:

  • Operating layer: network layer
  • Main functions: packet routing, network interconnection, protocol conversion
  • Forwarding basis: the IP address
  • Scope of use: between different networks
  • Performance characteristic: intelligent routing, network isolation

Comprehensive Application Exercises

13. Design a simple network topology containing a router, a switch, and hosts, and describe how a packet travels through it.

Network TopologyRouterSwitchPacket ForwardingEncapsulation

Approach

Draw the topology first, then trace a packet from host A to host B layer by layer: what the sender encapsulates, what each switch does, what the router does, and what the receiver strips off.

Steps

  1. Lay out the path: host A → switch 1 → router → switch 2 → host B.
  2. At the sender, describe the encapsulation performed by each layer.
  3. At switch 1, describe learning the source MAC address and forwarding on the destination MAC address.
  4. At the router, describe looking up the routing table, choosing the outgoing interface, and forwarding.
  5. At switch 2, describe learning and forwarding to host B.
  6. At the receiver, describe the decapsulation performed by each layer.

Answer

Topology design:

Host A
Switch 1
Router
Switch 2
Host B

Data passes through: Host A → Switch 1 → Router → Switch 2 → Host B

Packet transfer process:

  1. Host A sends the data:

    • Application layer: produces the application data
    • Transport layer: adds the TCP/UDP header
    • Network layer: adds the IP header
    • Data link layer: adds the Ethernet header
  2. Switch 1 processes the frame:

    • Receives the frame
    • Learns the source MAC address
    • Forwards it to the router based on the destination MAC address
  3. The router processes the packet:

    • Receives the IP packet
    • Looks up the routing table
    • Selects the outgoing interface
    • Forwards it to switch 2
  4. Switch 2 processes the frame:

    • Receives the frame
    • Learns the source MAC address
    • Forwards it to host B based on the destination MAC address
  5. Host B receives the data:

    • Data link layer: removes the Ethernet header
    • Network layer: removes the IP header
    • Transport layer: removes the TCP/UDP header
    • Application layer: handles the application data

14. Analyse a network performance problem and propose optimisation measures.

Network PerformanceCongestionBandwidthOptimisation

Approach

Take each reported symptom, trace it back to its most likely cause, and then group the remedies into hardware, network design, protocol, and management measures.

Steps

  1. List the symptoms.
  2. For each symptom, name the likely causes.
  3. Group the remedies into four categories.
  4. Check that every symptom is addressed by at least one remedy.

Answer

Problem statement: an enterprise network shows the following symptoms:

  • High network delay
  • Slow data transfer
  • Frequent network congestion

Problem analysis:

  1. High network delay: likely caused by insufficient network device performance, long transmission distances, or network congestion
  2. Slow data transfer: likely caused by insufficient bandwidth, limited device processing capacity, or low protocol efficiency
  3. Network congestion: likely caused by excessive network load, insufficient device processing capacity, or an unsound network design

Optimisation measures:

Hardware upgrades:

  • Upgrade the network devices to raise their processing capacity
  • Increase the network bandwidth
  • Use faster transmission media

Network optimisation:

  • Optimise the network topology
  • Implement load balancing
  • Configure QoS policies

Protocol optimisation:

  • Use more efficient network protocols
  • Tune the TCP parameters
  • Implement traffic shaping

Management optimisation:

  • Strengthen network monitoring
  • Maintain the network devices regularly
  • Define a network usage policy

Programming Exercises

15. Write a simple network performance test program.

Network TestRound-Trip TimePacket LossSocket API

Approach

Collect the measurements that matter for a link — round-trip time, packet loss, and the size and count of the packets sent — and print them in a readable report.

Steps

  1. Define a structure that holds the target host, the port, the packet parameters, and the measured results.
  2. Write a function that fills in the structure for a given host, port, size, and count.
  3. Write a function that prints the results, including the minimum, maximum, and average round-trip time and the packet loss rate.
  4. Call the two functions from main with a concrete target.

Answer

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

// Network performance test structure
typedef struct {
    char target_host[256];
    int port;
    int packet_size;
    int packet_count;
    double min_rtt;
    double max_rtt;
    double avg_rtt;
    double packet_loss;
} NetworkTest;

// Run the network performance test
NetworkTest perform_network_test(const char* host, int port, int size, int count) {
    NetworkTest test;
    strcpy(test.target_host, host);
    test.port = port;
    test.packet_size = size;
    test.packet_count = count;

    // Simulated test result
    test.min_rtt = 10.0;  // milliseconds
    test.max_rtt = 50.0;
    test.avg_rtt = 25.0;
    test.packet_loss = 0.1; // 0.1%

    return test;
}

// Print the test results
void print_test_results(const NetworkTest* test) {
    printf("Network performance test results:\n");
    printf("Target host: %s\n", test->target_host);
    printf("Port: %d\n", test->port);
    printf("Packet size: %d bytes\n", test->packet_size);
    printf("Packet count: %d\n", test->packet_count);
    printf("Minimum round-trip time: %.2f ms\n", test->min_rtt);
    printf("Maximum round-trip time: %.2f ms\n", test->max_rtt);
    printf("Average round-trip time: %.2f ms\n", test->avg_rtt);
    printf("Packet loss rate: %.2f%%\n", test->packet_loss);
}

int main() {
    // Run the network performance test
    NetworkTest test = perform_network_test("192.168.1.1", 80, 1024, 100);

    // Print the test results
    print_test_results(&test);

    return 0;
}

Found an issue with this content?

Tell us what could be improved.