comparison doc/MSN-PROTOCOL @ 1560:72235e3fcff6

[gaim-migrate @ 1570] Jason Boerner's --file patch. Also added/removed files from POTFILES.in and added the MSN protocol spec. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 10 Mar 2001 22:42:47 +0000
parents
children cb4fbcdae9eb
comparison
equal deleted inserted replaced
1559:99606e418aae 1560:72235e3fcff6
1 Instant Messaging and Presence Protocol R. Movva
2 Internet Draft Microsoft
3 Category: Informational August, 1999
4 Document: draft-movva-msn-messenger-protocol-00.txt
5 Document Expires: 2/00 W. Lai
6 Microsoft
7 August, 1999
8
9
10
11 MSN Messenger Service 1.0 Protocol
12
13
14
15 Status of this Memo
16
17 This document is an Internet-Draft and is NOT offered in accordance
18 with Section 10 of RFC2026, and the author does not provide the IETF
19 with any rights other than to publish as an Internet-Draft.
20
21 Internet-Drafts are working documents of the Internet Engineering
22 Task Force (IETF), its areas, and its working groups. Note that
23 other groups may also distribute working documents as Internet-
24 Drafts. Internet-Drafts are draft documents valid for a maximum of
25 six months and may be updated, replaced, or obsoleted by other
26 documents at any time. It is inappropriate to use Internet-Drafts as
27 reference material or to cite them other than as "work in progress."
28
29 The list of current Internet-Drafts can be accessed at
30 http://www.ietf.org/ietf/1id-abstracts.txt
31
32 The list of Internet-Draft Shadow Directories can be accessed at
33 http://www.ietf.org/shadow.html.
34
35 This document and related documents are discussed on the impp
36 mailing list. To join the list, send mail to impp-
37 request@iastate.edu. To contribute to the discussion, send mail to
38 impp@iastate.edu. The archives are at http://lists.fsck.com/cgi-
39 bin/wilma/pip. The IMPP working group charter, including the current
40 list of group documents, can be found at
41 http://www.ietf.org/html.charters/impp-charter.html.
42
43
44
45 1. Abstract
46
47 Microsoft released a commercial Instant Messaging product in July of
48 1999 called MSN Messenger Service. This document describes the
49 protocol used by that product for core instant messaging and
50 presence functionality. While this protocol does not meet many of
51 the requirements of the IMPP working group, it is provided as
52 background information on existing Instant Messaging
53 implementations. This protocol is provided 'as is' without warranty
54 of any kind.
55
56
57 Movva and Lai Category - Informational 1
58
59 MSN Messenger Service 1.0 Protocol Aug - 99
60
61
62
63 2. Conventions used in this document
64
65 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
66 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in
67 this document are to be interpreted as described in RFC-2119.
68
69 Protocol messages sent from client to server are preceded by "C:".
70
71 Protocol messages sent from server to client are preceded by "S:".
72
73
74
75 3. Introduction
76
77 MSN Messenger Service enables a user to learn about the presence of
78 other people on the Internet, and to communicate with them in real-
79 time. This functionality is commonly referred to as "Instant
80 Messaging" (IM).
81
82 This document describes the syntax and semantics of the MSN
83 Messenger Protocol, the communication protocol running between MSN
84 Messenger Service 1.0 clients and servers. Among the core services
85 that the MSN Messenger Servers provide to clients are:
86
87 - Authenticated user logon.
88 - Adding and deleting members of the user's contact list.
89 - Changing the user's on-line state.
90 - Receipt of asynchronous, real-time, on-line state change
91 notifications from members of the user's contact list.
92 - Delivering lightweight, real-time messages to other users.
93 - Receipt of asynchronous, real-time messages from other users.
94 - Configuring the user's access permissions, to restrict the ability
95 of other users to view the user's on-line state or send messages
96 to the user.
97
98 Additional background:
99
100 1. Some features extraneous to core instant messaging functionality
101 contained within the MSN Messenger Service 1.0 protocol are beyond
102 the scope of this document. Examples include client version
103 management and directory functionality.
104
105 2. The purpose of this document is to provide the members of the
106 IMPP working group with a reference implementation of a "monolithic"
107 IM system. That is, a system designed for massive scale, but not yet
108 capable of communication with servers other than those associated
109 with this specific service. Since any standard in this area will of
110 necessity be a "distributed" design that explicitly enables server-
111 to-server and service-to-service communication, this document will
112 serve primarily as a reference and example of one implementer's
113 choices when providing IM functionality at scale.
114
115
116 Movva and Lai Category - Informational 2
117
118 MSN Messenger Service 1.0 Protocol Aug - 99
119
120
121 3. This document reflects the protocol used in the 1.0 release of
122 MSN Messenger clients and servers, deployed on the Internet in July
123 of 1999. However, the service is in production and rapidly growing,
124 which almost certainly will necessitate changes to the protocol as
125 Microsoft gains operational experience with the service and expands
126 its feature set. This Internet Draft may not be updated with such
127 changes, and the changes may be made with little or no notice.
128
129
130
131 4. MSN Messenger Server Component Overview
132
133 MSN Messenger Service clients make connections to several different
134 kinds of servers. They are separate components to facilitate running
135 at scale - each component can be duplicated an arbitrary number of
136 times, independently of each other, to enable large numbers of
137 users.
138
139 4.1 Dispatch Server (DS)
140
141 The Dispatch Server is the initial point of connection between
142 client and server. Its primary functions are protocol version
143 negotiation, determination of which Notification Server (NS) is
144 associated with the client making a connection (via an algorithm of
145 the server's choosing), and referring the client to the proper NS.
146
147 4.2 Notification Server (NS)
148
149 The Notification Server is the primary server component. The client
150 and the Notification Server authenticate, synchronize user
151 properties, and exchange asynchronous event notifications. The
152 client's connection to the Notification Server occurs after the
153 referral from the Dispatch Server is completed, and persists without
154 interruption during the user's MSN Messenger Service session.
155
156 Some of the events transmitted between a client and a Notification
157 Server are: State changes (e.g. client is on-line, client is
158 offline, client is idle), Switchboard Server invitation requests
159 (see below), and application-specific notifications that are beyond
160 the scope of this document. (E.g. new e-mail has arrived)
161
162 4.3 Switchboard Server (SS)
163
164 The Switchboard Server is the component through which clients can
165 establish lightweight communication sessions without requiring a
166 direct network connection between clients. The common usage of the
167 Switchboard Server is to provide instant messaging sessions.
168 When a client wishes to communicate with another client, it sends a
169 message to its Notification Server, which then refers the client to
170 a Switchboard Server. Once the SS connection is established, the
171 "destination" client receives a notification from its NS to connect
172 to the same SS.
173
174
175 Movva and Lai Category - Informational 3
176
177 MSN Messenger Service 1.0 Protocol Aug - 99
178
179
180 5. Protocol Conventions
181
182 5.1 Connection Type
183
184 The MSN Messenger Protocol currently works over TCP/IP. The MSN
185 Messenger server components support connections over port numbers
186 1863, which is the registered port number assigned by the IANA
187 (http://www.isi.edu/in-notes/iana/assignments/port-numbers).
188
189 5.2 Command Syntax
190
191 MSN Messenger Protocol command syntax is ASCII and single line-
192 based. Commands begin with a case-sensitive, three-letter command
193 type, followed by zero or more parameters, and terminated by CRLF.
194 Parameters are separated by one or more whitespace characters and
195 cannot contain whitespace characters. Parameters that contain spaces
196 or extended (non 7-bit ASCII) characters should be encoded using
197 URL-style encoding (e.g. "%20" for space). Some commands accept un-
198 encoded binary data. In these cases, the length of the data is
199 transmitted as part of the command, and the data is transmitted
200 immediately following a CRLF of the command.
201
202 5.3 Asynchronous Requests
203
204 Commands issued from the client to the server that result in a reply
205 are known as requests. Requests are entirely asynchronous. The
206 client can submit several requests in sequence without waiting for
207 the server response after submitting each request. The server is
208 required to deliver a response or an error for each request
209 received, but it is not required to deliver the responses in the
210 same order as the requests were received. The client can determine
211 the request associated with a particular response by examining the
212 Transaction ID parameter (described below).
213
214 5.4 User Handles
215
216 MSN Messenger Protocol uses User Handles for identifying users. A
217 user handle (also known as "account name" and "logon name") is a
218 text representation of the user's identity that is both unique and
219 persistent. The user handle is syntactically equivalent to an e-mail
220 address, and as such is subject to the same restrictions for
221 character set, as described in RFC-822. Most notable among these
222 restrictions are the limitation to Latin alphanumeric characters and
223 a few symbols. The maximum acceptable length of the user handle is
224 129 bytes.
225
226 Implementation note: In the initial release of the client and
227 server, user handles are Hotmail account names. All user handles
228 must contain the "@hotmail.com" domain name, and user handles that
229 do not contain a domain name are not valid.
230
231 5.5 Custom User Names
232
233
234 Movva and Lai Category - Informational 4
235
236 MSN Messenger Service 1.0 Protocol Aug - 99
237
238
239 A custom user name (also known as "custom name" and "friendly name")
240 is a user's representation of the "friendly" textual name associated
241 with a user handle. (E.g. "Auntie Em" instead of em123@hotmail.com).
242 Custom user names are neither unique nor persistent, and can contain
243 any valid Unicode characters. Custom user names are represented in
244 UTF-8 as described in RFC-2044 and URL-encoded as described in RFC-
245 1738 when transmitted between the client and server. The maximum
246 acceptable length of the encoded custom user name is 387 in the
247 current implementation.
248
249 5.6 Transaction Identifiers
250
251 The Transaction Identifier (a.k.a. Transaction ID) is a numeric
252 string representing a number between 0 and (2^32 - 1). It is a value
253 that a client includes with any command that it issues to the
254 server. In the current version of the protocol, the transaction
255 identifier is used to associate server responses with client-issued
256 commands. The server treats the transaction ID as an opaque number
257 and does not assume any relationship between successive Transaction
258
259 IDs or any particular starting Transaction ID. It is the client's
260 responsibility to guarantee the uniqueness of the Transaction IDs
261 for the purpose of disambiguating the commands and/or responses. (A
262 future version of the protocol could enable the client to track the
263 status or cancel a particular transaction using the transaction ID.)
264
265 When the server sends the response to a command to the client, it
266 must include in the response the transaction ID that the client sent
267 to the server when the client originally issued the command. In
268 cases where a server sends a command to a client that requires a
269 transaction ID but is not in response to a specific client command,
270 it will use 0 as the transaction ID. In cases where a server sends
271 multiple responses to a single client request, the server will use
272 the same transaction ID in each response.
273
274 5.7 User List Types
275
276 Some of the protocol commands are used to the manipulate lists of
277 users. The following types of user lists are supported by the
278 protocol:
279
280 Forward List (FL) - The list of users for whom a given user wants to
281 receive state change notifications. The Forward List is what is most
282 commonly referred to as the user's "contact list."
283
284 Reverse List (RL) - The list of users who have registered an
285 interest in seeing this user's state change notifications.
286
287 Allow List (AL) - The list of users who the user has explicitly
288 allowed to see state change notifications and establish client-to-
289 client sessions via a Switchboard Server.
290
291
292
293 Movva and Lai Category - Informational 5
294
295 MSN Messenger Service 1.0 Protocol Aug - 99
296
297
298 Block List (BL) - The list of users who the user has explicitly
299 prevented from seeing state change notifications and establishing
300 client-to-client sessions via a Switchboard Server.
301
302
303
304 6. Command Summary Table
305
306 Command From To Description
307 ==================================================================
308 ACK Switchboard Client Sends a positive message
309 delivery acknowledgement.
310 -------------------------------------------------------------------
311 ADD Client Notification Adds to the user's FL, AL,
312 Notification Client and BL. Notifies the client
313 of asynchronous additions
314 to a user's list.
315 -------------------------------------------------------------------
316 ANS Client Switchboard Accepts a request for a
317 switchboard server session.
318 -------------------------------------------------------------------
319 BLP Client Notification Changes the user's message
320 Notification Client privacy setting, which
321 determines how to treat
322 messages from users not
323 already in the BL or AL.
324 -------------------------------------------------------------------
325 BYE Switchboard Client Notifies a client that a
326 user is no longer in the
327 session.
328 -------------------------------------------------------------------
329 CAL Client Switchboard Initiates a switchboard
330 server session.
331 -------------------------------------------------------------------
332 CHG Client Notification Sends a client state change
333 Notification Client to the server.
334 Echoes the success of
335 client's state change
336 request.
337 -------------------------------------------------------------------
338 FLN Notification Client Notifies the client when
339 users in the FL go off-
340 line.
341 -------------------------------------------------------------------
342 GTC Client Notification Changes the user's prompt
343 Notification Client setting, which determines
344 how the client reacts to
345 certain RL changes.
346 -------------------------------------------------------------------
347 INF Client Dispatch, Requests set of support
348 Notification authentication protocol
349 Dispatch, Client from the server.
350 Notification Provides the set of
351
352 Movva and Lai Category - Informational 6
353
354 MSN Messenger Service 1.0 Protocol Aug - 99
355
356
357 supported authentication
358 protocols to the client.
359 -------------------------------------------------------------------
360 ILN Notification Client Notifies the client of the
361 initial online state of a
362 user in the FL, while
363 either logging on or adding
364 a user to the FL.
365 -------------------------------------------------------------------
366 IRO Switchboard Client Provides the initial roster
367 information for new users
368 joining the session.
369 -------------------------------------------------------------------
370 JOI Switchboard Client Notifies a client that a
371 user is now in the session.
372 -------------------------------------------------------------------
373 LST Client Notification Retrieves the server's
374 Notification Client version of the user's FL,
375 RL, AL, or BL.
376 -------------------------------------------------------------------
377 MSG Client Switchboard Sends a message to the
378 members of the current
379 session.
380 -------------------------------------------------------------------
381 MSG Notification, Client Delivers a message from
382 Switchboard another client or from a
383 server-side component.
384 -------------------------------------------------------------------
385 NAK Switchboard Client Sends a negative message
386 delivery acknowledgement.
387 -------------------------------------------------------------------
388 NLN Notification Client Notifies the client when
389 users in the FL go on-line
390 or when their on-line state
391 changes.
392 -------------------------------------------------------------------
393 OUT All All Ends a client-server
394 Session.
395 -------------------------------------------------------------------
396 REM Client Notification Removes from the user's FL,
397 Notification Client AL, and BL.
398 Notifies the client of
399 asynchronous removals from
400 a user's list.
401 -------------------------------------------------------------------
402 RNG Notification Client Notifies the client of a
403 request by another client
404 to establish a session via
405 a switchboard server.
406 -------------------------------------------------------------------
407 SYN Client Notification Initiates client-server
408 Notification Client property synchronization.
409 -------------------------------------------------------------------
410
411 Movva and Lai Category - Informational 7
412
413 MSN Messenger Service 1.0 Protocol Aug - 99
414
415
416 USR All All Authenticates client with
417 server, possibly in
418 multiple passes.
419 ------------------------------------------------------------------
420 VER Client Dispatch Negotiates common protocol
421 Dispatch Client dialect between client and
422 Server.
423 ------------------------------------------------------------------
424 XFR Client Notification Requests a Switchboard
425 Notification Client server for use in
426 establishing a session.
427 -------------------------------------------------------------------
428 XFR Dispatch Client Notification of login-NS to
429 Notification Client the client or notification
430 to move to a different NS.
431 =======================================================================
432
433
434
435 7. Presence and State Protocol Details
436
437 This is a detailed list of protocol commands associated with
438 presence functionality. They are defined in the order used by
439 clients. Commands associated with instant messages are discussed in
440 section 8 below.
441
442 7.1 Protocol Versioning
443
444 After the client connects to a dispatch server by opening a TCP
445 socket to port 1863, the client and server agree on a particular
446 protocol version before they proceed. The Client-Server protocol
447 version handshake involves the following command exchange:
448
449 C: VER TrID dialect-name{ dialect-name...}
450 S: VER TrID dialect-name
451
452 The client can provide multiple dialect names in preferred order.
453 The dialect-name parameter returned by the server is the version
454 server is designating for this connection
455
456 The current protocol dialect-name supported by Messenger servers is
457 "MSNP2". The dialect names are not case-sensitive.
458
459 The string "0" is a reserved dialect name and is used to indicate a
460 failure response. E.g.:
461
462 S: VER TrID 0{ dialect-name ... }
463
464 7.2 Server Policy Information
465
466 The client next queries the server for variable "policy"
467 information. In this version of the protocol, the only policy
468
469
470 Movva and Lai Category - Informational 8
471
472 MSN Messenger Service 1.0 Protocol Aug - 99
473
474
475 information returned by the server is the authentication package in
476 use.
477
478 C: INF TrID
479 S: INF TrID SP{,SP...}
480
481 SP identifies a security package - the name of the SASL mechanism to
482 use for authentication. "MD5" is used by the Notification Server,
483 "CKI" by the Switchboard Server.
484
485 7.3 Authentication
486
487 The client needs to authenticate itself after protocol version
488 handshake and identifying the security packages supported on the
489 server. The following are the client server interactions involved.
490
491 C: USR TrID SP I{ AuthInitiateInfo}
492 S: USR TrID SP S{ AuthChallengeInfo}
493 C: USR TrID SP S{ AuthResponseInfo }
494 S: USR TrID OK UserHandle FriendlyName
495
496 The SP parameter is the name of the security package("MD5"). The
497 next parameter is a sequence value, which must be I to (I)nitiate
498 the authentication process and S for all (S)ubsequent messages. If
499 authentication fails on the server, the client can start the
500 authentication process again.
501
502 For the MD5 security package:
503 - The AuthInitiateInfo parameter provided by the client must be the
504 User handle.
505 - The AuthChallengeInfo parameter returned by the server contains a
506 challenge string.
507 - The AuthResponseInfo contains the binary response as a hexadecimal
508 string, which the MD5 hash of the challenge and the User password
509 strings concatenated together.
510
511 The final response from the server contains, in addition to the user
512 handle, the current "Friendly Name" associated with the user handle.
513 This is a "Custom User Name" as described above.
514
515 7.4 Referral
516
517 There are three cases in which clients are referred from one server
518 to another:
519
520 1. The initial "Dispatch Server" refers the client to the
521 Notification Server to which it is assigned.
522 2. Asynchronous referral by the Notification Server to reassign the
523 client to a different Notification Server if that server is
524 overloaded or undergoing maintenance.
525 3. During Switchboard Session establishment, the assigned
526 Notification Server refers the client to a particular
527 switchboard server for use. This is discussed below.
528
529 Movva and Lai Category - Informational 9
530
531 MSN Messenger Service 1.0 Protocol Aug - 99
532
533
534
535 In the current implementation the Dispatch Server uses the user
536 handle provided in the initial USR command above to assign the user
537 in question to a Notification Server. Alternate implementations
538 might not require referral at this stage.
539
540 If received, referral is of the form:
541
542 S: XFR TrID ReferralType Address[:PortNo]
543
544 ReferralType is either "NS" or "SB" and defines the type of referral
545 to a Notification Server or Switchboard Server.
546 Address is a valid DNS name or IP address to a referred server, with
547 optional port# suffixed as ":PortNo".
548
549 If this command is received from the server, the client should
550 attempt to log in to the server provided.
551
552 In the case of "NS" referrals during logon, the Server automatically
553 closes the client connection after sending this XFR response so that
554 the client can connect to the new IP Address.
555
556 If sent asynchronously, the client is responsible for closing the
557 connection.
558
559 After a "NS" referral, the client will not receive any more messages
560 from the "old" NS, and also must not send any commands to the "old"
561 NS after receiving an XFR.
562
563 7.5 Client User Property Synchronization
564
565 Several of the user properties used by the Messenger application are
566 stored on the server. This is done for two reasons:
567
568 1) So that users can "roam", i.e. log in from different locations
569 and still have the appropriate data, such as their contact lists and
570 privacy settings.
571 2) If changes occur to a user's Reverse List while that user was
572 offline (the user was added to another user's list), the client can
573 be updated with this information.
574
575 For performance reasons it is useful to cache these properties on
576 the client, so that bandwidth usage is minimized in the typical case
577 where the user is not roaming and there were no Reverse List
578 changes.
579
580 These requirements are met by the SYN command - synchronization.
581
582 Once a client logs in successfully, it uses the SYN command to
583 ensure it has the latest version of the server-stored properties.
584 These properties include: Forward List, Reverse List, Block List,
585 Allow List, GTC setting (privacy setting when someone adds this user
586 to their Forward List), and BLP setting (the user's privacy mode).
587
588 Movva and Lai Category - Informational 10
589
590 MSN Messenger Service 1.0 Protocol Aug - 99
591
592
593
594 The SYN command is:
595
596 C: SYN TrID Ser#
597 S: SYN TrID Ser#
598
599 The Ser# parameter sent by the client is the version of the
600 properties currently cached on the client. The server responds with
601 the current server version of the properties. If the server has a
602 newer version, the server will immediately follow the SYN reply by
603 updating the client with the latest version of the user properties.
604 These updates are done as described below, and are done without the
605 client explicitly initiating a LST, GTC or BLP command. Note that
606 the server will update all server-stored properties to the client,
607 regardless of how many entries have been changed.
608
609 The following "List Retrieval and Property Management" section
610 describes the format of the user properties sent by the server.
611 After the SYN reply from the server, the user property updates will
612 be sent from the server in this sequence: GTC, BLP, LST FL, LST AL,
613 LST BL, LST RL.
614
615 All the user property updates will share the same TrID as the SYN
616 command and reply.
617
618 7.6 List Retrieval And Property Management
619
620 Synchronizing can result in a batch of user properties and lists
621 getting sent by the server to the client. However, the client
622 application can also initiate a request to retrieve the server-
623 stored lists and properties. The following are the privacy property
624 and list retrieval commands. The response formats are the same
625 whether it is a client-initiated request, or whether it is a
626 response to the SYN process as described above.
627
628
629 List Command
630
631 By issuing the LST command, the client can explicitly request that a
632 list be sent. The server will respond with a series of LST
633 responses, one LST response for each item in the requested list.
634
635 C: LST TrID LIST
636 S: LST TrID LIST Ser# Item# TtlItems UserHandle CustomUserName
637
638 - LIST is FL/RL/AL/BL for Forward List, Reverse List, Allow List,
639 and Block List, respectively.
640 - The Item# parameter contains the index of the item described in
641 this command message. (E.g. item 1 of N, 2 of N, etc.)
642 - The TtlItems parameter contains the total number of items in this
643 list.
644 - UserHandle is the user handle for this list item.
645 - CustomUserName is the friendly name for this list item.
646
647
648 Movva and Lai Category - Informational 11
649
650 MSN Messenger Service 1.0 Protocol Aug - 99
651
652
653 If the list is empty, the response will be:
654
655 S: LST TrID LIST Ser# 0 0
656
657 Reverse List Prompting
658
659 The client can change its persistent setting for when to prompt the
660 user in reaction to an Reverse List change. This is accomplished via
661 the GTC command:
662
663 C: GTC TrID [A | N]
664 S: GTC TrID Ser# [A | N]
665
666 The value of the A/N parameter determines how the client should
667 behave when it discovers that a user is in its RL, but is not in its
668 AL or BL. (Note that this occurs when a user has been added to
669 another user's list, but has not been explicitly allowed or
670 blocked):
671
672 A - Prompt the user as to whether the new user in the RL should be
673 added to the AL or the BL
674 N - Automatically add the new user in the RL to the AL
675
676 The A/N parameter is not interpreted by the server, merely stored.
677
678 The server will respond with the current setting if the change was
679 successful. Otherwise, it will return an error with the matching
680 TrID. If the client tries to change the setting to the same value as
681 the current setting, the server will respond with an error message.
682
683 The default setting is A when a new user connects to the server for
684 the first time.
685
686 Privacy Mode
687
688 The client can change how the server handles instant messages from
689 users via the BLP command:
690
691 C: BLP TrID [AL | BL]
692 S: BLP TrID Ser# [AL | BL]
693
694 The AL/BL parameter determines how the server should treat messages
695 (MSG and RNG) from users. If the current setting is AL, messages
696 from users who are not in BL will be delivered. If the current
697 setting is BL, only messages from people who are in the AL will be
698 delivered.
699
700 The server will respond with the current setting if the change was
701 successful. Otherwise, it will return an error with the matching
702 TrID. If the client tries to change the setting to the same value as
703 the current setting, the server will respond with an error message.
704
705
706
707 Movva and Lai Category - Informational 12
708
709 MSN Messenger Service 1.0 Protocol Aug - 99
710
711
712 The default setting is AL when a new user connects to the server for
713 the first time.
714
715
716 7.7 Client States
717
718 After the client is authenticated and synchronized, the client
719 establishes its initial state with the server with the CHG command.
720 The syntax of the command is:
721
722 C: CHG TrID State
723 S: CHG TrID State
724
725 When the state is changed, the server will echo the settings back to
726 client. The state shall not be considered changed until the response
727 is received from the server.
728
729 Note that the server can send a state change message to the client
730 at any time. If the server changes the state without a request from
731 the client, the TrID parameter will be 0.
732
733 States are denoted by a string of three characters. The predefined
734 states that the server recognizes are:
735
736 NLN - Make the client Online (after logging in) and send and receive
737 notifications about buddies.
738 FLN - Make the client Offline. If the client is already online,
739 offline notifications will be sent to users on the RL. No message
740 activity is allowed. In this state, the client can only synchronize
741 the lists as described above.
742 HDN - Make the client Hidden/Invisible. If the client is already
743 online, offline notifications will be sent to users on the RL. The
744 client will appear as Offline to others but can receive
745 online/offline notifications from other users, and can also
746 synchronize the lists. Clients cannot receive any instant messages
747 in this state.
748
749 All other States are treated as sub-states of NLN (online). The
750 other States currently supported are:
751 BSY - Busy.
752 IDL - Idle.
753 BRB - Be Right Back.
754 AWY - Away From Computer.
755 PHN - On The Phone.
756 LUN - Out To Lunch.
757
758 7.8 List Modifications
759
760 The protocol supports generic commands to add and remove users from
761 various lists. This is used by clients to enable "Adding" contacts
762 to the list of folks being watched, or for the "Block" and "Allow"
763 features that define how users chooses to interact with one another.
764
765
766 Movva and Lai Category - Informational 13
767
768 MSN Messenger Service 1.0 Protocol Aug - 99
769
770
771 However, these generic commands have different semantics based on
772 the list being modified. For example, only the server can add or
773 remove entries from the Reverse List - since it is an indirect
774 consequence of the user having been added to another user's Forward
775 List.
776
777 The add and remove commands:
778
779 C: ADD TrID LIST UserHandle CustomUserName
780 S: ADD TrID LIST ser# UserHandle CustomUserName
781
782 C: REM TrID LIST UserHandle
783 S: REM TrID LIST ser# UserHandle
784
785 Valid values for LIST in Client initiated adds and removes are
786 FL/AL/BL.
787
788 All client initiated adds and removes will be echoed by the server
789 with a new serial number that should be persisted by the client
790 along with the list modification. If not successful, an error will
791 result.
792
793 The protocol also supports the concept of an ADD or REM that the
794 client did not initiate. Server generated ADDs and REMs can have
795 LIST values of FL/AL/BL/RL. This is common with RL changes, which
796 are never initiated by the client, but is an indirect consequence of
797 this user having been added to someone's Forward List. If the RL
798 change happens while the user is online, it will trigger an
799 asynchronous ADD or REM command from the server.
800
801 Asynchronous ADDs and REMs to the FL, AL, and BL can happen when the
802 server allows an authenticated user to make list changes from
803 another environment, such as a web site. In all of these cases, the
804 server will send the ADD or REM command with the TrID parameter
805 equal to 0.
806
807 7.9 Notification Messages
808
809 The client receives asynchronous notifications whenever a contact on
810 the user's Forward List changes its state. The notifications are of
811 the form:
812
813 S: NLN Substate UserHandle FriendlyName
814 S: ILN TrID Substate UserHandle FriendlyName
815 S: FLN UserHandle
816
817 NLN indicates that a user has come online.
818 - Substate can be any three-letter code (see "Client States" above).
819 - UserHandle and FriendlyName are the handle and names associated
820 with the user coming online.
821
822 ILN is similar to the NLN message, and is received from the server
823 in response to an CHG or ADD command from the client:
824
825 Movva and Lai Category - Informational 14
826
827 MSN Messenger Service 1.0 Protocol Aug - 99
828
829
830
831 1. Immediately after the client logon and sends its first CHG
832 command to the NS. In this case several ILNs may be received -
833 one for each Forward List contact that is currently online.
834 2. After the client sends an "ADD TrID FL UserHandle
835 CustomUserName" to the NS. (e.g. ILN for the new contact if that
836 contact is currently online)
837
838 In both cases, TrID in the ILN is the same as the one sent by the
839 client in the CHG or ADD command.
840
841 FLN means that the specified user is now offline.
842
843 7.10 Connection Close
844
845 The client issues the following command to logoff from the NS:
846
847 C: OUT
848 S: OUT {StatusCode}
849
850 The server will reply with an OUT to the client before it initiates
851 a disconnect, with an optional StatusCode.
852
853 The StatusCode can be "OTH", which indicates that a client with the
854 same user handle and password has logged on to the server from
855 another location, or "SSD" meaning the server is being shut down for
856 maintenance.
857
858 The server will drop the connection after sending the OUT.
859
860 7.11 Error Information
861
862 Error messages from the server are of the format:
863
864 S: eee {TrID} {(error-info) {param...}}
865
866 eee is a 3 digit decimal number indicating the error code. Error-
867 info contains the description of the error in a text string
868 localized to the server's locale. The optional parameters provide
869 indication of the client command causing the error. TrID is the
870 Transaction ID of the client command that caused this error. Any
871 server generated errors will not have Transaction IDs.
872
873
874 ERR_SYNTAX_ERROR 200
875 ERR_INVALID_PARAMETER 201
876 ERR_INVALID_USER 205
877 ERR_FQDN_MISSING 206
878 ERR_ALREADY_LOGIN 207
879 ERR_INVALID_USERNAME 208
880 ERR_INVALID_FRIENDLY_NAME 209
881 ERR_LIST_FULL 210
882 ERR_ALREADY_THERE 215
883
884 Movva and Lai Category - Informational 15
885
886 MSN Messenger Service 1.0 Protocol Aug - 99
887
888
889 ERR_NOT_ON_LIST 216
890 ERR_ALREADY_IN_THE_MODE 218
891 ERR_ALREADY_IN_OPPOSITE_LIST 219
892 ERR_SWITCHBOARD_FAILED 280
893 ERR_NOTIFY_XFR_FAILED 281
894
895 ERR_REQUIRED_FIELDS_MISSING 300
896 ERR_NOT_LOGGED_IN 302
897 ERR_INTERNAL_SERVER 500
898 ERR_DB_SERVER 501
899 ERR_FILE_OPERATION 510
900 ERR_MEMORY_ALLOC 520
901 ERR_SERVER_BUSY 600
902 ERR_SERVER_UNAVAILABLE 601
903 ERR_PEER_NS_DOWN 602
904 ERR_DB_CONNECT 603
905 ERR_SERVER_GOING_DOWN 604
906 ERR_CREATE_CONNECTION 707
907 ERR_BLOCKING_WRITE 711
908 ERR_SESSION_OVERLOAD 712
909 ERR_USER_TOO_ACTIVE 713
910 ERR_TOO_MANY_SESSIONS 714
911 ERR_NOT_EXPECTED 715
912 ERR_BAD_FRIEND_FILE 717
913 ERR_AUTHENTICATION_FAILED 911
914 ERR_NOT_ALLOWED_WHEN_OFFLINE 913
915 ERR_NOT_ACCEPTING_NEW_USERS 920
916
917
918
919 8. Session based Instant Messaging Protocol Details
920
921 MSN Messenger Service utilizes a lightweight, session-based
922 messaging scheme. In order for two clients to exchange instant
923 messages, they must first establish a common session via a
924 Switchboard Server. They can invite additional clients to join the
925 established session.
926
927 8.1 Referral to Switchboard
928
929 This process begins with a "calling" client requesting a referral
930 from its Notification Server to a Switchboard Server:
931
932 C: XFR TrID SB
933 S: XFR TrID SB Address SP AuthChallengeInfo
934
935 - SB is the type of referral being requested or granted.
936 - Address is the DNS name or IP address of a Switchboard Server that
937 has been assigned, and that the client should connect to.
938 - SP is the Security Package being used. In this version of the
939 protocol it is "CKI" only.
940 - AuthChallengeInfo is a cookie that the client needs to present to
941 the Switchboard server for authentication.
942
943
944 Movva and Lai Category - Informational 16
945
946 MSN Messenger Service 1.0 Protocol Aug - 99
947
948
949 8.2 Switchboard Connections and Authentication
950
951 After the XFR reply is received, the client makes a TCP/IP
952 connection to the Switchboard server using port 1863. Note that a
953 lack of version negotiation in the switchboard connection is a
954 limitation of the current implementation.
955
956 The client first needs to authenticates with the Switchboard Server:
957
958 C: USR TrID UserHandle AuthResponseInfo
959 S: USR TrID OK UserHandle FriendlyName
960
961 - AuthResponseInfo is the cookie for CKI security package returned
962 by the Notification Server in the XFR.
963 - UserHandle and FriendlyName are the Switchboard's echoes of the
964 user handle and friendly name of the user.
965
966 8.3 Inviting Users to a Switchboard Session
967
968 Any user in a Switchboard session can invite other users to join the
969 session. The CAL command is sent to the Switchboard server for this
970 purpose:
971
972 C: CAL TrID UserHandle
973 S: CAL TrID Status SessionID
974
975 The Messenger servers verify that the calling user has permissions
976 to contact the called user, with consideration given to the called
977 user's privacy settings and its online state. If instant messaging
978 with this user is not allowed, the server responds to the calling
979 user with an error. If it is allowed, the Switchboard server causes
980 a RNG command to be sent to the called client (see below), and
981 returns a CAL echo to the calling client. The CAL echo has these
982 parameters:
983
984 - Status is a predefined status code - in this implementation it
985 must be "RINGING".
986 - SessionID is the ASCII representation of a decimal number that
987 uniquely identifies this session on the Switchboard Server.
988
989 8.4 Getting Invited to a Switchboard Session
990
991 The other side of the session establishment is the behavior of the
992 called client. The called client receives a RNG from its
993 Notification Server and is expected to connect to the Switchboard
994 Server and respond with an ANS.
995
996 The client receives a RNG from the Notification Server as follows:
997
998 S: RNG SessionID SwitchboardServerAddress SP AuthChallengeInfo
999 CallingUserHandle CallingUserFriendlyName
1000
1001 - SessionID is a numeric ASCII session ID.
1002
1003 Movva and Lai Category - Informational 17
1004
1005 MSN Messenger Service 1.0 Protocol Aug - 99
1006
1007
1008 - SwitchboardServerAddress is a DNS name or IP Address
1009 - SP is the security package in use. In this implementation only
1010 "CKI" is supported.
1011 - AuthChallengeInfo is the cookie to be passed back to the
1012 switchboard to gain entrance to the session.
1013 - CallingUserHandle is the user handle of the caller.
1014 - CallingUserFriendlyName is the custom user name of the caller.
1015
1016 To join the session, the called client connects to the Switchboard
1017 Server and carries out the following exchange to join the session:
1018
1019 C: ANS TrID LocalUserHandle AuthResponseInfo SessionID
1020 S: IRO TrID Participant# TotalParticipants UserHandle
1021 FriendlyName
1022 S: ANS TrID OK
1023
1024 The IRO commands relay to the newly joined client roster information
1025 about the current session. Each IRO command message from the
1026 Switchboard contains one participant in the session.
1027 - Participant# contains the index of the participant described in
1028 this IRO command (e.g. 1 of N, 2 of N).
1029 - TotalParticipants contains the total number of participants
1030 currently in the session.
1031
1032 The entire session roster will be sent to the new client joining the
1033 session before any JOI or BYE commands described below.
1034
1035 If no one is in the session when the user joins (an unexpected error
1036 condition), the server skips directly to "ANS TrID OK" command. All
1037 the responses from the server related to the issued ANS command will
1038 contain the same TrID as the original client ANS request.
1039
1040 8.5 Session Participant Changes
1041
1042 When a new user joins a Switchboard session, the server sends the
1043 following command to all participating clients, including the client
1044 joining the session:
1045
1046 S: JOI CalleeUserHandle CalleeUserFriendlyName
1047
1048 - CalleeUserHandle is the user handle of the new participant.
1049 - CalleeUserFriendlyName is the Custom User Name of the new
1050 participant.
1051
1052 If a client's connection with the Switchboard Server is dropped for
1053 any reason, the server sends the following command to the remaining
1054 clients in the session:
1055
1056 S: BYE CalleeUserHandle
1057
1058 - CalleeUserHandle is the user handle of the participant that left
1059 the session.
1060
1061
1062 Movva and Lai Category - Informational 18
1063
1064 MSN Messenger Service 1.0 Protocol Aug - 99
1065
1066
1067 Privacy Note:
1068 If the client moved a contact to the BL while Switchboard sessions
1069 are active, it is the client's responsibility to leave any session
1070 that should now be blocked. The servers only enforce privacy
1071 permissions when inviting users to a session. Further, the servers
1072 only enforce privacy permission with respect to the calling user,
1073 and not the other participants in a Switchboard session. Therefore,
1074 in a multipoint session, it is possible for a user to participate in
1075 a session with someone whom he has blocked, if a third party is
1076 performing the invitation.
1077
1078 8.6 Leaving a Switchboard Session
1079
1080 When a client wishes to disconnect from the session, it sends the
1081 following command and waits for the Switchboard to close the
1082 connection:
1083
1084 C: OUT
1085
1086 8.7 Instant Messages
1087
1088 Sending an Instant Message
1089
1090 Once a client-to-client session has been established via the
1091 Switchboard Server, sending an Instant Message to the participants
1092 of the session is done as follows:
1093
1094 C: MSG TrID [U | N | A] Length\r\nMessage
1095 S: NAK TrID
1096 S: ACK TrID
1097
1098 U, N, and A correspond to the three delivery acknowledgement modes:
1099 Unacknowledged, Negative-Acknowledgement-Only, and Acknowledgement.
1100 Depending on the value of this parameter, either nothing, NAK, or
1101 ACK will be sent back by the Switchboard Server to the client.
1102
1103 For Unacknowledged mode, the Switchboard Server does not respond to
1104 the sending client with the success or failure of message delivery.
1105
1106 For Negative-Acknowledgement-Only mode, the Switchboard Server
1107 responds to the send client only if the message could not be
1108 delivered to the recipient client.
1109
1110 Acknowledgement mode is not currently implemented.
1111
1112 Length is the length of the Message parameter in bytes, whereas
1113 Message is the actual message as described below.
1114
1115 8.8 Receiving an Instant Message
1116
1117 A client can receive a system-generated message from the
1118 Notification Server, or it can receive an instant message from
1119
1120
1121 Movva and Lai Category - Informational 19
1122
1123 MSN Messenger Service 1.0 Protocol Aug - 99
1124
1125
1126 another client via a Switchboard Server. The message is received in
1127 the following format:
1128
1129 S: MSG UserHandle FriendlyName Length\r\nMessage
1130
1131 The UserHandle and FriendlyName are those of the sending user.
1132 Length is the length of the message in bytes.
1133
1134 Message is a MIME encoded stream, using a standard MIME header as
1135 defined by RFC-1521 and RFC-822.
1136
1137 Message is constructed as:
1138
1139 MIME-Header\r\nMIME-Header\r\n\r\nMessageData
1140
1141 MIME-Header is constructed as:
1142
1143 string": "string
1144 (E.g. "Content-Type: text/plain")
1145
1146 The Content-Type MIME headers that the current client will use and
1147 recognize are:
1148
1149 "text/plain;charset=UTF-8"
1150 "text/plain"
1151
1152 If "charset=UTF-8" appears at the end of the Content-Type, the
1153 Message Data is UTF-8 encoded.
1154
1155 Note: The Switchboard Server does not interpret the contents of the
1156 Message.
1157
1158
1159
1160 9. Author's Addresses
1161
1162 Ramu Movva
1163 Microsoft Corporation
1164 One Microsoft Way
1165 Redmond WA 98052
1166 ramum@microsoft.com
1167
1168 William Lai
1169 Microsoft Corporation
1170 One Microsoft Way
1171 Redmond, WA 98052
1172 wlai@microsoft.com
1173
1174
1175
1176 Movva and Lai Category - Informational 20