In computer science a protocol is a complete specification of the rules for communication between two or more computing devices in a computer network, or, more generally, the rules for communicating among processes that could be on the same or on different computers.
To achieve useful results, most actions will involve the cooperation of multiple protocols. Wise protocol designers do not put too many functions in any one protocol, as it would then be harder to substitute. For example, "physical" protocols variously deal with the hardware connection of a computer to a communications medium. By keeping the physical interface model fairly straightforward, the same connector and electrical logic may be used whether the signals are being carried over twisted pairs of copper wire; over optical fiber; and with wireless systems with distances ranging from a 1 to 100 meters, a few kilometers (IEEE 802.11 wireless LAN) or to radios on interplanetary probes.
Physical protocols will be, to some extent, specified in terms peculiar to the hardware engineering technology involved. As one moves from the wire, information keeps aggregating: signals on the wire map into overhead and data bits; the data bits group into bytes grouped into frames that can reach a destination on a single shared medium; the frames group into packets that can reach destinations in interconnected networks, and so forth.
Specifications for protocols above the physical begin with description of syntax: how to find the start of a group of related bits, how to find the shared-medium destination for a frame, how to find the logical address (think of a telephone number) in an interconnected set of networks. Once the syntax is defined, the meaning (i.e., semantics) of the fields in a protocol data unit is specified. Based on the semantics, the behavior of a receiving process is defined (e.g., ring the phone, turn on the light, open the web page).
Behavior tends to be specified using formal languages, or constructs from automata theory such as deterministic finite state machines. There is no universal means of specifying behavior, but the specification must say what to do with:
- correct data: syntactically and semantically correct, and received in a useful context (e.g., do not talk over the telephone until the called telephone answers)
- inopportune data: the information is correct, but makes no sense in the context existing (e.g., ringing the telephone after a conversation is in progress)
- incorrect data: improper syntax, undefined values of fields, etc.
A more complicated example of a protocol is the set or "stack" of protocols used in computer networking reference models, such as the Internet Protocol Suite or Open Systems Interconnection Reference Model. You are probably reading this page based on the rules your web browser found in the webpage itself, specified in the Hypertext Markup Language (HTML). HTML pages were moved from the server to your workstation with the Hypertext Transfer Protocol (HTTP). HTTP pages were built out of a continuous stream of error-corrected bytes delivered by the Transmission Control Protocol (TCP) from one network edge to the other network edge. Those bytes moved through the Internet in "chunks" of data, called packets, convenient for routers. The packets were split into "Ethernet" (IEEE 802.2) frames and then transmitted through a wired (IEEE 802.3) or wireless (IEEE 802.11) physical medium.