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.

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!

A quick reminder about networking

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

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

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

Common DNS records

Records map a domain name to an IP address.

  • NS: Name Server
  • CNAME: Alias
  • A: IPv4 address
  • AAAA: IPv6 address

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: far west

What is an application protocol

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

What is an application protocol

  • Defines application communication
  • RFCs on the IETF website:
    • Relies on transport and network protocols
    • Multiple revisions exist

How is structured an application protocol

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

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

How to define an application protocol

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

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
  • Simplified structure for this course:
    • Section 1 - Overview
    • Section 2 - Transport protocol
    • Section 3 - Messages
    • Section 4 - Examples

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?

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?

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.

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.

Example - The SMS protocol

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

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.

Questions

Do you have any questions?

Practical content

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!

Find the practical content

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

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!

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)

Sources