Define an application protocol

https://github.com/heig-vd-dai-course

Web · PDF

L. Delafontaine and H. Louis, with the help of GitHub Copilot

This work is licensed under the CC BY-SA 4.0 license.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Objectives

  • Refresh on networking
  • Learn where to find information about application protocols
  • Understand application protocol
  • Define application protocols
  • How to use an application protocol
  • While quite short, one of the most important chapters of the course!
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

A quick reminder about networking

More details for this section in the course material. You can find other resources and alternatives as well.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

The Internet Protocol (IP)

  • Each computer has a unique IP address
  • IPv4 addresses are limited; NAT routers share IP addresses
  • IPv6 fixes this issue
  • IP addresses are used to route packets
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

The Domain Name System (DNS)

  • DNS maps domain names to IP addresses
  • Example: heig-vd.ch193.134.223.20
  • dig and nslookup are useful tools to query DNS servers
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Common DNS records

Records map a domain name to an IP address.

  • NS: Name Server
  • CNAME: Alias
  • A: IPv4 address
  • AAAA: IPv6 address
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Reserved ports

  • Ports identify processes or services
  • Analogy: an IP address is like a street address, a port is like an apartment number
  • Ports are 16-bit unsigned numbers, maximum 65535
  • Reserved ports: 0-1023
  • Other ports: wild west
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

What is an application protocol

More details for this section in the course material. You can find other resources and alternatives as well.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

What is an application protocol

  • Defines application communication
  • RFCs on the IETF website:
    • Relies on transport and network protocols
    • Multiple revisions exist
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

How is structured an application protocol

More details for this section in the course material. You can find other resources and alternatives as well.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

How is structured an application protocol

  • Defined by a set of rules to follow in a RFC
  • Rules define:
    • Transport protocol
    • Messages order
    • Examples and errors
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

How to define an application protocol

More details for this section in the course material. You can find other resources and alternatives as well.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

How to define an application protocol

  • Lot of work and thinking
  • A protocol is never perfect
  • The more you take your time to think and design it, the less you will have to change it later
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0
  • Simplified structure for this course:
    • Section 1 - Overview
    • Section 2 - Transport protocol
    • Section 3 - Messages
    • Section 4 - Examples
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Section 1 - Overview

This section defines the purpose of the protocol:

  • What is the goal of the protocol?
  • What is the problem that it tries to solve?
  • What the application protocol is used for?
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Section 2 - Transport protocol

This section defines the transport protocol used by the application protocol:

  • What protocol(s) is/are involved? On which port(s)?
  • How are messages/actions encoded?
  • How are messages/actions delimited?
  • How are messages/actions treated (text or binary)?
  • Who initiates/closes the communication?
  • What happens on an unknown message/action/exception?
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Section 3 - Messages

This section defines the messages that can be exchanged between the client and the server.

  • What are the messages/actions?
  • What are the parameters?
  • What are the return values?
  • What are the exceptions?

Try to describe these for a given context, not from each point of view. It makes it way easier to understand and to implement.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Section 4 - Examples

This section defines examples of messages that can be exchanged between the client and the server and the exchange order:

  • What are the examples of messages/actions?
  • What are the examples of exceptions?

It is important to define these examples to illustrate the protocol and to help the reader to understand the protocol using sequence or state diagrams.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Example - The SMS protocol

More details for this section in the course material. You can find other resources and alternatives as well.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Example - The SMS protocol

You are working for a startup that wants to create a new communication app.

The app is simple: it allows users (with unique usernames) to send small text messages (maximum 100 characters) to each other. The server is in charge of sending the messages to the recipients.

You are asked to define the application protocol that will be used by the clients and the server.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Questions

Do you have any questions?

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Practical content

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

What will you do?

  • Define two custom application protocols:
    • "Guess the number" game
    • "Temperature monitoring" application

These application protocols will be used in the next chapters to implement them!

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Find the practical content

You can find the practical content for this chapter on GitHub.

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Finished? Was it easy? Was it hard?

Can you let us know what was easy and what was difficult for you during this chapter?

This will help us to improve the course and adapt the content to your needs. If we notice some difficulties, we will come back to you to help you.

➡️ GitHub Discussions

You can use reactions to express your opinion on a comment!

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

What will you do next?

In the next chapter, you will learn the following topics:

  • Java TCP programming
    • How to create a TCP server
    • How to create a TCP client
    • Implement the "Guess the number" game using TCP (optional)
HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0

Sources

HEIG-VD - DAI Course 2024-2025 - CC BY-SA 4.0