My favorites | Sign in
Logo
                
Search
for
KB_MSNC12_BinaryHeader  
(KnowledgeBase) Binary header research on MSNC12 (The new P2P protocol used in WLM 2009 and MSNP18).

by Pang Wu and Ethem Evlice

Introduction

Here're some result of the uncompleted research on binary header that WLM 2009 used for its p2p protocol.

Details (Only for switchboard data transfer)

Every field is big-endian.

Transfer layer package

Length Description
1 Header length
1 Operation code
2 Payload data length
4 Sequence Number(Last sequence number add payload data length)
Header length - 8 TLVs
Payload data length Payload data (Data package)
4 Footer

The Data package consists following fields:

Length Description
1 Header length
1 TF combination (Consists of 7-bit Type and 1-bit Flag)
2 Package number
4 Session ID
Header length - 8 TLVs
Payload data length - Header length Payload

Consider the following examples:

Example 1:

Data from a displayimage transfer process (An acknowledgement message, the MSG text header is omitted).

Binary ASCII
08 00 00 0c df 32 36 79 08 01 00 00 6c 99 fb c2 00 00 00 00 00 00 00 00 fb ......26 y....l..

For the Transfer Layer Package:

Then the following data is playload (data package): 08 01 00 00 6c 99 fb c2 00 00 00 00

Example 2:

Here's a MSNSLP INVITE message that initialize the switchboard transfer negotiation (Including the MSG header):

0000   4d 53 47 20 35 39 31 20 44 20 39 36 34 0d 0a 4d  MSG 591 D 964..M
0010   49 4d 45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30  IME-Version: 1.0
0020   0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20  ..Content-Type: 
0030   61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73  application/x-ms
0040   6e 6d 73 67 72 70 32 70 0d 0a 50 32 50 2d 44 65  nmsgrp2p..P2P-De
0050   73 74 3a 20 77 70 30 31 40 6c 69 76 65 2e 63 6e  st: wp01@live.cn
0060   3b 7b 64 39 66 64 31 36 31 62 2d 64 34 64 38 2d  ;{d9fd161b-d4d8-
0070   34 63 61 37 2d 38 61 36 38 2d 63 37 30 66 65 62  4ca7-8a68-c70feb
0080   33 39 61 33 33 30 7d 0d 0a 50 32 50 2d 53 72 63  39a330}..P2P-Src
0090   3a 20 66 72 65 65 7a 69 6e 67 73 6f 66 74 40 68  : freezingsoft@h
00a0   6f 74 6d 61 69 6c 2e 63 6f 6d 3b 7b 37 65 64 66  otmail.com;{7edf
00b0   39 64 32 34 2d 37 65 39 38 2d 34 37 32 30 2d 39  9d24-7e98-4720-9
00c0   66 30 35 2d 37 34 63 33 61 62 61 61 30 37 37 30  f05-74c3abaa0770
00d0   7d 0d 0a 0d 0a 18 03 02 e2 6a 23 43 ff 01 0c 00  }........j#C....
00e0   02 00 00 00 0e 00 00 0f 01 00 00 00 00 08 01 00  ................
00f0   00 00 00 00 00 49 4e 56 49 54 45 20 4d 53 4e 4d  .....INVITE MSNM
0100   53 47 52 3a 77 70 30 31 40 6c 69 76 65 2e 63 6e  SGR:wp01@live.cn
0110   3b 7b 64 39 66 64 31 36 31 62 2d 64 34 64 38 2d  ;{d9fd161b-d4d8-
0120   34 63 61 37 2d 38 61 36 38 2d 63 37 30 66 65 62  4ca7-8a68-c70feb
0130   33 39 61 33 33 30 7d 20 4d 53 4e 53 4c 50 2f 31  39a330} MSNSLP/1
0140   2e 30 0d 0a 54 6f 3a 20 3c 6d 73 6e 6d 73 67 72  .0..To: <msnmsgr
0150   3a 77 70 30 31 40 6c 69 76 65 2e 63 6e 3b 7b 64  :wp01@live.cn;{d
0160   39 66 64 31 36 31 62 2d 64 34 64 38 2d 34 63 61  9fd161b-d4d8-4ca
0170   37 2d 38 61 36 38 2d 63 37 30 66 65 62 33 39 61  7-8a68-c70feb39a
0180   33 33 30 7d 3e 0d 0a 46 72 6f 6d 3a 20 3c 6d 73  330}>..From: <ms
0190   6e 6d 73 67 72 3a 66 72 65 65 7a 69 6e 67 73 6f  nmsgr:freezingso
01a0   66 74 40 68 6f 74 6d 61 69 6c 2e 63 6f 6d 3b 7b  ft@hotmail.com;{
01b0   37 65 64 66 39 64 32 34 2d 37 65 39 38 2d 34 37  7edf9d24-7e98-47
01c0   32 30 2d 39 66 30 35 2d 37 34 63 33 61 62 61 61  20-9f05-74c3abaa
01d0   30 37 37 30 7d 3e 0d 0a 56 69 61 3a 20 4d 53 4e  0770}>..Via: MSN
01e0   53 4c 50 2f 31 2e 30 2f 54 4c 50 20 3b 62 72 61  SLP/1.0/TLP ;bra
01f0   6e 63 68 3d 7b 37 42 41 44 41 35 35 39 2d 39 31  nch={7BADA559-91
0200   45 32 2d 34 41 46 45 2d 41 35 32 39 2d 39 43 46  E2-4AFE-A529-9CF
0210   34 41 39 36 34 37 46 44 35 7d 0d 0a 43 53 65 71  4A9647FD5}..CSeq
0220   3a 20 30 20 0d 0a 43 61 6c 6c 2d 49 44 3a 20 7b  : 0 ..Call-ID: {
0230   42 30 42 34 31 41 30 41 2d 35 32 35 32 2d 34 42  B0B41A0A-5252-4B
0240   43 44 2d 42 46 38 31 2d 30 39 36 37 45 39 44 31  CD-BF81-0967E9D1
0250   38 36 34 34 7d 0d 0a 4d 61 78 2d 46 6f 72 77 61  8644}..Max-Forwa
0260   72 64 73 3a 20 30 0d 0a 43 6f 6e 74 65 6e 74 2d  rds: 0..Content-
0270   54 79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f  Type: applicatio
0280   6e 2f 78 2d 6d 73 6e 6d 73 67 72 2d 73 65 73 73  n/x-msnmsgr-sess
0290   69 6f 6e 72 65 71 62 6f 64 79 0d 0a 43 6f 6e 74  ionreqbody..Cont
02a0   65 6e 74 2d 4c 65 6e 67 74 68 3a 20 32 38 34 0d  ent-Length: 284.
02b0   0a 0d 0a 45 55 46 2d 47 55 49 44 3a 20 7b 41 34  ...EUF-GUID: {A4
02c0   32 36 38 45 45 43 2d 46 45 43 35 2d 34 39 45 35  268EEC-FEC5-49E5
02d0   2d 39 35 43 33 2d 46 31 32 36 36 39 36 42 44 42  -95C3-F126696BDB
02e0   46 36 7d 0d 0a 53 65 73 73 69 6f 6e 49 44 3a 20  F6}..SessionID: 
02f0   32 36 32 35 33 32 39 32 34 37 0d 0a 41 70 70 49  2625329247..AppI
0300   44 3a 20 31 32 0d 0a 52 65 71 75 65 73 74 46 6c  D: 12..RequestFl
0310   61 67 73 3a 20 31 38 0d 0a 43 6f 6e 74 65 78 74  ags: 18..Context
0320   3a 20 50 47 31 7a 62 6d 39 69 61 69 42 44 63 6d  : PG1zbm9iaiBDcm
0330   56 68 64 47 39 79 50 53 4a 33 63 44 41 78 51 47  VhdG9yPSJ3cDAxQG
0340   78 70 64 6d 55 75 59 32 34 69 49 46 52 35 63 47  xpdmUuY24iIFR5cG
0350   55 39 49 6a 4d 69 49 46 4e 49 51 54 46 45 50 53  U9IjMiIFNIQTFEPS
0360   4a 5a 54 69 74 72 4e 48 70 4c 4b 30 6c 6d 52 30  JZTitrNHpLK0lmR0
0370   64 30 52 31 68 79 54 48 49 78 64 56 4e 61 64 56  d0R1hyTHIxdVNadV
0380   6c 5a 52 47 73 39 49 69 42 54 61 58 70 6c 50 53  lZRGs9IiBTaXplPS
0390   49 78 4e 7a 41 35 4e 53 49 67 54 47 39 6a 59 58  IxNzA5NSIgTG9jYX
03a0   52 70 62 32 34 39 49 6a 41 69 49 45 5a 79 61 57  Rpb249IjAiIEZyaW
03b0   56 75 5a 47 78 35 50 53 4a 4e 55 55 46 42 51 55  VuZGx5PSJNUUFBQU
03c0   45 39 50 53 49 76 50 67 41 3d 0d 0a 0d 0a 00 00  E9PSIvPgA=......
03d0   00 00 00                                         ...

For the Transfer Layer Package:

Then the following data is playload (data package):
About operation code:
  • 0x00(0): Default, sometimes the operation code of a SLP INVITE message that requests a file transfer also use this value.
  • 0x02(2): Begins the data transfer.
  • 0x03(3): The SLP INVITE message to request a transfer (file, displayimage, emoticon, etc.).
About TF combination:
  • 0x01(1, T=0 F=1): If the SessionID is 0x0000, the payload contains SIP text message. If the SessionID is none zero, the payload is data preperation message.
  • 0x04(4, T=2 F=0): The payload contains binary data for MSNObjet.
  • 0x05(5, T=2 F=1): The payload contains the first package of binary data for MSNObject.
  • 0x06(6, T=3 F=0): The payload contains binary data for file transfer.
  • 0x07(7, T=3 F=1): The payload contains the first package of binary data for file transfer.
About TLVs:
  • T=0x1(1) L=0x8(8) : Indicates that value is the size of untransfer data.
  • T=0x2(2) L=0x4(4) : ACK, base sequence number
  • T=0x1(1) L=0xc(12): Encoded IP address of sender/receiver (If you know the algorithm, please contact me: freezingsoft@hotmail.com)
A sample tranfer session (Custom emoticon):
 Receiver                                                        Sender
    |---- Send "INVITE MSNMSGR" message with operation code 0x3 --->|
    |<----------- Acknowledge to the invitation message ------------|
    |------------- Acknowledge to last message  ------------------->|
    |<-------------- Send "MSNSLP/1.0 200 OK" message --------------|
    |<--------------- Initialize session message -------------------| [1]
    |--------- Acknowledge the Initialize session message  -------->|
    |<------------------- Data preparation message  ----------------| [2]
    |<-------------- Send the first data package -------------------|
    |<--------------- Send the Nst data package  -------------------|
                              ... ...
    |<----------------- Send the last data package -----------------|
    |<----- Send "BYE MSNMSGR:[receiver_mail:guid]" message --------|
    |-- Acknowledge to "BYE MSNMSGR:[receiver_mail:guid]" messag -->|
    |------ Send "BYE MSNMSGR:[sender_mail:guid]" message --------->|
    |--- Acknowledge to "BYE MSNMSGR:[sender_mail:guid]" messag --->|
  1. The init session message is always like this: 0x08, 0x02, 0x00, 0x00, 0xXX, 0xXX, 0xXX, 0x00, 0x00, 0x00, 0x00).
  2. Only MSNObject transfer session send this message. File transfer does not need data preparation message.

Key issues and FAQs (For switchboard data transfer)

Q:

Why can't my program receive an ""INVITE MSNMSGR" SLP message from the official client after the remote user established a switchboard conversation?

A:

You need to register the client capacities and endpoint info of your program to switchboard by sending 3 UUX commands (Send it after you send the ADL command(s)).

The pattern of these UUX commands is like this:

UUX [TransferID] [Payload length]\r\n
<EndpointData><Capabilities>[Client capacities]:[New p2pv2 capacities]</Capabilities></EndpointData>

UUX [TransferID] [Payload length]\r\n
<Data><PSM>[Personal message]</PSM><CurrentMedia></CurrentMedia><MachineGuid>[XML encoded machine guid]</MachineGuid><SignatureSound></SignatureSound></Data>

UUX [TransferID] [Payload length]\r\n
<PrivateEndpointData><EpName>[Your computer name]</EpName><Idle>false</Idle><ClientType>1</ClientType><State>[Your online state]</State></PrivateEndpointData>

An actual data example:

UUX 12 71\r\n
<EndpointData><Capabilities>2751496224:48</Capabilities></EndpointData>

UUX 13 124\r\n
<PrivateEndpointData><EpName>WP</EpName><Idle>false</Idle><ClientType>1</ClientType><State>NLN</State></PrivateEndpointData>

UUX 14 166\r\n
<Data><PSM>Pang~</PSM><CurrentMedia></CurrentMedia><MachineGuid>&#x7B;338c6533-882f-4980-aa34-62f50344526c&#x7D;</MachineGuid><SignatureSound></SignatureSound></Data>

Q:

When and how to send an acknowledgement message?

A:

All message with operation code > 0 need to be acknowledged.

For example, you need to acknowledge a MSNSLP invite message: (This example package contains one TLV in its header: 01 0c 00 02 00 00 00 0e 00 00 0f 01 00 00 T=0x01, L=0x0c, the value is an encoded ip address.)

0000   4d 53 47 20 66 72 65 65 7a 69 6e 67 73 6f 66 74  MSG freezingsoft
0010   40 68 6f 74 6d 61 69 6c 2e 63 6f 6d 20 50 61 6e  @hotmail.com Pan
0020   67 28 62 72 62 29 20 31 30 35 31 0d 0a 4d 49 4d  g(brb) 1051..MIM
0030   45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a  E-Version: 1.0..
0040   43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
0050   70 6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73 6e 6d  plication/x-msnm
0060   73 67 72 70 32 70 0d 0a 50 32 50 2d 44 65 73 74  sgrp2p..P2P-Dest
0070   3a 20 74 65 73 74 6d 73 6e 70 73 68 61 72 70 40  : testmsnpsharp@
0080   6c 69 76 65 2e 63 6e 3b 7b 37 65 64 66 39 64 32  live.cn;{7edf9d2
0090   34 2d 37 65 39 38 2d 34 37 32 30 2d 39 66 30 35  4-7e98-4720-9f05
00a0   2d 37 34 63 33 61 62 61 61 30 37 37 30 7d 0d 0a  -74c3abaa0770}..
00b0   50 32 50 2d 53 72 63 3a 20 66 72 65 65 7a 69 6e  P2P-Src: freezin
00c0   67 73 6f 66 74 40 68 6f 74 6d 61 69 6c 2e 63 6f  gsoft@hotmail.co
00d0   6d 3b 7b 64 39 66 64 31 36 31 62 2d 64 34 64 38  m;{d9fd161b-d4d8
00e0   2d 34 63 61 37 2d 38 61 36 38 2d 63 37 30 66 65  -4ca7-8a68-c70fe
00f0   62 33 39 61 33 33 30 7d 0d 0a 0d 0a 18 03 03 30  b39a330}.......0
0100   d3 b7 91 9f 01 0c 00 02 00 00 00 0e 00 00 0f 01  ................
0110   00 00 00 00 08 01 00 00 00 00 00 00 49 4e 56 49  ............INVI
0120   54 45 20 4d 53 4e 4d 53 47 52 3a 74 65 73 74 6d  TE MSNMSGR:testm
0130   73 6e 70 73 68 61 72 70 40 6c 69 76 65 2e 63 6e  snpsharp@live.cn
0140   3b 7b 37 65 64 66 39 64 32 34 2d 37 65 39 38 2d  ;{7edf9d24-7e98-
0150   34 37 32 30 2d 39 66 30 35 2d 37 34 63 33 61 62  4720-9f05-74c3ab
0160   61 61 30 37 37 30 7d 20 4d 53 4e 53 4c 50 2f 31  aa0770} MSNSLP/1

....

The outgoing acknowledge message should be like this: (The package also has a TLV that T=0x01, L=0x0c and the value of V field is not important, you can just copy the value from the INVITE message.)

0000   4d 53 47 20 34 20 44 20 32 33 39 0d 0a 4d 49 4d  MSG 4 D 239..MIM
0010   45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a  E-Version: 1.0..
0020   43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
0030   70 6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73 6e 6d  plication/x-msnm
0040   73 67 72 70 32 70 0d 0a 50 32 50 2d 44 65 73 74  sgrp2p..P2P-Dest
0050   3a 20 66 72 65 65 7a 69 6e 67 73 6f 66 74 40 68  : freezingsoft@h
0060   6f 74 6d 61 69 6c 2e 63 6f 6d 3b 7b 64 39 66 64  otmail.com;{d9fd
0070   31 36 31 62 2d 64 34 64 38 2d 34 63 61 37 2d 38  161b-d4d8-4ca7-8
0080   61 36 38 2d 63 37 30 66 65 62 33 39 61 33 33 30  a68-c70feb39a330
0090   7d 0d 0a 50 32 50 2d 53 72 63 3a 20 74 65 73 74  }..P2P-Src: test
00a0   6d 73 6e 70 73 68 61 72 70 40 6c 69 76 65 2e 63  msnpsharp@live.c
00b0   6e 3b 7b 37 65 64 66 39 64 32 34 2d 37 65 39 38  n;{7edf9d24-7e98
00c0   2d 34 37 32 30 2d 39 66 30 35 2d 37 34 63 33 61  -4720-9f05-74c3a
00d0   62 61 61 30 37 37 30 7d 0d 0a 0d 0a 1c 03 00 00  baa0770}........
00e0   26 3e fe 3e 02 04 d3 b7 94 cf 01 0c 00 02 00 00  &>.>............
00f0   00 0e 61 6e 0f 01 00 00 00 00 00 00              ..an........

For example, initial session message:

0000   4d 53 47 20 77 70 30 31 40 6c 69 76 65 2e 63 6e  MSG wp01@live.cn
0010   20 e6 bb 82 20 32 31 30 0d 0a 4d 49 4d 45 2d 56   ... 210..MIME-V
0020   65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a 43 6f 6e  ersion: 1.0..Con
0030   74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 6c 69  tent-Type: appli
0040   63 61 74 69 6f 6e 2f 78 2d 6d 73 6e 6d 73 67 72  cation/x-msnmsgr
0050   70 32 70 0d 0a 50 32 50 2d 44 65 73 74 3a 20 66  p2p..P2P-Dest: f
0060   72 65 65 7a 69 6e 67 73 6f 66 74 40 68 6f 74 6d  reezingsoft@hotm
0070   61 69 6c 2e 63 6f 6d 3b 7b 37 65 64 66 39 64 32  ail.com;{7edf9d2
0080   34 2d 37 65 39 38 2d 34 37 32 30 2d 39 66 30 35  4-7e98-4720-9f05
0090   2d 37 34 63 33 61 62 61 61 30 37 37 30 7d 0d 0a  -74c3abaa0770}..
00a0   50 32 50 2d 53 72 63 3a 20 77 70 30 31 40 6c 69  P2P-Src: wp01@li
00b0   76 65 2e 63 6e 3b 7b 64 39 66 64 31 36 31 62 2d  ve.cn;{d9fd161b-
00c0   64 34 64 38 2d 34 63 61 37 2d 38 61 36 38 2d 63  d4d8-4ca7-8a68-c
00d0   37 30 66 65 62 33 39 61 33 33 30 7d 0d 0a 0d 0a  70feb39a330}....
00e0   08 02 00 00 5b c8 00 f7 00 00 00 00              ....[.......

Outgoing message:

0000   4d 53 47 20 35 39 33 20 44 20 32 31 38 0d 0a 4d  MSG 593 D 218..M
0010   49 4d 45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30  IME-Version: 1.0
0020   0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20  ..Content-Type: 
0030   61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73  application/x-ms
0040   6e 6d 73 67 72 70 32 70 0d 0a 50 32 50 2d 44 65  nmsgrp2p..P2P-De
0050   73 74 3a 20 77 70 30 31 40 6c 69 76 65 2e 63 6e  st: wp01@live.cn
0060   3b 7b 64 39 66 64 31 36 31 62 2d 64 34 64 38 2d  ;{d9fd161b-d4d8-
0070   34 63 61 37 2d 38 61 36 38 2d 63 37 30 66 65 62  4ca7-8a68-c70feb
0080   33 39 61 33 33 30 7d 0d 0a 50 32 50 2d 53 72 63  39a330}..P2P-Src
0090   3a 20 66 72 65 65 7a 69 6e 67 73 6f 66 74 40 68  : freezingsoft@h
00a0   6f 74 6d 61 69 6c 2e 63 6f 6d 3b 7b 37 65 64 66  otmail.com;{7edf
00b0   39 64 32 34 2d 37 65 39 38 2d 34 37 32 30 2d 39  9d24-7e98-4720-9
00c0   66 30 35 2d 37 34 63 33 61 62 61 61 30 37 37 30  f05-74c3abaa0770
00d0   7d 0d 0a 0d 0a 10 00 00 00 6a 23 46 e1 02 04 5b  }........j#F...[
00e0   c8 00 f7 00 00 00 00 00 00                       .........

For example, to acknowledge the following message: (This example package is an acknowledge message. It contains one TLV in its header: 01 0c 00 02 00 00 00 0e 61 6e 0f 01 00 00 T=0x01, L=0x0c, the value is an encoded ip address.)

0000   4d 53 47 20 34 20 44 20 32 33 39 0d 0a 4d 49 4d  MSG 4 D 239..MIM
0010   45 2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a  E-Version: 1.0..
0020   43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70  Content-Type: ap
0030   70 6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73 6e 6d  plication/x-msnm
0040   73 67 72 70 32 70 0d 0a 50 32 50 2d 44 65 73 74  sgrp2p..P2P-Dest
0050   3a 20 66 72 65 65 7a 69 6e 67 73 6f 66 74 40 68  : freezingsoft@h
0060   6f 74 6d 61 69 6c 2e 63 6f 6d 3b 7b 64 39 66 64  otmail.com;{d9fd
0070   31 36 31 62 2d 64 34 64 38 2d 34 63 61 37 2d 38  161b-d4d8-4ca7-8
0080   61 36 38 2d 63 37 30 66 65 62 33 39 61 33 33 30  a68-c70feb39a330
0090   7d 0d 0a 50 32 50 2d 53 72 63 3a 20 74 65 73 74  }..P2P-Src: test
00a0   6d 73 6e 70 73 68 61 72 70 40 6c 69 76 65 2e 63  msnpsharp@live.c
00b0   6e 3b 7b 37 65 64 66 39 64 32 34 2d 37 65 39 38  n;{7edf9d24-7e98
00c0   2d 34 37 32 30 2d 39 66 30 35 2d 37 34 63 33 61  -4720-9f05-74c3a
00d0   62 61 61 30 37 37 30 7d 0d 0a 0d 0a 1c 03 00 00  baa0770}........
00e0   26 3e fe 3e 02 04 d3 b7 94 cf 01 0c 00 02 00 00  &>.>............
00f0   00 0e 61 6e 0f 01 00 00 00 00 00 00              ..an........

The acknowledge should be like this: (The TLV that T=0x01, L=0x0c was dropped.)

0000   4d 53 47 20 66 72 65 65 7a 69 6e 67 73 6f 66 74  MSG freezingsoft
0010   40 68 6f 74 6d 61 69 6c 2e 63 6f 6d 20 50 61 6e  @hotmail.com Pan
0020   67 28 62 72 62 29 20 32 32 37 0d 0a 4d 49 4d 45  g(brb) 227..MIME
0030   2d 56 65 72 73 69 6f 6e 3a 20 31 2e 30 0d 0a 43  -Version: 1.0..C
0040   6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70  ontent-Type: app
0050   6c 69 63 61 74 69 6f 6e 2f 78 2d 6d 73 6e 6d 73  lication/x-msnms
0060   67 72 70 32 70 0d 0a 50 32 50 2d 44 65 73 74 3a  grp2p..P2P-Dest:
0070   20 74 65 73 74 6d 73 6e 70 73 68 61 72 70 40 6c   testmsnpsharp@l
0080   69 76 65 2e 63 6e 3b 7b 37 65 64 66 39 64 32 34  ive.cn;{7edf9d24
0090   2d 37 65 39 38 2d 34 37 32 30 2d 39 66 30 35 2d  -7e98-4720-9f05-
00a0   37 34 63 33 61 62 61 61 30 37 37 30 7d 0d 0a 50  74c3abaa0770}..P
00b0   32 50 2d 53 72 63 3a 20 66 72 65 65 7a 69 6e 67  2P-Src: freezing
00c0   73 6f 66 74 40 68 6f 74 6d 61 69 6c 2e 63 6f 6d  soft@hotmail.com
00d0   3b 7b 64 39 66 64 31 36 31 62 2d 64 34 64 38 2d  ;{d9fd161b-d4d8-
00e0   34 63 61 37 2d 38 61 36 38 2d 63 37 30 66 65 62  4ca7-8a68-c70feb
00f0   33 39 61 33 33 30 7d 0d 0a 0d 0a 10 00 00 00 d3  39a330}.........
0100   b7 94 cf 02 04 26 3e fe 3e 00 00 00 00 00 00     .....&>.>......

Q:

How to compute the identifier and ack identifier for a Transfer Layer Package?

A:

First of all, you need to set a base identifier (just a random number) for the first Transfer Layer Package you want to send, say "out package 1". Then the "out package 2"'s identifier should be the identifier of "out package 1" plus payload data length of "out package 1".

The calculation of ack identifier is similar. For example, A is the message you want to acknowledge to, B is the outgoing acknowledge message. So the ack identifier should be (the identifier of package A) plus (payload data length of package A). Then create a TLV item which T=0x02, L=0x04, V=(ack identifier). Add this TLV item to package B.

Q:

In old p2pv1, any message exceed a size of 1202 should be splitted. How to split a large message in p2pv2?

A:

In p2pv2, the max size for the payload of a p2p Data Package is 1222. So the maximum number in the (payload data length) field for a Transfer Layer Package is 1222+20=1242(20 is the header length for a Data Package).

To split a message, you need to set a none-zero Package Number for the data message packets. All the data messages splitted from that message should keep this Package Number. The TFCombination field for the first splitted message should be the same as original message, the following messages' TFCombination should be the value of the first minus one.

For example, a message with TFCombination of 0x01 (SLP message) should be splitted into 3 packets. So, firstly, give a random non-zero Package Number to all 3 packages. Then the first message's TFCombination in this sequence is 0x01. The TFCombination for the second and third package is 0x00.

Q:

Why don't you guys update all these to MSNPiki?

A:

I have to admit that this is a good question. There're several reasons:

Ah, by the way, we also need a new logo, if you think you can help, please contact me.

At last, feel free to contact me if you:

My email address is: freezingsoft@hotmail.com. Good luck.

By Pang Wu

UDP data transfer

1. Frame Layer

Length Description
4 Local Identifier (get from last received package's remoteID or localID++)
4 Remote Identifier (get from last received package's localID or remoteID++)
4 SessionID?
4 Unknown
4 Unknown

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LID   | RID   | SID   |Unknown|Unknown|       Data ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Data is a Transport Layer packet. Other package is just the same as above.

More info from Jabber community (TCP direct connection)

MSNP18 P2P protocol description.

New P2P protocol is a stack of 3 layers: Frame Layer, Transport Layer and Data Layer.

I. ENCODING RULES.

1. Frame Layer.

Frame Layer is responsible for data framing. In the case you establish direct TCP p2p connection the Frame looks like this:

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Size  |           Data                                  ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The Size is a little-endian unsigned integer. The Data is a Transport Layer packet, Foo packet or Nonce packet. This depends on a state of a p2p connection.

In the case you exchange p2p messages over a switchboard, you MUST incapsulate the Data into standard switcboard message and put 4 zeros to the end of that message. Example:

MIME-Version: 1.0\r\n Content-Type: application/x-msnmsgrp2p\r\n P2P-Dest: dest@hotmail.com;{41bd14f3-8904-4100-71be-89943607df9d}\r\n P2P-Src: src@live.com;{6028abad-5919-8be8-fd1c-5e1e84a86742}\r\n\r\n ...the Data goes here...\0\0\0\0

2. Foo packet.

Foo packet is a 4-byte data packet "foo\0": 0x6f, 0x6f, 0x0. This packet is only used in direct TCP p2p connections.

3. Nonce packet.

Nonce packet is just an opaque 16-byte data packet. It is used to authorize a p2p connection. This packet is only used in direct TCP p2p connections. There is a one-to-one mapping between the Hashed-Nonce (which is the part of "application/x-msnmsgr-transreqbody" of an SLP message) and this Nonce. An algorithm of this mapping is unknown. An example of valid mappings:

{2B95F56D-9CA0-9A64-82CE-ADC1F3C55845} <->
[0x37,0x29,0x2d,0x12,0x86,0x5c,0x7b,0x4c,
 0x81,0xf5,0xe,0x5,0x1,0x78,0x80,0xc2]


{F960C412-A40F-E37D-DD1D-AE264E958F28} <->
[0x3d,0xa6,0x17,0xa5,0x2e,0xa2,0xdc,0x40,
 0x85,0xa5,0x54,0xf9,0xe1,0x96,0xf4,0x6e]

4. Transport Layer.

The Transport Layer packets are used to track a data sent over a p2p connection. The packet consists of the Header and the Payload. The Header consists of L, O, Len, Seq and TLVs fields.

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|L|O|Len|  Seq  |                TLVs                      ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Payload                          ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

L - a length of the header including this field. O - operation code. Len - a length of the Payload. "0" means the Payload is empty. Seq - a sequence number. TLVs - a list of TLV-encoded values (see below). The list may be empty. Payload - a Data Layer packet. The Payload may be empty.

All fields are in big-endian format.

5. Data Layer.

The Data Layer packets are used for data incapsulation. The packet consists of the Header and the Payload. The Header consists of L, O, Seq, SID and TLVs fields.

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|L|O|Seq|  SID  |                TLVs                      ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Payload                          ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

L - a length of the header including this field. O - an operation code. It consists of 7-bit Type and 1-bit flag F:

    0 1 2 3 4 5 6 7 8
    +-+-+-+-+-+-+-+-+
    |    Type     |F|
    +-+-+-+-+-+-+-+-+

Seq - a sequence number. SID - a session id. TLVs - a list of TLV-encoded values (see below). The list may be empty. Payload - an opaque data. The Payload may be empty. A size of the Payload must not exceed 1372 bytes.

All fields are in big-endian format.

6. TLVs

TLV list consists of TLV-encoded pairs (type, value). A whole TLV list is padded with zeros to fit 4-byte boundary.

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|T|L|                       Value                          ....
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            ....                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|T|L|                       Value         ....          | .... 0|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

T - type of the value. L - length of the value. Value - the value itself.

All fields are in big-endian format.

II. BUSSINESS LOGIC.

1. Initialization.

This state is only used in direct TCP p2p connections. Once a TCP connection is established, connecting peer should sent Foo packet and then Nonce packet. Receiving peer should check that Nonce and send its own Nonce packet back to the connecting peer.

Initiator             Responder
    |-------  Foo  ------>|
    |------- Nonce ------>|
    |<------ Nonce -------|

The p2p connection is now definitely established and the peers may exchange data.

2. Sequence numbers in Transport Layer packets.

The first sequence number picks up randomly between 1 and 2^32. The next sequence number should be increased on the size of the Payload of the previous Transport Layer packet. Thus, for example, if that Payload is empty, the sequence number is not increased.

3. TODO.

Join us !

If you are familiar with the MSN p2p protocol (No matter the old or new one) and have interest in our project, please contact me : freezingsoft@hotmail.com, you are the man we are seeking for!

References


Sign in to add a comment
Hosted by Google Code