Internet Relay Chat — The UChicago χ-Projects (2024)

IRC is one of the earliest network protocols for text messaging andmulti-participant chatting. It was created in 1988 and, despite theemergence of more sophisticated messaging protocols (including openstandards like XMPP and SIP/SIMPLE, and proprietary protocols such asMicrosoft’s MSNP, AOL’s OSCAR, and Skype), IRC remains a popularstandard and still sees heavy use in certain communities, specially theopen source software community.

Internet Relay Chat — The UChicago χ-Projects (1)

The basic architecture of IRC, shown in the figure above, isfairly straightforward. In the simplest case, there is a single IRCserver to which multiple IRC clients can connect to. An IRC clientconnects to the server with a specific identity. Most notably, eachclient must choose a unique nickname, or “nick”. Once a client isconnected, it can communicate one-to-one with other users. Additionally,clients can run commands to query the server’s state (e.g., to obtain alist of connected users, or to obtain additional details about aspecific nick). IRC also supports the creation of chat rooms calledchannels for one-to-many communication. Users can join channels andsend messages to the channel; these messages will, in turn, be sent toevery user in the channel.

Internet Relay Chat — The UChicago χ-Projects (2)

IRC also supports the formation of server networks, where multipleservers form a tree of connections to support more clients and providegreater capacity. Servers in the same network share information aboutlocal events (e.g., a new client connects, a user connected to a givenserver joins a channel, etc.) so that all servers will have a copy ofthe same global state. In this project, we will only consider the casewhere there is a single IRC server.

The IRC protocol used by IRC servers and clients is a text-based TCPprotocol. Originally specified in 1993[RFC1459], it was subsequentlyspecified in more detail in 2000 through the following RFCs:

  • [RFC2810] Internet RelayChat: Architecture. This document describes the overallarchitecture of IRC.

  • [RFC2811] Internet RelayChat: Channel Management. This document describes how channels aremanaged in IRC.

  • [RFC2812] Internet RelayChat: Client Protocol. This document describes the protocol usedbetween IRC clients and servers (sometimes referred to as the“client-server” protocol)

  • [RFC2813] Internet RelayChat: Server Protocol. This document describes the “server-server”protocol used between IRC servers in the same network.

You are not expected to read all of these documents. More specifically:

  • We recommend you do read all of[RFC2810], as it will giveyou a good sense of what the IRC architecture looks like. You maywant to give it a cursory read at first, and revisit it as you becomemore familiar with the finer points of the IRC protocol.

  • In the second assignment you will implement a subset of[RFC2812]. We suggest youread [RFC2812 §1]and [RFC2812 §2].For the remainder of the RFC, you should only read the sectionsrelevant to the parts of the IRC protocol you will be implementing.

  • In the third assignment you will implement a subset of the functionalitydescribed in [RFC2811],which will require implementing additional parts of[RFC2812]. We suggest youhold off on reading[RFC2811] until we reachthe third assignment; if you do want to read the introductory sections, takeinto account that we will only be supporting “standard channels” inthe “#” namespace, and that we will not be supporting servernetworks.

  • In the fifth assignment, you will implement a subset of[RFC2813],which will require implementing and updating some parts of[RFC2812]. You will not bedealing with server-to-server connections until the fifth assignment,so you can safely skip reading [RFC2813]until then.

Finally, you should take into account that, although IRC has an officialspecification, most IRC servers and clients do not conform to theseRFCs. Most (if not all) servers do not implement the full specification(and even contradict it in some cases), and there are many features thatare unique to specific implementations. In this project, we will producean implementation that is partially compliant with these RFCs, andsufficiently compliant to work with some of the main IRC clientscurrently available.

In the remainder of this section, we will see an overview of the messageformat used in IRC. Then, in the next section, we will see severalexample communications (involving multiple messages between a client anda server).

Message format

IRC clients and servers communicate by sending plain ASCII messages toeach other over TCP. The format of these messages is described in[RFC2812 §2.3], andcan be summarized thusly:

  • The IRC protocol is a text-based protocol, meaning that messagesare encoded in plain ASCII. Although not as efficient as a purebinary format, this has the advantage of being fairly human-readable,and easy to debug just by reading the verbatim messages exchangedbetween clients and servers.

  • A single message is a string of characters with a maximum length of512 characters. The end of the string is denoted by a CR-LF (CarriageReturn - Line Feed) pair (i.e., “\r\n”). There is no nullterminator. The 512 character limit includes this delimiter, meaningthat a message only has space for 510 useful characters.

  • The IRC specification includes no provisions for supporting messageslonger than 512 characters, although many servers and clients supportnon-standard solutions (including ignoring the 512 limit altogether).In our implementation, any message with more than 510 characters (notcounting the delimiter) will be truncated, with the last twocharacters replaced with “\r\n”.

  • A message contains at least two parts: the command and the commandparameters. There may be at most 15 parameters. The command and theparameters are all separated by a single ASCII space character. Thefollowing are examples of valid IRC messages:

    NICK amyWHOIS doctorMODE amy +oJOIN #tardisQUIT
  • When the last parameter is prefixed with a colon character, the valueof that parameter will be the remainder of the message (includingspace characters). The following are examples of valid IRC messageswith a “long parameter”:

    PRIVMSG rory :Hey Rory...PRIVMSG #cmsc23300 :Hello everybodyQUIT :Done for the day, leaving
  • Some messages also include a prefix before the command and thecommand parameters. The presence of a prefix is indicated with asingle leading colon character. The prefix is used to indicate theorigin of the message. For example, when a user sends a message toa channel, the server will forward that message to all the users inthe channel, and will include a prefix to specify the user that sentthat message originally. We will explain the use of prefixes in moredetail in the next section.

    The following are examples of valid IRC messages with prefixes:

    :borja!borja@polaris.cs.uchicago.edu PRIVMSG #cmsc23300 :Hello everybody:doctor!doctor@baz.example.org QUIT :Done for the day, leaving

Replies

The IRC protocol includes a special type of message called a reply.When a client sends a command to a server, the server will send a reply(except in a few special commands where a reply should not be expected).Replies are used to acknowledge that a command was processed correctly,to indicate errors, or to provide information when the command performsa server query (e.g., asking for the list of users or channels).

A reply is a message with the following characteristics:

  • It always includes a prefix.

  • The command will be a three-digit code. The full list of possiblereplies is specified in [RFC2812 §5].

  • The first parameter is always the target of the reply, typically anick.

The following are examples of valid IRC replies:

:irc.example.com 001 borja :Welcome to the Internet Relay Network borja!borja@polaris.cs.uchicago.edu:irc.example.com 433 * borja :Nickname is already in use.:irc.example.org 332 borja #cmsc23300 :A channel for CMSC 23300 students
Internet Relay Chat — The UChicago χ-Projects (2024)

References

Top Articles
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 5974

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.