Web protocols play an integral role in instant messaging. XMPP and IRC protocols are two of the most popular instant messaging protocols that are most commonly used, and it is worthwhile to understand how they work and to implement instant messaging on a platform.
Over the last few decades, the technology behind instant messaging protocols has evolved a lot, and it is important for developers to understand the pros and cons of all available options today. The growth of instant messaging in different platforms meant smooth relay of data and a requirement for lower latency.
What are XMPP and IRC Protocols?
XMPP stands for Extensible Messaging and Presence Protocol, originally named Jabber. It is a set of open technologies meant for instant messaging (IM), multi-party chat, voice and video calls, contact list maintenance, collaboration, content syndication, and user presence information, based on XML (Extensible Markup Language). It was first introduced in 1999, and in the two decades that followed, has gained wide adoption.
The protocol, which emerged from the Jabber open-source community, evolved as a way to provide an open, secure, and decentralized alternative to the mainstream IM solutions like MSN, AIM, and ICQ. The core technologies which were formalized in 2004 are meant for streaming XML over a network.
IRC is an abbreviation for Internet Relay Chat, developed by Jakko Oikarinen in Finland in 1988. It is a text-based real-time chat internet application. It includes an interface where you can join “channels” that are dedicated to discussions on a specific topic among multiple users, as well as individual chats between two users.
IRC has a client-server model which requires an IRC client, a network program, to join or start a channel. The IRC client can be an independent program installed on a computer, or it can be browser-based as in the case of the Opera browser, which includes the IRC client, or a client that works on multiple browsers like the MIT Lounge Chat.
Communication happens by users connecting through a client, and the data getting transmitted through servers which are interconnected, and from there to the recipient user connected via the IRC client.
IRC vs XMPP: Components and Architecture
The XMPP protocol has a few core components which make up the technology:
The core XML streaming layer
Transport Layer Security or TLS for channel encryption
Simple Authentication and Security Layer (SASL) for authentication
UTF-8 for Unicode support, including internationalized address
“Presence” or built-in information on the status of network availability
“Rosters” or presence-enabled contact lists
Two-way authorization via presence subscription
IRC is implemented in the application protocol layer. It has the following four chief components:
Networks: IRC runs on independent networks, which can be organized by geography or region, the topic of interest, audience groups, or any other classification criterion. The networks used most often are Freenode, EFNet, Enter The Game, Galaxynet, GamesNET, IRCNet, etc. The IRC networks consist of tens of IRC servers, which connect users through different channels.
Servers: Servers connect all other components of the IRC and are central to the application: from client to client, client to server, and server to server. An IRCD or Internet Chat Relay Daemon is server software that connects the servers and implements the IRC protocol. Servers on a network follow a spanning tree arrangement, as shown in Figure 2.
Clients: The IRC clients connect to the servers and allow users to send their messages to the servers. Examples of clients are mIRC, Xchat for Windows OS, Colloquy, Textual for Mac OS, Weechat, Hexchat for Linux and Unix, and web-chat, Mibbit for web-based chat.
Channels: A channel can be private or public, and is usually topic-specific. The command /LIST which displays all the channels accessible to a user.
IRC vs XMPP: Strengths and Weaknesses
Since XMPP was created as a viable alternative to closed-messaging services, it includes features that make it an appropriate technology for open communication. Over the years, as the requirements for instant messaging have grown, it has been developed to include features like multi-user chat, VoIP calling, etc., on top of its already existent base layers. This is a quick summary of the advantages of using XMPP for building a chat:
Open: XMPP protocols are public, free, and easy to understand and implement. Clients, server components, and code libraries make it easily extensible and implementable in different use cases.
Decentralized: The XMPP architecture is decentralized--which means that it includes a client-server model and the clients do not have direct communication each other. There is no central server like the one in Windows Live Messenger. The implementation is similar to an email, where every client has an XMPP address, similar to an email. So, anyone can run their XMPP server, enabling organizations to manage their own communication.
Secure: XMPP ensures security through the in-built TLS and SASL, which are part of XMPP specifications. An XMPP server can also be isolated from the public network, for example, a company intranet, making it less vulnerable to cyber attacks. Although it does not include end-to-end encryption as yet, the developer community is working on adding that to the stack.
Extensible: Since it is built on XML, XMPP is extensible by design since the beginning. It allows anyone to build new functionality to customize the chat experience on top of the core functionality already included in XMPP. There is an archive of common extensions available, maintained in the XEP series, but anyone can build a new extension for their purpose.
Flexible: Although IM is one of the primary uses of XMPP and the reason it was developed, the use cases of XMPP extend beyond IM. It is a flexible technology that can be used for content syndication, file-sharing, gaming, cloud computing, collaboration and a lot more.
Standard: The core XML streaming protocols of XMPP have been standardized by Internet Engineering Task Force (IETF) as approved internet messaging and presence technology. XMP specifications were published as RFC 3920 and RFC 3921 in 2004, and in 2011 the specifications were revised to be most up-to-date (RFC 6120, RFC 6121 and RFC 7622).
Proven Technology: Since its inception and release in 1999, XMPP technology has been used by tens of thousands of developers for varied use cases. Millions of people are using the technology through popular applications built on XMPP.
Although IRC has many useful features — which made it grow to 10 million users in 2003 — it has seen a decline in the last few years, with only 371K users in 2018. This is a summary of the pros and cons of the IRC protocol:
Low Latency: Since IRC communicates via client-server and server-server connections, it is able to transmit bigger amounts of data in a relatively low time span. This means that even for servers with hundreds of thousands of users, the time lag in sending and receiving a text message is only 1/10th of a second, and maximum, only a second. This was one of the reasons for its fast historic growth, in a time when network connections may not be ideal.
Distributed and Real time: IRC was the pioneering technology for instant messaging across continents, in real time. Since it works on a network of servers that are interconnected, it’s ideal for communication across geographies, and has played an important role in getting information across in times of conflict and disasters, like the Kuwait war, Russian rebellion, Hurricane Katrina, etc. This was in an era without social media.
Not Easy to Scale: The downside of IRC is that it is not that easy to scale. Since the communication happens through servers, if there is a huge number of servers, it can lead to problems in relay of messages.
Label Collisions: The IRC protocol includes three labels: nickname, channel name, and server name. Currently, a user is allowed to pick the label for any of the three. This leads to collisions. It is a well-known issue and unique labels need implementation within the protocol.
Less Secure: If two people create a channel with the same label, they are included within the same channel. This leads to privacy concerns, as servers know all the properties and participants of every channel.
Weaker Encryption: IRC allows TLS encryption from client to server side of the connection. But since an IRC channel may often not be encrypted, it makes it vulnerable to DoS/DDoS attackers and hackers.
IRC vs XMPP: Applications and Use Cases
Some of the most popular platforms using XMPP are Google Talk which was a pioneer in voice calling, Skype, Playstation chat app, Whatsapp, Zoom, Nintendo Switch, Apple (for push notifications), and many more. The only downside of XMPP in certain use cases like multi-user chat is that it can be slow compared to other technologies.
IRC is on its way to a new standardized version, with compatibility with the newer IPv6 protocol and other features. However, the release date for the same is not yet announced. The application has adapted to the requirements of modern-day IM, which includes file-sharing etc., but it is not yet at par with existing chat applications which provide these solutions more conveniently. It also requires some technical knowledge to use IRC, making it less viable for people without a technical background.
IRC or XMPP - Which is Better to Build a Chat Application
The simple answer is - it depends on what your use case is. IRC is better for some while XMPP is more suitable in other use cases. Here’s more on that -
If you would like to build a private chat for your own organization, with security features, XMPP is the better option as it has an inbuilt security layer as well as a decentralized and open-source architecture that enables organizations to build their own chat apps on top of the XMPP protocol.
If you require custom features in your chat app, XMPP is the better option as it has a proven technology core, and there are multiple extensions available as XMPP Extension Protocols, which enable the developer to add custom features without having to develop them from scratch.
For applications other than IM, XMPP is an ideal option as it is flexible by design, and finds uses in gaming, content syndication, push notifications, etc. If these features are required as a part of a program or application, XMPP is the better option.
If a certain chat app has high privacy needs, then IRC would not be an ideal option as it has username conflict issues, and the privacy layer is implemented only on the client to server side of the connection. While in XMPP, TSL and SASL encryption are inbuilt into the core technology, making it ideal for high-privacy use cases.
If the requirement is for a fast text-based chat app, with a geographically distributed user-base, where the network conditions may be less than ideal, then IRC is the better option, as it has low latency and can transmit large amounts of data in lesser time.
IRC is an ideal option for chat rooms which are interest-based or topic-based, and dependent on community building. Since there are many IRC clients that are developed for the app to be robust and is open-source, it is easy to build as well.
Wrapping Up
Hopefully, you’ve figured out the basics about the XMPP and IRC protocols and can move ahead with your development. If you’re looking to build your own chat app, here’s a question you should be asking yourself - Should You Build Chat From Scratch or Buy Chat APIs? Read this article to find your answer.
Did you know? You can start building your own chat app for free using CometChat’s SDKs and APIs? Just sign up to our developer dashboard to get started.
About the author
Arti Agarwal is an alum of IIT Roorkee & MIT. She has pursued advanced education in Data Science and Economics. She's a published author and writer and winner of the "Most Influential Content Marketing Professional" Award by the World Marketing Congress in 2017.
Arti Agarwal
CometChat