Recently I was reading the AMQP protocol specification from the official website, however, because this is my first protocol that I am trying to study in depth so couple of generic questions about protocols pop up in my head that I would like to find an answer.How does a protocol contain type system, methods, constructors and etc? Where are these things defined?How does my OS system know which TCP port is for AMQP and other protocols based on TCP/IP? Is there some sort of mapping in the OS?How does my OS even know about protocol? Do I install something without knowing?
AMQP protocol and protocols in general
networking;protocol;messaging
How does a protocol contain type system, methods, constructors and etc? Where are these things defined?All of those need to be defined in the protocol specification itself. Not all protocols have a type system, methods or constructors and there is no general consensus what they should look like (especially the type system) in the context of communication protocols.How does my OS system knows which tcp port is for AMQP and other protocols based on TCP/IP? Is there some sort of mapping in the OS?In principle, every protocol can be bound to any existing port. There is just a convention that certain protocols can be reached on a specific port, like port 80 for the HTTP protocol.The program that provides a server for a particular protocol (such as HTTP, AMQP or a protocol that sits on top of that) typically tells the OS on which port it wants to receive the protocol data.How does my OS even know about protocol? Do I install something without knowing?This depends on the protocol in question. Some protocols (like IP, TCP and UDP) are seen as so basic and ubiquitous that every OS comes by default with an implementation for them.Some other protocols (like HTTP or SMTP) are typically implemented in user-space programs and are not known to the OS.Still other protocols that are meant to be used as building blocks for creating other protocols on top of might be provided as libraries that you need to install separately (and might become a default installed part of the OS if they become popular enough). AMQP seems to be in that latter category.