Application Layer Comprehensive Exercises
Exercise 1: Fundamental Concepts
- Briefly describe the difference between the C/S model and the P2P model.
Approach
Compare the two models on the five dimensions that decide which one fits a workload: structure, where resources are managed, scalability, reliability, and security. Then state the scenarios each one serves.
Steps
- Compare the structural characteristics.
- Compare resource management.
- Compare scalability.
- Compare reliability.
- Compare security.
- Compare the scenarios.
Answer
The main differences are:
-
Structure:
- The C/S model: a centralised structure with distinct clients and servers
- The P2P model: a distributed structure in which the nodes are peers
-
Resource management:
- The C/S model: the server manages the resources centrally
- The P2P model: the resources are spread across the nodes
-
Scalability:
- The C/S model: limited by the performance of the server
- The P2P model: grows as the number of nodes grows
-
Reliability:
- The C/S model: depends on the server, so a server failure stops the service
- The P2P model: fault tolerant, so the failure of one node does not affect the whole
-
Security:
- The C/S model: the server controls the access rights
- The P2P model: the nodes are autonomous, so the security is relatively weaker
-
Scenarios:
- The C/S model: conventional network services (the web, mail, file transfer)
- The P2P model: peer-to-peer network services (file sharing, instant messaging)
- What are the main functions of the application layer?
Approach
Describe the functions from the outside in: what the user gets, what the layer defines for the applications, which kinds of service it offers, and how it cooperates with the transport layer.
Steps
- State the user-facing function.
- State the protocol support.
- State the types of service.
- State protocol management.
- State the cooperation with the transport layer.
Answer
The main functions of the application layer are:
-
User services:
- Provide network services that are directly usable by people
- Provide a uniform interface for the user
- Support the various needs of networked applications
-
Protocol support:
- Define the rules of communication at the application layer
- Define the format in which data is transferred
- Manage application sessions
-
Types of service:
- File services: file transfer and file sharing
- Communication services: electronic mail and instant messaging
- Information lookup: web browsing and database queries
- Remote services: remote login and remote control
-
Protocol management:
- Application-specific protocols
- Standardised protocols
- Extensible protocols
- Protocols that allow interoperability
-
Cooperation with the transport layer:
- Use the services the transport layer provides
- Choose the transport protocol that fits
- Implement end-to-end communication
Exercise 2: The DNS and FTP Protocols
- What are the main steps in the DNS name resolution process?
Approach
Follow the queries down the hierarchy — client, local server, root, top-level domain, authoritative server — and then describe the return path.
Steps
- Describe the client query.
- Describe the local DNS server lookup and its cache check.
- Describe the root server lookup.
- Describe the top-level domain server lookup.
- Describe the authoritative server lookup.
- Describe the return of the result.
Answer
The DNS name resolution process consists of the following main steps:
-
The client query:
- The client sends a query request to the local DNS server
- The query carries the domain name to be resolved
-
The local DNS server lookup:
- The local DNS server checks its cache
- If there is a cached result, it is returned directly
- If not, it queries a root server
-
The root server lookup:
- The local DNS server queries a root server
- The root server returns the addresses of the top-level domain servers
- For example the addresses of the .com and .org servers
-
The top-level domain server lookup:
- The local DNS server queries a top-level domain server
- It returns the address of the authoritative server
- For example the authoritative server for example.com
-
The authoritative server lookup:
- The local DNS server queries the authoritative server
- The authoritative server returns the final IP address
- The conversion from a domain name to an IP address is complete
-
The result is returned:
- The local DNS server returns the result to the client
- The client obtains the IP address of the target server
- A connection can now be established
- Why does FTP distinguish between the control connection and the data connection?
Approach
Explain the separation in terms of function first, then give the practical consequences: fewer connection setups, the ability to run several transfers at once, independent control over security, and recovery from a failure of either connection.
Steps
- Explain the separation of function.
- Explain the effect on efficiency.
- Explain the flexibility it allows.
- Explain the effect on security.
- Explain the effect on reliability.
- Explain the design rationale.
Answer
FTP distinguishes the control connection from the data connection for these reasons:
-
Separation of function:
- The control connection carries the commands and the responses
- The data connection carries the file data
- The responsibilities are clear and do not interfere with each other
-
Higher efficiency:
- The control connection stays open as a long-lived connection
- The data connection is established on demand
- The cost of establishing connections is reduced
-
Flexibility:
- Several file transfers can run at the same time
- Different transfer modes are supported
- It adapts to different network environments
-
Security:
- The control connection can be encrypted
- The data connection can be controlled independently
- Better security control is possible
-
Reliability:
- A failure of the control connection does not stop the data transfer
- A failed data connection can be re-established
- The overall reliability is improved
-
Protocol design:
- It follows the principle of layering
- It makes the protocol easier to extend
- It improves the maintainability of the protocol
Exercise 3: The Electronic Mail and WWW Protocols
- What are the respective roles of SMTP and POP3 in an electronic mail system?
Approach
Treat SMTP and POP3 as the two halves of the mail path: one pushes a message towards its destination, the other pulls a message back to the user. List the three responsibilities of each.
Steps
- State the three roles of SMTP.
- State the three roles of POP3.
- Close with the contrast between pushing and pulling.
Answer
The role of SMTP:
-
Sending mail:
- The client sends the mail to the SMTP server
- The servers forward the mail to one another
- The mail is made sure to reach the destination server
-
Mail routing:
- The mail is routed according to the recipient’s address
- Mail relaying is supported
- Mail forwarding is handled
-
Authentication:
- The identity of the sender is verified
- Forged mail is prevented
- Permission to send mail is controlled
The role of POP3:
-
Receiving mail:
- The client downloads the mail from the POP3 server
- It obtains the list of messages
- It downloads the content of the messages
-
Mail management:
- Messages are marked as read
- Messages are deleted from the server
- The state of the mailbox is managed
-
Offline access:
- The mail is downloaded to the local machine
- It can be read offline
- The storage used on the server is reduced
- What are the main characteristics of the HTTP protocol? Which HTTP methods are common?
Approach
Describe the five properties of HTTP first, since they explain how the protocol is put together, then list the seven methods with what each one does and whether it is idempotent.
Steps
- Describe the connectionless property.
- Describe the stateless property.
- Describe the request-response model.
- Describe the text-based property.
- Describe the extensible property.
- List the seven methods.
Answer
The main characteristics of the HTTP protocol:
-
Connectionless:
- Every request is handled independently
- No connection state is maintained
- The server consumes fewer resources
-
Stateless:
- No state is kept between requests
- Every request stands on its own
- The server scales out easily
-
The request-response model:
- The client sends a request
- The server returns a response
- A simple and clear interaction model
-
Text-based:
- The protocol messages are in text format
- They are easy to debug and to understand
- Many character encodings are supported
-
Extensible:
- Custom headers are supported
- Many content types are supported
- The protocol is easy to extend
The common HTTP methods:
-
GET:
- Retrieves a resource
- The parameters are passed in the URL
- An idempotent operation
-
POST:
- Submits data
- The data is carried in the request body
- A non-idempotent operation
-
HEAD:
- Retrieves the header information of a resource
- The content of the resource is not returned
- Used to check the state of a resource
-
PUT:
- Updates a resource
- Replaces the resource entirely
- An idempotent operation
-
DELETE:
- Deletes a resource
- Deletes the specified resource
- An idempotent operation
-
OPTIONS:
- Retrieves the methods that are supported
- Checks the capabilities of the server
- Used for the CORS preflight
-
TRACE:
- Echoes the request back
- Used for debugging
- Shows the path the request took
Exercise 4: Applied Scenarios
- In a networked application, how do you choose between the C/S model and the P2P model?
Approach
Start from the requirements of the workload rather than from the models themselves: list the requirements that push you towards C/S, then those that push you towards P2P.
Steps
- List the requirements that call for C/S.
- List the requirements that call for P2P.
- State the decision rule.
Answer
The cases that call for the C/S model:
-
A need for centralised management:
- The resources have to be managed centrally
- The security control has to be uniform
- The data has to be managed centrally
-
A strong reliability requirement:
- The service has to be stable
- The servers have to be maintained professionally
- High availability is required
-
A strong security requirement:
- The security control has to be strict
- Authentication is required
- Access rights have to be managed
-
Conventional application scenarios:
- Web services
- Mail services
- File transfer services
- Database services
The cases that call for the P2P model:
-
A need for distribution:
- The resources are spread across many nodes
- The resources of the nodes have to be used fully
- A decentralised architecture is required
-
A strong scalability requirement:
- It has to scale as the number of nodes grows
- The resources of the network have to be used fully
- The costs have to be brought down
-
A strong fault tolerance requirement:
- High fault tolerance is required
- The failure of a single node must not affect the whole
- The system has to be able to heal itself
-
Peer application scenarios:
- File sharing
- Instant messaging
- Distributed computing
- Blockchain applications
- What is the role of the DNS system on the Internet?
Approach
Describe the roles that a naming system has to play on the Internet, from resolving a name to an address through to the operational concerns: routing mail, securing the lookup, spreading load, and surviving a failure.
Steps
- Describe name resolution.
- Describe mail routing.
- Describe the security service.
- Describe load balancing.
- Describe failover.
- Describe geographic distribution.
- Describe service discovery.
Answer
The role of the DNS system on the Internet:
-
Name resolution:
- Converts domain names into IP addresses
- Supports IPv4 and IPv6 addresses
- Provides load balancing
-
Mail routing:
- MX records designate the mail servers
- They support a priority order among mail servers
- They provide the mail routing service
-
Security services:
- DNSSEC provides authenticated verification
- It prevents DNS hijacking attacks
- It keeps the resolution of a name secure
-
Load balancing:
- Several IP addresses correspond to one domain name
- The load of the requests is spread out
- The availability of the service is improved
-
Failover:
- The system switches to a standby server automatically when the primary fails
- The reliability of the service is improved
- The interruption of the service is reduced
-
Geographic distribution:
- The nearest server is returned according to the location of the user
- The network latency is reduced
- The access speed is improved
-
Service discovery:
- Services are discovered through domain names
- The registration and discovery of services are supported
- The management of services is easier
Exercise 5: Comparing Protocols
- Compare the characteristics of the HTTP and FTP protocols.
Approach
Describe each protocol on its own terms first, then state the differences between them directly.
Steps
- Describe the characteristics of HTTP.
- Describe the characteristics of FTP.
- State the differences in purpose.
- State the differences in connection model and state management.
- State the differences in scope.
Answer
The characteristics of HTTP:
-
Simplicity:
- The protocol is simple and easy to implement
- It is text-based, which makes it easy to debug
- Many content types are supported
-
Statelessness:
- No connection state is kept
- Every request is handled independently
- The server scales out easily
-
Flexibility:
- Many HTTP methods are supported
- Custom headers are supported
- Many content types are supported
-
Security:
- HTTPS encryption is supported
- Authentication is supported
- Access control is supported
The characteristics of FTP:
-
The two-connection model:
- The control connection carries the commands
- The data connection carries the files
- The separation of function is explicit
-
Specialised for file transfer:
- It exists for file transfer and nothing else
- Several transfer modes are supported
- File management operations are supported
-
Reliability:
- It runs over TCP, which guarantees reliable transfer
- Resuming an interrupted transfer is supported
- Recovery of a transfer is supported
-
Security:
- User name and password authentication is supported
- Encrypted transfer with SFTP is supported
- Secure transfer with FTPS is supported
The main differences:
-
Purpose:
- HTTP: the general-purpose web protocol
- FTP: a protocol dedicated to file transfer
-
Connection model:
- HTTP: a single connection
- FTP: two connections
-
State management:
- HTTP: stateless
- FTP: stateful
-
Scope:
- HTTP: general web services
- FTP: file transfer only
- Why is HTTPS more secure than HTTP in modern networked applications?
Approach
Answer from the attacker’s point of view: list what the attacker can do against plain HTTP, and give the mechanism that HTTPS adds against each one.
Steps
- Explain encrypted transport.
- Explain authentication of the server.
- Explain data integrity.
- Explain protection against replay attacks.
- Explain certificate verification.
- Explain the security headers.
- Explain the browser and search engine behaviour.
Answer
The reasons HTTPS is more secure than HTTP:
-
Encrypted transport:
- The data is encrypted with SSL/TLS
- Eavesdropping is prevented
- The user’s privacy is protected
-
Authentication of the server:
- The identity of the server is verified
- Man-in-the-middle attacks are prevented
- The client is sure it is connected to the right server
-
Data integrity:
- Tampering with the data is prevented
- The integrity of the data is ensured
- Corruption of the data is prevented
-
Protection against replay attacks:
- Replay attacks are prevented
- The uniqueness of a request is ensured
- The security of the exchange is improved
-
Certificate verification:
- Digital certificates are verified
- The identity of the server is ensured
- Phishing attacks are prevented
-
Security headers:
- Security-related HTTP headers are supported
- XSS attacks are prevented
- CSRF attacks are prevented
-
Support in modern browsers:
- Modern browsers prefer HTTPS
- A security indicator is displayed
- Insecure connections are flagged with a warning
-
Search engine optimisation:
- Search engines index HTTPS sites first
- The ranking of the site is improved
- It matches current web standards
