Choose another language: 

Catchcopy protocol v0002
6 posts
• Page 1 of 1
Catchcopy protocol v0002
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
Protocol
Target:
This protocol define the communication between an explorer (or all other application which do copy) and software of file copy.
Choice of the mode of communication:
The choice have been done, it's use QLocalServer (The application of copy) and QLocalSocket (the file explorer). Under windows then it's done with named pipe and under unix an unix socket.
That's allow isolate the language (server in c++ and client in Qt) and the architecture (server 32Bits to portable version and client in 64Bits like the explorer.exe of Windows 64Bits)
It's allow too only the local connexion and detect the application disconnection or of the client (with crash too example).
About the performance, a Pentium 3 at 500MHz can transfer of this mode 1GB/s, to copy list very ofter < at 32KB (the transfer is done in 30µs -> 0.00003s, that's greatly lower then copy time). Better performance is useless here.
About security, that's do the process is kept into the user space.
For windows: The name of the named pipe is: "advanced-copier-[user]", where [user] is the user name in hexa + little endian. Example, for the user named: "user", the encoded string form WCHAR is "7500730065007200", then it do: advanced-copier-7500730065007200
For unix: The path of the unix socket is: "/tmp/advanced-copier-[uid]", where [uid] is the id of the current user, example: /tmp/advanced-copier-1000
Decomposition and recomposition:
All order/reply need be cute as packet of 32KB max. To check correct size to the receiver and header of int unsigned of 32Bits is included, and it contain size of all the order/reply.
The receiver need remove this header and group all frame in unique frame.
Encoding used:
The used encoding is the l'unicode (utf16), where each char is encoded into 16Bits in big endian. All modern OS use it.
Format of the composed frame:
The order can not be more than 64MB. Format of the order's data (after frame have been composed and header of size removed):
0000DC79 here it's the id of the order, done by the client, it's a 32Bits unsigned int.
In decomposing that's do:
The reply:
For the reply, we return id of order finished, the return code, and the return info if needed:
In decomposing it do:
0000DC79 the order id, see at top (32Bits unsigned int)
000001388 return code, it decimal it do 5000 -> unknow order (32Bits unsigned int)
This protocol define the communication between an explorer (or all other application which do copy) and software of file copy.
Choice of the mode of communication:
The choice have been done, it's use QLocalServer (The application of copy) and QLocalSocket (the file explorer). Under windows then it's done with named pipe and under unix an unix socket.
That's allow isolate the language (server in c++ and client in Qt) and the architecture (server 32Bits to portable version and client in 64Bits like the explorer.exe of Windows 64Bits)
It's allow too only the local connexion and detect the application disconnection or of the client (with crash too example).
About the performance, a Pentium 3 at 500MHz can transfer of this mode 1GB/s, to copy list very ofter < at 32KB (the transfer is done in 30µs -> 0.00003s, that's greatly lower then copy time). Better performance is useless here.
About security, that's do the process is kept into the user space.
For windows: The name of the named pipe is: "advanced-copier-[user]", where [user] is the user name in hexa + little endian. Example, for the user named: "user", the encoded string form WCHAR is "7500730065007200", then it do: advanced-copier-7500730065007200
For unix: The path of the unix socket is: "/tmp/advanced-copier-[uid]", where [uid] is the id of the current user, example: /tmp/advanced-copier-1000
Decomposition and recomposition:
All order/reply need be cute as packet of 32KB max. To check correct size to the receiver and header of int unsigned of 32Bits is included, and it contain size of all the order/reply.
The receiver need remove this header and group all frame in unique frame.
Encoding used:
The used encoding is the l'unicode (utf16), where each char is encoded into 16Bits in big endian. All modern OS use it.
Format of the composed frame:
The order can not be more than 64MB. Format of the order's data (after frame have been composed and header of size removed):
0000DC79000000060000000200610000000400610062000000060061006200630000000800610062006300640000000a006100620063006400650000000c006100620063006400650066
0000DC79 here it's the id of the order, done by the client, it's a 32Bits unsigned int.
In decomposing that's do:
- 00000006 List size (32Bits unsigned int)
- 00000002 (string size in bytes, 32Bits unsigned int) 0061 -> a
- 00000004 (string size in bytes, 32Bits unsigned int) 00610062 -> ab
- 00000006 (string size in bytes, 32Bits unsigned int) 006100620063 -> abc
- 00000008 (string size in bytes, 32Bits unsigned int) 0061006200630064 -> abcd
- 0000000a (string size in bytes, 32Bits unsigned int) 00610062006300640065 -> abcde
- 0000000c (string size in bytes, 32Bits unsigned int) 006100620063006400650066 -> abcdef
The reply:
For the reply, we return id of order finished, the return code, and the return info if needed:
0000DC7900000138800000001000000180075006e006b006e006f00770020006f0072006400650072
In decomposing it do:
0000DC79 the order id, see at top (32Bits unsigned int)
000001388 return code, it decimal it do 5000 -> unknow order (32Bits unsigned int)
- 00000001 List size (32Bits unsigned ints)
- 00000018 (string size in bytes, 32Bits unsigned int) 0075006e006b006e006f00770020006f0072006400650072 -> unknow order
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
Send multiple frame
To send multiple frame then distinct order, the frames recomposed are:
Send copy A to do with the id DC79:
End of previous packet and new packet. The 2 frames wouldn't be concatenated.
Send copy B to do with the id DC7A (the number is new because need be unique to identify the reply linked with it):
Send copy A to do with the id DC79:
0000DC79000000060000000200610000000400610062000000060061006200630000000800610062006300640000000a006100620063006400650000000c006100620063006400650066
End of previous packet and new packet. The 2 frames wouldn't be concatenated.
Send copy B to do with the id DC7A (the number is new because need be unique to identify the reply linked with it):
0000DC7A000000060000000200610000000400610062000000060061006200630000000800610062006300640000000a006100620063006400650000000c006100620063006400650066
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
Order send in the protocol
Here the order allowed, the [] need be replace by theres values.
The texts can be varied with server, the return code no.
The return code is returned like unsigned int 32Bits and not as string.
All the unknow order is ignored by the application:
Send protocol used (obligation at the connexion):
Reply:
Dection of protocol extension:
Reply:
Client identification (if you want):
Reply:
Ask server name:
Réponses possible:
Send copy/move list
cp or mv, for copy or move, and cp-? or mv-? for the software ask the destination -> then list without destination
each arguement need do 1 to 65535 char
The list (cp/mv included) need containt 3 to 65535 entry
The dir separation should be \ under windows, and / under unix
Reply:
IIf the order is unknow:
The texts can be varied with server, the return code no.
The return code is returned like unsigned int 32Bits and not as string.
All the unknow order is ignored by the application:
Send protocol used (obligation at the connexion):
- protocol
- 0002
Reply:
- 1000
- protocol supported
- 5000
- incorrect argument list size
- 5001
- incorrect argument
- 5003
- protocol not supported
Dection of protocol extension:
- protocol extension
- [nom de l'extension]
- [version de l'extension (facultatif)]
Reply:
- 1001
- protocol extension supported
- 1002
- protocol extension not supported
- 5000
- incorrect argument list size
- 5001
- incorrect argument
Client identification (if you want):
- client
- [client name]
Reply:
- 1003
- client registered
- 5000
- incorrect argument list size
- 5001
- incorrect argument
Ask server name:
- server
- name?
Réponses possible:
- 1004
- [Server name]
- 5000
- incorrect argument list size
- 5001
- incorrect argument
Send copy/move list
cp or mv, for copy or move, and cp-? or mv-? for the software ask the destination -> then list without destination
each arguement need do 1 to 65535 char
The list (cp/mv included) need containt 3 to 65535 entry
The dir separation should be \ under windows, and / under unix
- cp
- [source1]
- [source2]
- [destination]
Reply:
- 1005
- finished
- 1006
- finished with error(s)
- 1007
- canceled
- 5000
- incorrect argument list size
- 5001
- incorrect argument
IIf the order is unknow:
- 5002
- unknow order
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
Recomposition
Example, if the size max is 512B:
Before decomposition, here client -> server, but same for server -> client:
After decomposition:
Before decomposition, here client -> server, but same for server -> client:
0000043a000000040000001100000004006300700000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0041005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0042005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0043005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0044005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0045005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0046005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0047005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0048005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d0049005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004a005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004b005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004c005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004d005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004e005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070
005c0073006f0075007200630065002d004f005c000000440063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074
006f0070005c00640065007300740069006e006100740069006f006e005c
After decomposition:
1) 0000043a000000040000001100000004006300700000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073
006f0075007200630065002d0041005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f007500720063
0065002d0042005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f0075007200630065002d0043005c
[color=#FFBF00]0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073
2) 006b0074006f0070005c0073006f0075007200630065002d0044005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f007000
5c0073006f0075007200630065002d0045005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f00750072
00630065002d0046005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f0075007200630065002d004700
5c0000003e0063003a005c0055007300650072005c00750073006500720073
3) 005c004400650073006b0074006f0070005c0073006f0075007200630065002d0048005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b00
74006f0070005c0073006f0075007200630065002d0049005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073
006f0075007200630065002d004a005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f00750072006300
65002d004b005c0000003e0063003a005c0055007300650072005c0075
4) 0073006500720073005c004400650073006b0074006f0070005c0073006f0075007200630065002d004c005c0000003e0063003a005c0055007300650072005c00750073006500720073005c
004400650073006b0074006f0070005c0073006f0075007200630065002d004d005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074
006f0070005c0073006f0075007200630065002d004e005c0000003e0063003a005c0055007300650072005c00750073006500720073005c004400650073006b0074006f0070005c0073006f
0075007200630065002d004f005c000000440063003a005c00550073
5) 00650072005c00750073006500720073005c004400650073006b0074006f0070005c00640065007300740069006e006100740069006f006e005c
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
Example of communication
Connexion of the client (the file explorer of software to do file copy) to the server (the copie software)
Legend:
Size total of the packet, included this 32Bits part
Query id, is auto incremented id
Reply code (1000, 1003, 5000), used by client if wanted
Size of string list
Size in byte of string
Real string content
Registering of the procol (obligation before all)
Client -> Server: query 00000001, array("protocol","0002")
Reply of the server to the query 00000001
Server -> Client: reply to the query 00000001,1000, array("protocol supported")
Send client name
Client -> Server: query 00000002, array("client","test client")
Reply of the server to the query 00000002
Server -> Client: reply to the query 00000002,1003, array("client registered")
Send copy list A
Client -> Server: query 00000003, array("cp","c:\source-folder\","c:\destination-folder\")
Send copy list B
Client -> Server: query 00000004, array("mv","c:\source-file.iso","c:\destination-folder\")
Reply of the server to the query 00000004, the copy list B is finished
Server -> Client: reply to the query 00000004,1005, array("finished")
Reply of the server to the query 00000003, the copy list A is canceled
Server -> Client: reply to the query 00000003,1007, array("canceled")
Legend:
Size total of the packet, included this 32Bits part
Query id, is auto incremented id
Reply code (1000, 1003, 5000), used by client if wanted
Size of string list
Size in byte of string
Real string content
Registering of the procol (obligation before all)
Client -> Server: query 00000001, array("protocol","0002")
00000001000000020000001000700072006f0074006f0063006f006c000000080030003000300032
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000002c00000001000000020000001000700072006f0074006f0063006f006c000000080030003000300032
Reply of the server to the query 00000001
Server -> Client: reply to the query 00000001,1000, array("protocol supported")
00000001000003E8000000010000002400700072006f0074006f0063006f006c00200073007500700070006f0072007400650064
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000003800000001000003E8000000010000002400700072006f0074006f0063006f006c00200073007500700070006f0072007400650064
Send client name
Client -> Server: query 00000002, array("client","test client")
00000002000000020000000c0063006c00690065006e007400000016007400650073007400200063006c00690065006e0074
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000003600000002000000020000000c0063006c00690065006e007400000016007400650073007400200063006c00690065006e0074
Reply of the server to the query 00000002
Server -> Client: reply to the query 00000002,1003, array("client registered")
00000002000003eb00000001000000220063006c00690065006e007400200072006500670069007300740065007200650064
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000003600000002000003eb00000001000000220063006c00690065006e007400200072006500670069007300740065007200650064
Send copy list A
Client -> Server: query 00000003, array("cp","c:\source-folder\","c:\destination-folder\")
00000003000000030000000400630070000000220063003a005c0073006f0075007200630065002d0066006f006c006400650072005c
0000002c0063003a005c00640065007300740069006e006100740069006f006e002d0066006f006c006400650072005c
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000006a00000003000000030000000400630070000000220063003a005c0073006f0075007200630065002d0066006f006c006400650072005c
0000002c0063003a005c00640065007300740069006e006100740069006f006e002d0066006f006c006400650072005c
Send copy list B
Client -> Server: query 00000004, array("mv","c:\source-file.iso","c:\destination-folder\")
000000040000000300000004006d0076000000240063003a005c0073006f0075007200630065002d00660069006c0065002e00690073006f
0000002c0063003a005c00640065007300740069006e006100740069006f006e002d0066006f006c006400650072005c
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000006c000000040000000300000004006d0076000000240063003a005c0073006f0075007200630065002d00660069006c0065002e00690073006f
0000002c0063003a005c00640065007300740069006e006100740069006f006e002d0066006f006c006400650072005c
Reply of the server to the query 00000004, the copy list B is finished
Server -> Client: reply to the query 00000004,1005, array("finished")
00000004000003ed000000010000001000660069006e00690073006800650064
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000002400000004000003ed000000010000001000660069006e00690073006800650064
Reply of the server to the query 00000003, the copy list A is canceled
Server -> Client: reply to the query 00000003,1007, array("canceled")
00000003000003ef000000010000001000630061006e00630065006c00650064
Packet really send, with header for recomposition and 1 block send (not cuted) because is smaller than 32KB (see recomposition part):
1) 0000002400000003000003ef000000010000001000630061006e00630065006c00650064
Enjoy ultracopier 
- alpha_one_x86
- Site Admin
- Posts: 34
- Joined: Sun Oct 26, 2008 9:09 am
6 posts
• Page 1 of 1

