Meaning of bytes in BitTorrent protocol - bittorrent

I am going to try to write simple BitTorrent client. Of course I read http://wiki.theory.org/BitTorrentSpecification. I began by analyzing communication between two clients. I have problem with meaning of two fields - bold font in the following hexadecimal dump.
First packet send by Deluge to rTorrent:
00000000 13 |. | - protocol name length (1) - 0x13 = 19
00000000 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 | BitTorrent prot| - protocol name (19)
00000010 6f 63 6f 6c |ocol |
00000010 00 00 00 00 00 18 00 05 | ........ | - reserved extension bytes (8)
00000010 ab 20 ef 66 | . .f| - info_hash (20)
00000020 c8 ee de 47 99 a2 75 40 20 75 ee 7b c6 4e 2f dd |...G..u# u.{.N/.|
00000030 2d 44 45 31 33 33 30 2d 42 6c 78 37 6c 69 7a 7e |-DE1330-Blx7liz~| - peer_id (20)
00000040 4a 54 2e 6a |JT.j| Deluge 1.3.3
Answer from rTorrent to Deluge:
00000000 13 |. | - protocol name length (1) - 0x13 = 19
00000000 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 | BitTorrent prot| - protocol name (19)
00000010 6f 63 6f 6c |ocol |
00000010 00 00 00 00 00 10 00 00 | ........ | - reserved extension bytes (8)
00000010 ab 20 ef 66 | . .f| - info_hash (20)
00000020 c8 ee de 47 99 a2 75 40 20 75 ee 7b c6 4e 2f dd |...G..u# u.{.N/.|
00000030 2d 6c 74 30 43 39 30 2d b6 eb 22 ae 31 e3 89 90 |-lt0C90-..".1...| - peer_id (20)
00000040 2a 9b af a9 |*... | libTorrent (rakshasa) 0.12.9
00000040 00 00 00 6e | ...n | - message length? (4) - 0x6E = 110
00000040 14 00 | .. | - something (2) - message id?
00000040 64 31 3a 65 69 30 | d1:ei0| - bencoded dictionary (108)
00000050 65 31 3a 6d 64 31 31 3a 75 74 5f 6d 65 74 61 64 |e1:md11:ut_metad| { 'e': 0,
00000060 61 74 61 69 32 65 36 3a 75 74 5f 70 65 78 69 31 |atai2e6:ut_pexi1| 'metadata_size': 1702,
00000070 65 65 31 33 3a 6d 65 74 61 64 61 74 61 5f 73 69 |ee13:metadata_si| 'm': {'ut_metadata': 2, 'ut_pex': 1},
00000080 7a 65 69 31 37 30 32 65 31 3a 70 69 35 30 30 39 |zei1702e1:pi5009| 'reqq': 2048,
00000090 34 65 34 3a 72 65 71 71 69 32 30 34 38 65 31 3a |4e4:reqqi2048e1:| 'p': 50094,
000000a0 76 31 37 3a 6c 69 62 54 6f 72 72 65 6e 74 20 30 |v17:libTorrent 0| 'v': 'libTorrent 0.12.9' }
000000b0 2e 31 32 2e 39 65 |.12.9e |
000000b0 00 00 00 0c 05 | .....| - something (5) - checksum?

Related

Hyperledger Fabric: Proposal has not been endorsed

I am trying to commit a transaction on the Blockchain of the Hyperledger Fabric 2.2 after offline signing of the transaction from users private key.
After signing the transaction proposal,I send it to the endorsers for the endorsements and in response i get following endorsements from the endorser peers.
[ { version: 1,
timestamp: null,
response:
{ status: 200,
message: '',
payload:
<Buffer 7b 22 4f 72 67 4e 61 6d 65 22 3a 22 78 79 7a 31 22 2c 22 64 6f 63 54 79 70 65 22 3a 22 63 65 72 74 69 66 69 63 61 74 65 22 2c 22 64 6f 6d 61 69 6e 22 ... > },
payload:
<Buffer 0a 20 ca 1d b7 e3 be aa 49 c8 29 a7 ec 70 22 e8 16 39 42 5a 0f ba e2 d5 3f fd 73 5d 3b 46 fb a0 4b 1f 12 d8 01 0a 64 12 34 0a 0a 5f 6c 69 66 65 63 79 ... >,
endorsement:
{ endorser:
<Buffer 0a 07 4f 72 67 31 4d 53 50 12 d9 07 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 43 71 54 43 43 41 6c ... >,
signature:
<Buffer 30 45 02 21 00 aa ca ad 65 19 c4 f7 81 14 d2 dc e4 66 78 37 e7 9e 26 da 42 6a a6 d4 9f 6b 82 63 c5 96 36 3d c2 02 20 4e a7 57 ab 6f a7 9f 6c 7b 08 53 ... > },
connection:
{ type: 'Endorser',
name: 'peer0.org1.example.com:7051',
url: 'grpcs://localhost:7051',
options: [Object] },
peer: 'peer0.org1.example.com:7051' },
{ version: 1,
timestamp: null,
response:
{ status: 200,
message: '',
payload:
<Buffer 7b 22 4f 72 67 4e 61 6d 65 22 3a 22 78 79 7a 31 22 2c 22 64 6f 63 54 79 70 65 22 3a 22 63 65 72 74 69 66 69 63 61 74 65 22 2c 22 64 6f 6d 61 69 6e 22 ... > },
payload:
<Buffer 0a 20 ca 1d b7 e3 be aa 49 c8 29 a7 ec 70 22 e8 16 39 42 5a 0f ba e2 d5 3f fd 73 5d 3b 46 fb a0 4b 1f 12 d8 01 0a 64 12 34 0a 0a 5f 6c 69 66 65 63 79 ... >,
endorsement:
{ endorser:
<Buffer 0a 07 4f 72 67 32 4d 53 50 12 d1 07 2d 2d 2d 2d 2d 42 45 47 49 4e 20 43 45 52 54 49 46 49 43 41 54 45 2d 2d 2d 2d 2d 0a 4d 49 49 43 70 54 43 43 41 6b ... >,
signature:
<Buffer 30 44 02 20 6e 9c 3f 83 eb a0 45 5b 94 9b 58 be 38 55 8b 00 58 6c 1e c6 8e 65 bd 34 11 4b 8e 4c 76 6c 76 75 02 20 5c 3f c8 ee 14 43 51 a4 07 e8 3a e7 ... > },
connection:
{ type: 'Endorser',
name: 'peer0.org2.example.com:9051',
url: 'grpcs://localhost:9051',
options: [Object] },
peer: 'peer0.org2.example.com:9051' } ]
But, when i try to build,a required formatted proposal including the endorsements,to send it to the orderer so that orderer network, orders the transaction and sends it to committing peers for commitment on the Blockchain,but it gives following error
Failed to submit transaction: Error: Proposal has not been endorsed
code to build the proposal for the orderer
let commitment = new Commit('pki','mychannel')
let idx = client.newIdentityContext(user.user);
let commit = commitment.build(idx,{endorsement:ProposalResponse})
Followed these instructions https://hyperledger.github.io/fabric-sdk-node/release-2.2/Proposal.html#build
Any thoughts are appreciated

strace does not show the complete write

Im trying to view the data being written to an HTTP socket using strace
However, although I have given -e write=all, I still cannot see all the data being written
strace -o /tmp/capture.log -p <pid> -e trace=all -e write=all -e read=all -f -tt
..
29620 16:09:14.723120 write(1899, "POST /task/native.wsdl HTTP/1.1\r"..., 210) = 210
29620 16:09:14.723319 write(1899, "<soap:Envelope xmlns:soap=\"http:"..., 450) = 450
What is strange is that, it shows the complete data during some other writes to other sockets
31145 16:09:28.110571 write(359, "POST /task/native.wsdl HTTP/1.1\r"..., 210) = 210
| 00000 50 4f 53 54 20 2f 74 61 73 6b 2f 6e 61 74 69 76 POST /task/nativ |
| 00010 65 2e 77 73 64 6c 20 48 54 54 50 2f 31 2e 31 0d e.wsdl HTTP/1.1. |
| 00020 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 .Content-Type: t |
| 00030 65 78 74 2f 78 6d 6c 3b 20 63 68 61 72 73 65 74 ext/xml; charset |
| 00040 3d 55 54 46 2d 38 0d 0a 41 63 63 65 70 74 3a 20 =UTF-8..Accept: |
| 00050 2a 2f 2a 0d 0a 53 4f 41 50 41 63 74 69 6f 6e 3a */*..SOAPAction: |
| 00060 20 22 22 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a ""..User-Agent: |
| 00070 20 41 70 61 63 68 65 20 43 58 46 20 32 2e 37 2e Apache CXF 2.7. |
| 00080 31 31 0d 0a 48 6f 73 74 3a 20 65 73 2d 73 76 63 11..Host: es-svc |
| 00090 73 2e 69 74 2e 61 74 74 2e 63 6f 6d 3a 37 30 30 s.it.att.com:700 |
| 000a0 33 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 4b 3..Connection: K |
| 000b0 65 65 70 2d 41 6c 69 76 65 0d 0a 43 6f 6e 74 65 eep-Alive..Conte |
| 000c0 6e 74 2d 4c 65 6e 67 74 68 3a 20 34 35 30 0d 0a nt-Length: 450.. |
| 000d0 0d 0a .. |
Can somebody please explain. Is it possible to get data from all writes
The strace -e write=a,b flag shows write syscalls for file descriptors numbered from a to b, and -e write=all shows write syscalls to all file descriptors.
What you're looking for is -e abbrev=none; see the manpage:
-e abbrev=set
Abbreviate the output from printing each member of large structures.
The default is abbrev=all. The -v option has the effect of abbrev=none.

Unable to delete hidden characters from a text file in Linux bash [duplicate]

This question already has answers here:
How to remove ^[, and all of the escape sequences in a file using linux shell scripting
(14 answers)
Closed 4 years ago.
I have a file on a Linux machine which contains many hidden characters which are as follows :
$ cat -v file.txt
^[[2J^[[?7l^[[3;23r^[[?6l^[[1;1H^[[?25l^[[1;1HLogging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
^[[1;24r^[[1;1H^[[44;1HPress any key to continue^[[44;1H^[[?
25h^[[44;27H^[[2J^[[?7l^[[1;24r^[[?
6l^[[44;27H^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1HMH
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
^[[1;44r^[[44;1H^[[44;1H^[[2K^[[44;1H^[[?25h^[[44;1H^[[44;1My-Device-SW>
^[[44;1H^[[44;11H^[[44;1H^[[?
25h^[[44;11H^[[44;0H^[E^[[44;1H^[[44;11H^[[44;1H^[[2K^[[44;1H^[[?.
Earlier there were some ^M characters which I removed using :
sed 's/^M//g' file.txt
I want to remove only the hidden characters so that my actual file looks like :
$ cat file.txt
Logging into the device
Software revision V1.0
Copyright All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
ABC, COMPANY
Press any key to continue
My-Device-SW>
My-Device-show CPU
5 percent busy, from 388 sec ago
1 sec ave: 4 percent busy
5 sec ave: 16 percent busy
1 min ave: 7 percent busy
My-Device-SW>
My-Device-exit
Do you want to log out [y/n]? y
Connection to My-Device-SW closed.
Also posting the output of hexdump -C file.txt :
$ hexdump -C file.txt
00000000 1b 5b 32 4a 1b 5b 3f 37 6c 1b 5b 33 3b 32 33 72 |.[2J.[?7l.[3;23r|
00000010 1b 5b 3f 36 6c 1b 5b 31 3b 31 48 1b 5b 3f 32 35 |.[?6l.[1;1H.[?25|
00000020 6c 1b 5b 31 3b 31 48 4c 6f 67 67 69 6e 67 20 69 |l.[1;1HLogging i|
00000030 6e 74 6f 20 74 68 65 20 64 65 76 69 63 65 0a 53 |nto the device.S|
00000040 6f 66 74 77 61 72 65 20 72 65 76 69 73 69 6f 6e |oftware revision|
00000050 20 56 31 2e 30 0a 43 6f 70 79 72 69 67 68 74 20 | V1.0.Copyright |
00000060 41 6c 6c 20 52 69 67 68 74 73 20 52 65 73 65 72 |All Rights Reser|
00000070 76 65 64 2e 0a 20 20 20 20 20 20 20 20 20 20 20 |ved.. |
00000080 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000090 52 45 53 54 52 49 43 54 45 44 20 52 49 47 48 54 |RESTRICTED RIGHT|
000000a0 53 20 4c 45 47 45 4e 44 0a 20 55 73 65 2c 20 64 |S LEGEND. Use, d|
000000b0 75 70 6c 69 63 61 74 69 6f 6e 2c 20 6f 72 20 64 |uplication, or d|
000000c0 69 73 63 6c 6f 73 75 72 65 20 62 79 20 74 68 65 |isclosure by the|
000000d0 20 47 6f 76 65 72 6e 6d 65 6e 74 20 69 73 20 73 | Government is s|
000000e0 75 62 6a 65 63 74 20 74 6f 20 72 65 73 74 72 69 |ubject to restri|
000000f0 63 74 69 6f 6e 73 0a 20 20 20 20 20 20 20 20 20 |ctions. |
00000100 41 42 43 2c 20 43 4f 4d 50 41 4e 59 0a 1b 5b 31 |ABC, COMPANY..[1|
00000110 3b 32 34 72 1b 5b 31 3b 31 48 1b 5b 34 34 3b 31 |;24r.[1;1H.[44;1|
00000120 48 50 72 65 73 73 20 61 6e 79 20 6b 65 79 20 74 |HPress any key t|
00000130 6f 20 63 6f 6e 74 69 6e 75 65 1b 5b 34 34 3b 31 |o continue.[44;1|
00000140 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 32 37 48 1b |H.[?25h.[44;27H.|
00000150 5b 32 4a 1b 5b 3f 37 6c 1b 5b 31 3b 32 34 72 1b |[2J.[?7l.[1;24r.|
00000160 5b 3f 36 6c 1b 5b 34 34 3b 32 37 48 1b 5b 31 3b |[?6l.[44;27H.[1;|
00000170 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 |44r.[44;1H.[44;1|
00000180 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000190 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 |5h.[44;1H.[44;1H|
000001a0 4d 79 2d 44 65 76 69 63 65 2d 53 57 3e 20 1b 5b |My-Device-SW> .[|
000001b0 34 34 3b 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 |44;1H.[44;11H.[4|
000001c0 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 |4;1H.[?25h.[44;1|
000001d0 31 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 3b |1H.[44;0H.E.[44;|
000001e0 31 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 |1H.[44;11H.[44;1|
000001f0 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 |H.[2K.[44;1H.[?2|
00000200 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 |5h.[44;1H.[1;44r|
00000210 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b |.[44;1H.[1;44r.[|
00000220 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b |44;1H.[44;1H.[2K|
00000230 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 |.[44;1H.[?25h.[4|
00000240 34 3b 31 48 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 |4;1H.[44;1HMy-De|
00000250 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 |vice-SW> .[44;1H|
00000260 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b |.[44;11H.[44;1H.|
00000270 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 |[?25h.[44;11H.[4|
00000280 34 3b 31 31 48 73 68 6f 77 20 43 50 55 1b 5b 34 |4;11Hshow CPU.[4|
00000290 34 3b 31 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |4;11H.[?25h.[44;|
000002a0 31 39 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b 34 34 |19H.[44;0H.E.[44|
000002b0 3b 31 48 1b 5b 34 34 3b 31 39 48 1b 5b 34 34 3b |;1H.[44;19H.[44;|
000002c0 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f |1H.[2K.[44;1H.[?|
000002d0 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b 34 34 |25h.[44;1H.[1;44|
000002e0 72 1b 5b 34 34 3b 31 48 0a 35 20 70 65 72 63 65 |r.[44;1H.5 perce|
000002f0 6e 74 20 62 75 73 79 2c 20 66 72 6f 6d 20 33 38 |nt busy, from 38|
00000300 38 20 73 65 63 20 61 67 6f 0a 31 20 73 65 63 20 |8 sec ago.1 sec |
00000310 61 76 65 3a 20 34 20 70 65 72 63 65 6e 74 20 62 |ave: 4 percent b|
00000320 75 73 79 0a 35 20 73 65 63 20 61 76 65 3a 20 31 |usy.5 sec ave: 1|
00000330 36 20 70 65 72 63 65 6e 74 20 62 75 73 79 0a 31 |6 percent busy.1|
00000340 20 6d 69 6e 20 61 76 65 3a 20 37 20 70 65 72 63 | min ave: 7 perc|
00000350 65 6e 74 20 62 75 73 79 0a 1b 5b 31 3b 34 34 72 |ent busy..[1;44r|
00000360 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 48 1b 5b |.[44;1H.[44;1H.[|
00000370 32 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b |2K.[44;1H.[?25h.|
00000380 5b 34 34 3b 31 48 1b 5b 34 34 3b 31 4d 79 2d 44 |[44;1H.[44;1My-D|
00000390 65 76 69 63 65 2d 53 57 3e 20 1b 5b 34 34 3b 31 |evice-SW> .[44;1|
000003a0 48 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 |H.[44;11H.[44;1H|
000003b0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 31 48 1b 5b |.[?25h.[44;11H.[|
000003c0 34 34 3b 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b |44;0H.E.[44;1H.[|
000003d0 34 34 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 32 |44;11H.[44;1H.[2|
000003e0 4b 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |K.[44;1H.[?25h.[|
000003f0 34 34 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 |44;1H.[1;44r.[44|
00000400 3b 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 |;1H.[1;44r.[44;1|
00000410 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 |H.[44;1H.[2K.[44|
00000420 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 |;1H.[?25h.[44;1H|
00000430 1b 5b 34 34 3b 31 48 4d 79 2d 44 65 76 69 63 65 |.[44;1HMy-Device|
00000440 2d 53 57 3e 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 |-SW> .[44;1H.[44|
00000450 3b 31 31 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 |;11H.[44;1H.[?25|
00000460 68 1b 5b 34 34 3b 31 31 48 1b 5b 34 34 3b 31 31 |h.[44;11H.[44;11|
00000470 48 65 78 69 74 1b 5b 34 34 3b 31 31 48 1b 5b 3f |Hexit.[44;11H.[?|
00000480 32 35 68 1b 5b 34 34 3b 31 35 48 1b 5b 34 34 3b |25h.[44;15H.[44;|
00000490 30 48 1b 45 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b |0H.E.[44;1H.[44;|
000004a0 31 35 48 1b 5b 34 34 3b 31 48 1b 5b 32 4b 1b 5b |15H.[44;1H.[2K.[|
000004b0 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 3b |44;1H.[?25h.[44;|
000004c0 31 48 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 |1H.[1;44r.[44;1H|
000004d0 1b 5b 31 3b 34 34 72 1b 5b 34 34 3b 31 48 1b 5b |.[1;44r.[44;1H.[|
000004e0 34 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 |44;1H.[2K.[44;1H|
000004f0 1b 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 34 |.[?25h.[44;1H.[4|
00000500 34 3b 31 48 44 6f 20 79 6f 75 20 77 61 6e 74 20 |4;1HDo you want |
00000510 74 6f 20 6c 6f 67 20 6f 75 74 20 5b 79 2f 6e 5d |to log out [y/n]|
00000520 3f 20 1b 5b 34 34 3b 31 48 1b 5b 34 34 3b 33 31 |? .[44;1H.[44;31|
00000530 48 1b 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b |H.[44;1H.[?25h.[|
00000540 34 34 3b 33 31 48 1b 5b 34 34 3b 33 31 48 79 1b |44;31H.[44;31Hy.|
00000550 5b 34 34 3b 33 31 48 1b 5b 3f 32 35 68 1b 5b 34 |[44;31H.[?25h.[4|
00000560 34 3b 33 32 48 1b 5b 34 34 3b 30 48 1b 45 1b 5b |4;32H.[44;0H.E.[|
00000570 34 34 3b 31 48 1b 5b 34 34 3b 33 32 48 1b 5b 34 |44;1H.[44;32H.[4|
00000580 34 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 1b |4;1H.[2K.[44;1H.|
00000590 5b 3f 32 35 68 1b 5b 34 34 3b 31 48 1b 5b 31 3b |[?25h.[44;1H.[1;|
000005a0 34 34 72 1b 5b 34 34 3b 31 48 1b 5b 32 4a 1b 5b |44r.[44;1H.[2J.[|
000005b0 3f 37 6c 1b 5b 31 3b 34 34 72 1b 5b 3f 36 6c 1b |?7l.[1;44r.[?6l.|
000005c0 5b 34 34 3b 31 48 1b 5b 3f 32 35 68 1b 5b 34 34 |[44;1H.[?25h.[44|
000005d0 3b 31 48 1b 5b 3f 36 6c 1b 5b 31 3b 30 72 1b 5b |;1H.[?6l.[1;0r.[|
000005e0 3f 37 6c 1b 5b 32 4a 1b 5b 34 34 3b 31 48 1b 5b |?7l.[2J.[44;1H.[|
000005f0 31 3b 31 48 1b 5b 32 4b 1b 5b 34 34 3b 31 48 43 |1;1H.[2K.[44;1HC|
00000600 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f 20 4d 79 2d |onnection to My-|
00000610 44 65 76 69 63 65 2d 53 57 20 63 6c 6f 73 65 64 |Device-SW closed|
00000620 2e 0a |..|
00000622
Can someone please help me out in this?
Modifying with the actual file content above.
Are you using text files created under windows on Linux?. In that case you must install "tofrodos" package in your Linux distro, and then use "fromdos" tool to convert files from windows to linux format:
$ fromdos <windows-file-format.txt>

Network request to TV works from any device but Raspberry Pi

I'm trying to control my Panasonic TV via network. I had all my code (node) running from the laptop when I transferred it to the Raspberry. For some reason, it does not work from there. (A similar project controlling my Denon receiver works very well.)
By "Not Working", I mean, that the TV can be reached, but returns a 403 error. When TV is off, it's unreachable. So the Raspberry calls out to the TV.
I tried many different ways and eventually I'm working with a curl request. It works from everywhere, but not from the Raspberry:
curl 'http://192.168.178.142:55000/nrc/control_0' \
-H 'content-type: text/xml; charset="utf-8"' \
-H 'user-agent: net.thlabs.nodecontrol' \
-H 'soapaction: "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey"' \
--data-binary '<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendKey xmlns:u="urn:panasonic-com:service:p00NetworkControl:1"><X_KeyEvent>NRC_MUTE-ONOFF</X_KeyEvent></u:X_SendKey></s:Body></s:Envelope>' \
--compressed
It does work from the Raspberry, if I proxy through any other device e.g. my laptop. However, it does not work, when I proxy from laptop through the Raspberry.
Trying for two days now, does anybody have a clue?
Edit: I reduced the curl even more: Without user-agent, content-type and compression this stilll works on any laptop (running windows, also tried WSL shell), but on my Raspberries (1+3, Rasbian and ArchLinux), I receive 403. When I additionally omit the soapaction I receive error 400 everywhere.
curl 'http://192.168.178.142:55000/nrc/control_0' \
-H 'soapaction: "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey"' \
--data-binary '<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendKey xmlns:u="urn:panasonic-com:service:p00NetworkControl:1"><X_KeyEvent>NRC_MUTE-ONOFF</X_KeyEvent></u:X_SendKey></s:Body></s:Envelope>' \
-w '%{http_code}'
Update 1: verbose curl
curl -v ... result on Laptop:
* Hostname was NOT found in DNS cache
* Trying 192.168.178.142...
* Connected to 192.168.178.142 (192.168.178.142) port 55000 (#0)
> POST /nrc/control_0 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.178.142:55000
> Accept: */\*
> soapaction: "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey"
> Content-Length: 314
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 314 out of 314 bytes
< HTTP/1.1 200 OK
< CONTENT-LENGTH: 301
< Content-Type: text/xml; charset="utf-8"
< EXT:
* Server Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER is not blacklisted
< SERVER: Panasonic-VIErA/1, UPnP/1.0, Panasonic MIL DLNA SERVER
< CONNECTION: close
<
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_SendKeyResponse xmlns:u="urn:panasoniccom:service:p00NetworkControl:1"></u:X_SendKeyResponse>
</s:Body>
</s:Envelope>
* Closing connection 0
curl -v ... result on Raspberries:
* Hostname was NOT found in DNS cache
* Trying 192.168.178.142...
* Connected to 192.168.178.142 (192.168.178.142) port 55000 (#0)
> POST /nrc/control_0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 192.168.178.142:55000
> Accept: */\*
> soapaction: "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey"
> Content-Length: 314
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 314 out of 314 bytes
< HTTP/1.1 403 Forbidden
< CONNECTION: close
<
* Closing connection 0
Update 2: Traceroutes
On Windows Laptop (Powershell):
tracert 192.168.178.142
Routenverfolgung zu COM-MID1.fritz.box [192.168.178.142] über maximal 30 Hops:
1 4 ms 3 ms 3 ms COM-MID1.fritz.box [192.168.178.142]
On Raspberry Pi:
pi#raspberrypi:~ $ traceroute 192.168.178.142
traceroute to 192.168.178.142 (192.168.178.142), 30 hops max, 60 byte packets
1 COM-MID1.fritz.box (192.168.178.142) 4.545 ms 4.411 ms 4.347 ms
Update 3: HTTP Requests captured by Wireshark
From Laptop:
0000 c0 d9 62 53 1b 03 00 c2 c6 cd ce 81 08 00 45 00 ..bS..........E.
0010 02 52 00 08 40 00 80 06 12 7f c0 a8 b2 3f c0 a8 .R..#........?..
0020 b2 8e ff 53 d6 d8 9f 96 36 7f e1 55 0f 6c 50 18 ...S....6..U.lP.
0030 fa f0 4d 2d 00 00 50 4f 53 54 20 2f 6e 72 63 2f ..M-..POST /nrc/
0040 63 6f 6e 74 72 6f 6c 5f 30 20 48 54 54 50 2f 31 control_0 HTTP/1
0050 2e 31 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 .1..User-Agent:
0060 63 75 72 6c 2f 37 2e 33 35 2e 30 0d 0a 48 6f 73 curl/7.35.0..Hos
0070 74 3a 20 31 39 32 2e 31 36 38 2e 31 37 38 2e 31 t: 192.168.178.1
0080 34 32 3a 35 35 30 30 30 0d 0a 41 63 63 65 70 74 42:55000..Accept
0090 3a 20 2a 2f 2a 0d 0a 73 6f 61 70 61 63 74 69 6f : *\*..soapactio
00a0 6e 3a 20 22 75 72 6e 3a 70 61 6e 61 73 6f 6e 69 n: "urn:panasoni
00b0 63 2d 63 6f 6d 3a 73 65 72 76 69 63 65 3a 70 30 c-com:service:p0
00c0 30 4e 65 74 77 6f 72 6b 43 6f 6e 74 72 6f 6c 3a 0NetworkControl:
00d0 31 23 58 5f 53 65 6e 64 4b 65 79 22 0d 0a 43 6f 1#X_SendKey"..Co
00e0 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 33 31 ntent-Length: 31
00f0 34 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 4..Content-Type:
0100 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 application/x-w
0110 77 77 2d 66 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 ww-form-urlencod
0120 65 64 0d 0a 0d 0a 3c 3f 78 6d 6c 20 76 65 72 73 ed....<?xml vers
0130 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 ion="1.0" encodi
0140 6e 67 3d 22 75 74 66 2d 38 22 3f 3e 3c 73 3a 45 ng="utf-8"?><s:E
0150 6e 76 65 6c 6f 70 65 20 78 6d 6c 6e 73 3a 73 3d nvelope xmlns:s=
0160 22 68 74 74 70 3a 2f 2f 73 63 68 65 6d 61 73 2e "http://schemas.
0170 78 6d 6c 73 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 xmlsoap.org/soap
0180 2f 65 6e 76 65 6c 6f 70 65 2f 22 20 73 3a 65 6e /envelope/" s:en
0190 63 6f 64 69 6e 67 53 74 79 6c 65 3d 22 68 74 74 codingStyle="htt
01a0 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 p://schemas.xmls
01b0 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e 63 oap.org/soap/enc
01c0 6f 64 69 6e 67 2f 22 3e 3c 73 3a 42 6f 64 79 3e oding/"><s:Body>
01d0 3c 75 3a 58 5f 53 65 6e 64 4b 65 79 20 78 6d 6c <u:X_SendKey xml
01e0 6e 73 3a 75 3d 22 75 72 6e 3a 70 61 6e 61 73 6f ns:u="urn:panaso
01f0 6e 69 63 2d 63 6f 6d 3a 73 65 72 76 69 63 65 3a nic-com:service:
0200 70 30 30 4e 65 74 77 6f 72 6b 43 6f 6e 74 72 6f p00NetworkContro
0210 6c 3a 31 22 3e 3c 58 5f 4b 65 79 45 76 65 6e 74 l:1"><X_KeyEvent
0220 3e 4e 52 43 5f 4d 55 54 45 2d 4f 4e 4f 46 46 3c >NRC_MUTE-ONOFF<
0230 2f 58 5f 4b 65 79 45 76 65 6e 74 3e 3c 2f 75 3a /X_KeyEvent></u:
0240 58 5f 53 65 6e 64 4b 65 79 3e 3c 2f 73 3a 42 6f X_SendKey></s:Bo
0250 64 79 3e 3c 2f 73 3a 45 6e 76 65 6c 6f 70 65 3e dy></s:Envelope>
From Raspberry:
0000 c0 d9 62 53 1b 03 b8 27 eb fb b4 2f 08 00 45 00 ..bS...'.../..E.
0010 02 5e 7a 2d 40 00 40 06 d8 6f c0 a8 b2 1d c0 a8 .^z-#.#..o......
0020 b2 8e ad e4 d6 d8 af d0 76 fc ef 51 f3 ed 80 18 ........v..Q....
0030 00 e5 6f 0b 00 00 01 01 08 0a 00 09 0c d0 76 94 ..o...........v.
0040 27 05 50 4f 53 54 20 2f 6e 72 63 2f 63 6f 6e 74 '.POST /nrc/cont
0050 72 6f 6c 5f 30 20 48 54 54 50 2f 31 2e 31 0d 0a rol_0 HTTP/1.1..
0060 55 73 65 72 2d 41 67 65 6e 74 3a 20 63 75 72 6c User-Agent: curl
0070 2f 37 2e 33 38 2e 30 0d 0a 48 6f 73 74 3a 20 31 /7.38.0..Host: 1
0080 39 32 2e 31 36 38 2e 31 37 38 2e 31 34 32 3a 35 92.168.178.142:5
0090 35 30 30 30 0d 0a 41 63 63 65 70 74 3a 20 2a 2f 5000..Accept: *\
00a0 2a 0d 0a 73 6f 61 70 61 63 74 69 6f 6e 3a 20 22 *..soapaction: "
00b0 75 72 6e 3a 70 61 6e 61 73 6f 6e 69 63 2d 63 6f urn:panasonic-co
00c0 6d 3a 73 65 72 76 69 63 65 3a 70 30 30 4e 65 74 m:service:p00Net
00d0 77 6f 72 6b 43 6f 6e 74 72 6f 6c 3a 31 23 58 5f workControl:1#X_
00e0 53 65 6e 64 4b 65 79 22 0d 0a 43 6f 6e 74 65 6e SendKey"..Conten
00f0 74 2d 4c 65 6e 67 74 68 3a 20 33 31 34 0d 0a 43 t-Length: 314..C
0100 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 ontent-Type: app
0110 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 77 77 2d 66 lication/x-www-f
0120 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 65 64 0d 0a orm-urlencoded..
0130 0d 0a 3c 3f 78 6d 6c 20 76 65 72 73 69 6f 6e 3d ..<?xml version=
0140 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 "1.0" encoding="
0150 75 74 66 2d 38 22 3f 3e 3c 73 3a 45 6e 76 65 6c utf-8"?><s:Envel
0160 6f 70 65 20 78 6d 6c 6e 73 3a 73 3d 22 68 74 74 ope xmlns:s="htt
0170 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 p://schemas.xmls
0180 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e 76 oap.org/soap/env
0190 65 6c 6f 70 65 2f 22 20 73 3a 65 6e 63 6f 64 69 elope/" s:encodi
01a0 6e 67 53 74 79 6c 65 3d 22 68 74 74 70 3a 2f 2f ngStyle="http://
01b0 73 63 68 65 6d 61 73 2e 78 6d 6c 73 6f 61 70 2e schemas.xmlsoap.
01c0 6f 72 67 2f 73 6f 61 70 2f 65 6e 63 6f 64 69 6e org/soap/encodin
01d0 67 2f 22 3e 3c 73 3a 42 6f 64 79 3e 3c 75 3a 58 g/"><s:Body><u:X
01e0 5f 53 65 6e 64 4b 65 79 20 78 6d 6c 6e 73 3a 75 _SendKey xmlns:u
01f0 3d 22 75 72 6e 3a 70 61 6e 61 73 6f 6e 69 63 2d ="urn:panasonic-
0200 63 6f 6d 3a 73 65 72 76 69 63 65 3a 70 30 30 4e com:service:p00N
0210 65 74 77 6f 72 6b 43 6f 6e 74 72 6f 6c 3a 31 22 etworkControl:1"
0220 3e 3c 58 5f 4b 65 79 45 76 65 6e 74 3e 4e 52 43 ><X_KeyEvent>NRC
0230 5f 4d 55 54 45 2d 4f 4e 4f 46 46 3c 2f 58 5f 4b _MUTE-ONOFF</X_K
0240 65 79 45 76 65 6e 74 3e 3c 2f 75 3a 58 5f 53 65 eyEvent></u:X_Se
0250 6e 64 4b 65 79 3e 3c 2f 73 3a 42 6f 64 79 3e 3c ndKey></s:Body><
0260 2f 73 3a 45 6e 76 65 6c 6f 70 65 3e /s:Envelope>
Update 4: Files with captured packets
Laptop: https://drive.google.com/open?id=1P_uVc0ndGG37kizuFBZwApvQ-SePKbZd
RaspPi: https://drive.google.com/open?id=1V4-t3qi5TS8NpYeGqVXLo_zi8PxXbRnp
I have resolved the problem by resetting the factory parameters of my Panasonic TV. But I don't understand the root cause of the problem.

BitTorrent protocol can't get answers to my piece requests

I'm developing a BitTorrent client and I'm having trouble getting answers to my piece requests.
To debug, I followed a conversation between uTorrent and transmission using Wireshark and tried to imitate same conversation in my client. But it still doesn't work.
Below is an example conversation happening between my client and transmission. (my client also using -TR--- prefixed peer id, this is only for testing purposes and I'll change this)
Indented messages are coming from transmission, others are messages my client send.
Note that this conversation is not exactly same as how uTorrent and transmission would talk, because my client does not support fast extension yet. (BEP 6)
(Output is taken from Wireshark, lines starting with -- are my comments)
00000000 13 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 .BitTorr ent prot
00000010 6f 63 6f 6c 00 00 00 00 00 10 00 00 f8 9e 0d fd ocol.... ........
00000020 9c fc a8 52 d9 7a d6 af a4 4d 8f 73 ce 70 b6 36 ...R.z.. .M.s.p.6
00000030 2d 54 52 32 38 34 30 2d 36 68 61 67 76 30 73 70 -TR2840- 6hagv0sp
00000040 34 67 37 6b 4g7k
-- ^ my handshake to transmission
00000000 13 42 69 74 54 6f 72 72 65 6e 74 20 70 72 6f 74 .BitTorr ent prot
00000010 6f 63 6f 6c 00 00 00 00 00 10 00 04 f8 9e 0d fd ocol.... ........
00000020 9c fc a8 52 d9 7a d6 af a4 4d 8f 73 ce 70 b6 36 ...R.z.. .M.s.p.6
00000030 2d 54 52 32 38 34 30 2d 72 73 35 68 71 67 32 68 -TR2840- rs5hqg2h
00000040 6e 70 68 64 nphd
-- ^ transmission answers to my handshake
00000044 00 00 00 1a 14 00 64 31 3a 6d 64 31 31 3a 75 74 ......d1 :md11:ut
00000054 5f 6d 65 74 61 64 61 74 61 69 33 65 65 65 _metadat ai3eee
-- ^ my extended handshake to transmission
00000044 00 00 00 72 14 00 64 31 3a 65 69 31 65 31 3a 6d ...r..d1 :ei1e1:m
00000054 64 31 31 3a 75 74 5f 6d 65 74 61 64 61 74 61 69 d11:ut_m etadatai
00000064 33 65 65 31 33 3a 6d 65 74 61 64 61 74 61 5f 73 3ee13:me tadata_s
00000074 69 7a 65 69 31 34 37 65 31 3a 70 69 35 31 34 31 izei147e 1:pi5141
00000084 33 65 34 3a 72 65 71 71 69 35 31 32 65 31 31 3a 3e4:reqq i512e11:
00000094 75 70 6c 6f 61 64 5f 6f 6e 6c 79 69 31 65 31 3a upload_o nlyi1e1:
000000A4 76 31 37 3a 54 72 61 6e 73 6d 69 73 73 69 6f 6e v17:Tran smission
000000B4 20 32 2e 38 34 65 00 00 00 02 05 80 2.84e.. ....
-- ^ transmission's extended handshake and bitfield
000000C0 00 00 00 01 01 .....
-- ^ transmission unchokes me
00000062 00 00 00 01 02 .....
-- ^ my interested message
00000067 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ .......#
00000077 00 .
-- ^ piece request
-- no answers ...
00000078 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ .......#
00000088 00 .
-- ^ piece request again, with 10 seconds interval
-- again no answers...
00000089 00 00 00 0d 06 00 00 00 00 00 00 00 00 00 00 40 ........ .......#
00000099 00 .
-- ^ piece request again, with 10 seconds interval
-- no answers...
Any ideas what am I doing wrong?
Thanks.
EDIT: I updated my client to send unchoke just after sending interested, but I'm still having same problem...
The problem was that I was requesting a piece bigger than the total size of the torrent.
The torrent I was using has 2 files, in total of 12KB. However the piece size of the torrent is 16KB and I was requesting 16KB piece even though the torrent file has only one piece and it's 12 KB in total.
After requesting 12KB instead of 16KB, the problem was solved.

Resources