NetStream Получение данных с приложения
06.04.2021, 15:04. Показов 1255. Ответов 0
всем добрый день господа.
У меня есть приложение которое накладывает на лицо сетку и передаёт данные по TCP в открытом виде.
"Шарком" я вытянул данные которые он передаёт
hex
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| 0000 18 c0 4d 34 75 02 c2 2c 80 32 56 db 08 00 45 00 ..M4u..,.2V...E.
0010 02 87 00 00 40 00 40 06 de 40 ac 10 01 0b ac 10 ....@.@..@......
0020 01 05 03 e7 c5 8d 2c e9 7b d0 0a 28 cb 70 50 18 ......,.{..(.pP.
0030 20 00 9b 99 00 00 3a 20 32 2c 6e 6f 73 65 53 6e .....: 2,noseSn
0040 65 65 72 5f 52 20 3a 20 32 35 2c 6d 6f 75 74 68 eer_R : 25,mouth
0050 52 69 67 68 74 20 3a 20 30 2c 65 79 65 4c 6f 6f Right : 0,eyeLoo
0060 6b 49 6e 5f 4c 20 3a 20 30 2c 62 72 6f 77 4f 75 kIn_L : 0,browOu
0070 74 65 72 55 70 5f 52 20 3a 20 30 2c 65 79 65 4c terUp_R : 0,eyeL
0080 6f 6f 6b 44 6f 77 6e 5f 4c 20 3a 20 31 30 2c 63 ookDown_L : 10,c
0090 68 65 65 6b 53 71 75 69 6e 74 5f 52 20 3a 20 32 heekSquint_R : 2
00a0 35 2c 6e 6f 73 65 53 6e 65 65 72 5f 4c 20 3a 20 5,noseSneer_L :
00b0 32 35 2c 6d 6f 75 74 68 46 75 6e 6e 65 6c 20 3a 25,mouthFunnel :
00c0 20 38 2c 65 79 65 4c 6f 6f 6b 4f 75 74 5f 4c 20 8,eyeLookOut_L
00d0 3a 20 38 2c 6d 6f 75 74 68 52 6f 6c 6c 4c 6f 77 : 8,mouthRollLow
00e0 65 72 20 3a 20 33 2c 6d 6f 75 74 68 53 68 72 75 er : 3,mouthShru
00f0 67 55 70 70 65 72 20 3a 20 33 32 2c 62 72 6f 77 gUpper : 32,brow
0100 49 6e 6e 65 72 55 70 20 3a 20 39 2c 6a 61 77 4f InnerUp : 9,jawO
0110 70 65 6e 20 3a 20 32 39 2c 65 79 65 42 6c 69 6e pen : 29,eyeBlin
0120 6b 5f 52 20 3a 20 30 2c 63 68 65 65 6b 53 71 75 k_R : 0,cheekSqu
0130 69 6e 74 5f 4c 20 3a 20 32 34 2c 6d 6f 75 74 68 int_L : 24,mouth
0140 55 70 70 65 72 55 70 5f 4c 20 3a 20 33 32 2c 65 UpperUp_L : 32,e
0150 79 65 4c 6f 6f 6b 44 6f 77 6e 5f 52 20 3a 20 31 yeLookDown_R : 1
0160 30 2c 6d 6f 75 74 68 46 72 6f 77 6e 5f 4c 20 3a 0,mouthFrown_L :
0170 20 30 2c 6d 6f 75 74 68 44 69 6d 70 6c 65 5f 52 0,mouthDimple_R
0180 20 3a 20 31 35 2c 6d 6f 75 74 68 44 69 6d 70 6c : 15,mouthDimpl
0190 65 5f 4c 20 3a 20 31 36 2c 65 79 65 57 69 64 65 e_L : 16,eyeWide
01a0 5f 4c 20 3a 20 33 36 2c 65 79 65 57 69 64 65 5f _L : 36,eyeWide_
01b0 52 20 3a 20 33 36 2c 65 79 65 42 6c 69 6e 6b 5f R : 36,eyeBlink_
01c0 4c 20 3a 20 30 2c 6d 6f 75 74 68 53 68 72 75 67 L : 0,mouthShrug
01d0 4c 6f 77 65 72 20 3a 20 32 2c 65 79 65 53 71 75 Lower : 2,eyeSqu
01e0 69 6e 74 5f 52 20 3a 20 31 37 2c 65 79 65 4c 6f int_R : 17,eyeLo
01f0 6f 6b 55 70 5f 52 20 3a 20 30 2c 6d 6f 75 74 68 okUp_R : 0,mouth
0200 53 6d 69 6c 65 5f 4c 20 3a 20 36 36 2c 68 65 61 Smile_L : 66,hea
0210 64 5f 55 70 20 3a 20 33 30 2e 30 37 38 33 39 2c d_Up : 30.07839,
0220 68 65 61 64 5f 52 69 67 68 74 20 3a 20 38 2e 34 head_Right : 8.4
0230 39 36 37 37 38 35 2c 68 65 61 64 5f 52 69 67 68 967785,head_Righ
0240 74 54 69 6c 74 20 3a 20 31 32 2e 31 37 39 36 36 tTilt : 12.17966
0250 31 2c 48 65 61 64 50 6f 73 58 20 3a 20 30 2e 30 1,HeadPosX : 0.0
0260 33 31 36 37 38 33 38 36 2c 48 65 61 64 50 6f 73 31678386,HeadPos
0270 59 20 3a 20 30 2e 30 31 33 32 39 38 36 39 38 2c Y : 0.013298698,
0280 48 65 61 64 50 6f 73 5a 20 3a 20 30 2e 34 32 31 HeadPosZ : 0.421
0290 30 37 32 39 2c 0729, |
|
Но вот ума не доходит как считать данные, с какого байта начинать чтение. Ранее таким не увлекался и прошу помощи в освоении и чтении потока.
На таком коде я получаю пустоты
| C# | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| static void DoConnect(string host, int port)
{
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
IPAddress[] IPAddresses = Dns.GetHostAddresses(host);
Console.WriteLine("Establishing connection to {0}", host);
client.Connect(IPAddresses, port);
Console.WriteLine("Connection established");
NetworkStream stream = client.GetStream();
byte[] bytes = new byte[client.ReceiveBufferSize];
Console.WriteLine("ReceiveBufferSize in client - {0}", client.ReceiveBufferSize);
string returndata = Encoding.UTF8.GetString(bytes);
// Reply
if (stream.CanRead)
{
byte[] readBuffer = new byte[client.ReceiveBufferSize];
string fullServerReply = null;
using (var writer = new MemoryStream())
{
while (stream.DataAvailable)
{
int numberOfBytesRead = stream.Read(readBuffer, 0x54, readBuffer.Length);
if (numberOfBytesRead <= 0)
{
break;
}
writer.Write(readBuffer, 0x54, numberOfBytesRead);
}
fullServerReply = Encoding.UTF8.GetString(writer.ToArray());
Console.WriteLine("new data recived - {0}", fullServerReply);
}
}
File.AppendAllText(@"log.log", returndata); |
|
Я что то не понимаю в офсетах и даже если офсет == 0 всё равно пустота
client.ReceiveBufferSize == 65536
Данные которые я получаю
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
| Frame 143: 661 bytes on wire (5288 bits), 661 bytes captured (5288 bits) on interface \Device\NPF_{025FE554-88B2-4BA8-A2C3-875D2368F92F}, id 0
Interface id: 0 (\Device\NPF_{025FE554-88B2-4BA8-A2C3-875D2368F92F})
Interface name: \Device\NPF_{025FE554-88B2-4BA8-A2C3-875D2368F92F}
Interface description: Ethernet
Encapsulation type: Ethernet (1)
Arrival Time: Apr 6, 2021 13:21:16.180674000 RTZ 3 (зима)
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1617700876.180674000 seconds
[Time delta from previous captured frame: 0.000063000 seconds]
[Time delta from previous displayed frame: 0.000063000 seconds]
[Time since reference or first frame: 0.832784000 seconds]
Frame Number: 143
Frame Length: 661 bytes (5288 bits)
Capture Length: 661 bytes (5288 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:tcp:data]
[Coloring Rule Name: TCP]
[Coloring Rule String: tcp]
Ethernet II, Src: c2:2c:80:32:56:db (c2:2c:80:32:56:db), Dst: Giga-Byt_34:75:02 (18:c0:4d:34:75:02)
Destination: Giga-Byt_34:75:02 (18:c0:4d:34:75:02)
Address: Giga-Byt_34:75:02 (18:c0:4d:34:75:02)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: c2:2c:80:32:56:db (c2:2c:80:32:56:db)
Address: c2:2c:80:32:56:db (c2:2c:80:32:56:db)
.... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 172.16.1.11, Dst: 172.16.1.5
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint: Default (0)
.... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
Total Length: 647
Identification: 0x0000 (0)
Flags: 0x40, Don't fragment
0... .... = Reserved bit: Not set
.1.. .... = Don't fragment: Set
..0. .... = More fragments: Not set
Fragment Offset: 0
Time to Live: 64
Protocol: TCP (6)
Header Checksum: 0xde40 [validation disabled]
[Header checksum status: Unverified]
Source Address: 172.16.1.11
Destination Address: 172.16.1.5
Transmission Control Protocol, Src Port: 999, Dst Port: 50573, Seq: 52762, Ack: 1, Len: 607
Source Port: 999
Destination Port: 50573
[Stream index: 0]
[TCP Segment Len: 607]
Sequence Number: 52762 (relative sequence number)
Sequence Number (raw): 753499088
[Next Sequence Number: 53369 (relative sequence number)]
Acknowledgment Number: 1 (relative ack number)
Acknowledgment number (raw): 170445680
0101 .... = Header Length: 20 bytes (5)
Flags: 0x018 (PSH, ACK)
000. .... .... = Reserved: Not set
...0 .... .... = Nonce: Not set
.... 0... .... = Congestion Window Reduced (CWR): Not set
.... .0.. .... = ECN-Echo: Not set
.... ..0. .... = Urgent: Not set
.... ...1 .... = Acknowledgment: Set
.... .... 1... = Push: Set
.... .... .0.. = Reset: Not set
.... .... ..0. = Syn: Not set
.... .... ...0 = Fin: Not set
[TCP Flags: ·······AP···]
Window: 8192
[Calculated window size: 8192]
[Window size scaling factor: -1 (unknown)]
Checksum: 0x9b99 [unverified]
[Checksum Status: Unverified]
Urgent Pointer: 0
[SEQ/ACK analysis]
[Bytes in flight: 607]
[Bytes sent since last PSH flag: 2067]
[Timestamps]
[Time since first frame in this TCP stream: 0.832784000 seconds]
[Time since previous frame in this TCP stream: 0.000063000 seconds]
TCP payload (607 bytes)
Data (607 bytes)
Data: 3a20322c6e6f7365536e6565725f52203a2032352c6d6f7574685269676874203a20302c…
[Length: 607] |
|

0
|