apricode assignment
TRANSCRIPT
-
7/29/2019 Apricode Assignment
1/3
Programming assignment: simple TCP / IP client - performance test
1. Description:A TCP/IP Client of a given binary protocol should be implemented. The protocol defines login, logout
and error frames. The connection must be established by way of a TCP/IP Socket . The client should
be used as the foundation for a performance test with the following criteria:
Parallel login and logout for 1.000 client connections. Logging of a login/logout roundtrip time of one client connection. Calculation of the average login/logout time for all parallel client connections.
Demo server address:
IP: 194.208.27.222 Port: 80812. Protocol
2.1InstructionThe Protocol frames will be sent as a binary block. The byte order is little-endian. The
header-information MessageType, SessionId and BodyLength are always required. These
fields define the header of the frame and all other fields define the body. All strings are
encoded in UTF-8 and case-sensitive. The SessionId has to be the same value as theSessionId from the Login Response. The BodyLength is the sum of the length of all
following fields (body of the frame).
2.2Sequence Establish TCP/IP connection to the server Send LoginRequest Retrieve Response Send LogoutRequest
2.3Frames
2.3.1 Login RequestField Type Length Required
MessageType Int32 4 Byte Yes
SessionId GUID 16 Byte Yes
BodyLength Int64 8 Byte Yes
Id String 6 Byte Yes
UserLength Int32 4 Byte Yes
User String Defined by
UserLength
Yes
PasswordLength Int32 4 Byte YesPassword String Defined by
PasswordLength
Yes
-
7/29/2019 Apricode Assignment
2/3
Description:
MessageType = 1
The Id has to be set with your authentication Id. The SessionId has to be an empty GUID (
TextRepresentation: 00000000-0000-0000-0000-000000000000) in binary
representation. Definition of a GUID:[Globally unique identifier - Wikipedia, the free
encyclopedia]
Binary Representation of a GUID:
Bits Bytes Description Endianness
32 4 Data1 Big
16 2 Data2 Big
16 2 Data3 Big
64 8 Data4 Big
2.3.2 Login Response
Field Type Length Required
MessageType Int32 4 Byte Yes
SessionId GUID 16 Byte Yes
BodyLength Int64 8 Byte Yes
Success Bool 1 Byte Yes
ErrorLength Int32 4 Byte Yes
Error String Defined by
ErrorLength
No
Description:
MessageType =2
The SessionId of the Login Response is the session identifier for all other frames.
2.3.3 Logout Request
Field Type Length Required
MessageType Int32 4 Byte Yes
SessionId GUID 16 Byte Yes
BodyLength Int64 8 Byte Yes
Id String 6 Byte Yes
LogoutCode Int32 4 Byte YesMessageLength Int32 4 Byte Yes
Message String Defined by
MessageLength
No
Description:
MessageType=3
The Id has to be set with your authentication Id. The SessionId has to be the value of the
Login Response. The LogoutCode has to have the value 1. The Message is optional.
2.3.4 Error Frame
Field Type Length Required
MessageType Int32 4 Byte Yes
http://en.wikipedia.org/wiki/Guidhttp://en.wikipedia.org/wiki/Guidhttp://en.wikipedia.org/wiki/Guidhttp://en.wikipedia.org/wiki/Guidhttp://en.wikipedia.org/wiki/Guid -
7/29/2019 Apricode Assignment
3/3
SessionId GUID 16 Byte Yes
BodyLength Int64 8 Byte Yes
ErrorCode Int32 4 Byte Yes
MessageLength Int32 4 Byte Yes
Message String Defined by
MessageLength
No
Description:
MessageType=4
The Message field contains details of the error.
2.4ExceptionsIf a message header couldnt be read, no message will be returned.
If the authentication fails, an Error Frame will be returned.
If the Login fails, an LoginResponse with the Error Message will be returned.If a Frame with a unknown MessageType has been send, an Error Frame will be
returned.
If the SessionId isnt the same as the SessionId from the Login Response, an Error
Frame will be returned.
If the LogoutCode is not 1, an Error Frame will be returned.
3. Available UsersYou could use one of the following users or all for a Login Requests.
User Password
Plato Dfedl1285!
Nietsche Jdkiel3849?
Confucius D9348djiex$
Descartes 930eidkfrq%