https://www.activexperts.com/serial-por ... technical/ see how PDU Type is encoded.In addition, there are TP-MMS, TP-SRI, TP-UDHI, TP-RP fields. Where are their data located? How do they appear in the digital representation for an ordinary person?
Only for sended messages, not for received1. If I understand correctly, TP-SCA can be absent and taken from the SIM card itself.
you have already your reply, and is not encrypted anything at allit's unclear how the entire number is encrypted and where it is displayed,
0x91 and 0x81 do not exist (everytime use hex when the number are hex...)2. I read that the SCA number type can have several types, but I only found descriptions for 91 and 81. I also read that there are other types like....
Is not encrypted, and you are forced to check BIT by BIT or you need one "if" function for each 256 possibilities....However, I don't know how to translate bits, and it doesn't seem necessary to write a function for decoding such a small piece of information.
I would like to understand how these encrypted data will be represented in human-readable form
If you notice, one of my screenshots is taken from there. Unfortunately, I do not understand all the information in this article. And first of all, how bits are translated. That's why I asked to show what bit options are when they are arranged as ordinary numbers in the PDU texthttps://www.activexperts.com/serial-por ... technical/ see how PDU Type is encoded.
On the smsc the first "07" is the needed bytes, on the senders are the length of the number, not the bytes...Now let's talk about the sender's address field (TP-OA). Although it may resemble the SCA number at first glance, there are certain aspects that are not clear:
1. Why does the same length of the SCA number get encoded as "07," while for the sender's address it is "0B"?
It's obvious... 0x07 is 7 bytes and 0x0B are 11 characters, because 0x0B = 11...4. And how can we determine the length of an alphanumeric address in terms of the number of characters allocated for it, rather than the number of bytes?
How does it not exist? It's even mentioned in the link above. Here is a screenshot from the article.0x91 and 0x81 do not exist (everytime use hex when the number are hex...)
are BIT 10010001 and 10000001 and must be checked what each bit is.
Why do this if there are only a few such values? Perhaps even one value. In addition to "07" I have not yet met.Is not encrypted, and you are forced to check BIT by BIT or you need one "if" function for each 256 possibilities....
1) The article is incompleteI was referring to the fact that 81 and 91 don't exist because they are hexadecimal numbers, not decimals.0x91 and 0x81 do not exist (everytime use hex when the number are hex...)
are BIT 10010001 and 10000001 and must be checked what each bit is.
As I have written several times, put something before or after the number to understand the difference... 0x81 / 81H / hex 81, etc.
How does it not exist? It's even mentioned in the link above. Here is a screenshot from the article.
1) The article is incomplete, for example missing the alphanumeric value, you notice some SMS that coming from one alphanumeric string?Why do this if there are only a few such values? Perhaps even one value. In addition to "07" I have not yet met.Is not encrypted, and you are forced to check BIT by BIT or you need one "if" function for each 256 possibilities....
I haven't looked at this thread yet. After your post, I did it. But apparently again my google translator is to blame. It was about a number consisting of letters, ie like "InternetSMS" or "Freedom".you have already your reply, and is not encrypted anything at all
viewtopic.php?t=196637#p1005497
Unfortunately I don't understand when hex is used0x91 and 0x81 do not exist (everytime use hex when the number are hex...)
are BIT 10010001 and 10000001 and must be checked what each bit is.
Unfortunately, it's not obvious to me. And first of all, it is not clear when bytes are used, when something else is used. The length of the number in both cases is 11 characters. At the 12th character, we add "F" to an even number in both cases. But at the same time, for SCA, the length will be displayed as "07", and for the sender's number "0B". Perhaps because I do not understand bytes, but perhaps it is Google that translates in such a way that it cannot convey the meaning of what was said.It's obvious... 0x07 is 7 bytes and 0x0B are 11 characters, because 0x0B = 11...
I don't understand what article you are talking about. Perhaps there is described work with text numbers of the sender.10.5.4.7 (not 6, the article is also wrong)
In any case, even if we count every bit, and at the same time we want to somehow use this information, we will need an array of values in order to understand what to do with this information next. If there is no value in the array, we will have to do some default action so that the code execution does not interrupt. If we assume that we will use a maximum of two options: 91 or 81, then we also do not need to count the bits, but only make two conditions. So I don't see the point in counting bits when executing a script anyway. It is better to write down/remember the values once and work with them further.The possible total not-reserved values combination for that field are ~48. Approx, not counted exactly.
So, must be checked every BIT, or create one array of 48 or more values are one nonsense...
That is, "07" is not the length of characters, but bytes? Does "0B" count characters, not bytes?It's obvious... 0x07 is 7 bytes and 0x0B are 11 characters, because 0x0B = 11...
I understand not knowing the programming language, but at least what is a Byte you should know...That is, "07" is not the length of characters, but bytes? Does "0B" count characters, not bytes?It's obvious... 0x07 is 7 bytes and 0x0B are 11 characters, because 0x0B = 11...
If so, am I right in thinking that 7 bytes means 7 pairs of characters? That is, one pair of characters - the type of number, and 6 pairs - the length of the number? Ie 11-12 characters.
..............Updated Code here:
I know people who write programs / applications perfectly, but do not understand bits and bytes. A program is just an algorithm and syntax, and it doesn't care what information to process, even a command to brew coffee, even count bytes. Programmers don't know how to do barista work, but they can make a program to make a coffee machine work. Or a more complex example with drones. A man does not fly, but he can write a program for a drone. However, he does not need to count bytes. Only if they set such a task.I understand not knowing the programming language, but at least what is a Byte you should know...
That is, if the length is 16, then it will be 08, and if the length is 12, then it will be 06?0x is written in front to avoid ambiguity when using only symbols that could be mistaken for decimals (or even binary), for example how much is "10"? or "91"?
therefore the possible values of a Byte, in hexadecimal, range from 00 to FF,
and that's why 0x07 represents 7 Bytes, which obviously are represented by 14 characters because every single Bytes is represented with two.
You never said what 48 is on a lineThis is just a starting point for one complete function, on this function you have all needed example for decode everything inside.
:put [$PDUdecode 07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72 48]
}
:local length [:tonum "0$2"]
How many time same question?You never said what 48 is on a lineFrom the previous messages I did not understand where it came from. I understand that it has something to do with the length of the message.Code: Select all:put [$PDUdecode 07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72 48] }
Again: The length at the end is optional, if specified the validity of the PDU is calculated.Also interested in this line:Do I understand correctly that this is the second argument in the function and is somehow related to the number 48?Code: Select all:local length [:tonum "0$2"]
Can you elaborate on the syntax of this argument?
Then, you can't produce anything useful for the PDU, because it contains parts in hexadecimal, parts in mixed and parts in binary...I know people who write programs / applications perfectly, but do not understand bits and bytes. A program is just an algorithm and syntax, and it doesn't care what information to process, even a command to brew coffee, even count bytes. Programmers don't know how to do barista work, but they can make a program to make a coffee machine work. Or a more complex example with drones. A man does not fly, but he can write a program for a drone. However, he does not need to count bytes. Only if they set such a task.I understand not knowing the programming language, but at least what is a Byte you should know...
Sorry, I don't have time to read all the replies in different threads. A few hours ago I read there and answered. Now it's time to read this thread.How many time same question?
Sometimes I am amazed at the quality of Google translation. He translates so poorly that you, a smart person, did not see my clarifications about the $2 argument in my question. I made the assumption that it was him. But I did not understand its syntax, and what it means. But thanks for your clarification. Now I will know that you can merge a line not only with a dot, but also in this way.If you do not know waht $1, $2, etc, are inide one function, at least deign to read what already exists on scripting.
Someone doesn't understand someone. Again I will complain about Google translation. I clearly said that a programmer should know what he is programming, but not know everything from the very beginning, including bytes. Here is my quote:If programmers don't know the subject of what they are programming, maybe they will eventually do something that works, but they will never come up with a program worth calling it that name...
Thus, if a programmer needs to write a program for a coffee machine, he studies the coffee machine. If he needs to write a program for a machine that milks cows, he studies the process of milking cows. If he is told to write a bit-transcoding program or some other deciphering technique, he learns that technique. But the programmer is not required to initially know all this. That's why I'm trying to find people who, in a nutshell, as an ordinary person from the street, will explain to me what bytes are and how they are read.Only if they set such a task.
I have tried reading this post several times. But there is too much information for those who know what bytes are and how they are recalculated. But there is no clear explanation for the common man. I tried looking at your sample code you showed in another thread. I see that you use an offset to determine the PDU type, but I do not understand what is the start of the offset and why such an offset. You could explain in simple terms how to determine the type of PDU. At the moment, the only thing I seem to understand is that "04" is SMS-DELIVER. Maybe there is some set of ready-made values?https://www.activexperts.com/serial-por ... technical/ see how PDU Type is encoded.In addition, there are TP-MMS, TP-SRI, TP-UDHI, TP-RP fields. Where are their data located? How do they appear in the digital representation for an ordinary person?
Okay, I'll try to register in the GPT chat today@DyadyaGenya: for what it's worth, ChatGPT is way better than Google Translate at understanding important nuances of the language which is also the real strength of a language modell like GPT (as opposed to facts that shouldn't be trusted at all).
Just don't post ChatGPT generated code here, rextended will not love you after thatOkay, I'll try to register in the GPT chat today
I doubt that I will quickly figure out how this chatGPT works. Moreover, I heard that it generates code poorly, especially if the programming language is rare.Just don't post ChatGPT generated code here, rextended will not love you after that
Now let's talk about the sender's address field (TP-OA). Although it may resemble the SCA number at first glance, there are certain aspects that are not clear:
1. Why does the same length of the SCA number get encoded as "07," while for the sender's address it is "0B"?
On the smsc the first "07" is the needed bytes, on the senders are the length of the number, not the bytes...
{ :local PDUdecode do={ :local pdu [:tostr $1] :local length [:tonum "0$2"] :local return [:toarray ""] :if (!($pdu~"^[0-9A-F]*\$")) do={:error "ERROR: Only 0-9 and A-F are valid hexadecimal PDU digits."} :if (([:len $pdu] % 2) != 0) do={:error "ERROR: PDU length must be even."} :local skip (2 + ([:tonum "0x$[:pick $pdu 0 2]"] * 2)) :if ($length > 0) do={ :local PDUlength (([:len $pdu] - $skip) / 2) :if ($length != $PDUlength) do={:return "ERROR: Provided Length does not match SMS PDU part."} :set ($return->"PDUlength") $PDUlength } :local invertnibble do={ :local string [:tostr $1] :local positn 0 :local output "" :while (([:len $string] + 1) > $positn) do={ :set output "$output$[:pick $string ($positn + 1) ($positn + 2)]$[:pick $string $positn ($positn + 1)]" :set positn ($positn + 2) } :return $output } # BEGIN SMSC section :local smsc "<SIM>" :local type "<SIM>" :local smscLen [:tonum "0x$[:pick $pdu 0 2]"] :if ($smscLen != 0) do={ :set type [:tonum "0x$[:pick $pdu 2 4]"] # 0x91 = 145 :if ($type = 145) do={ :set smsc "+$[$invertnibble [:pick $pdu 4 $skip]]" :if ($smsc~"F\$") do={:set smsc [:pick $smsc 0 ([:len $smsc] - 1)]} } else={ :return "ERROR: Unexpected SMSC number type (0x[:pick $pdu 2 4])" } } :set ($return->"smsc" ) $smsc :set ($return->"smscType") $type # END SMSC section # BEGIN SMS Type section :local type [:tonum "0x$[:pick $pdu $skip ($skip + 2)]"] # 0x04 = 4 :if ($type = 4) do={ :set ($return->"SMStype") $type } else={ :return "ERROR: Unexpected SMSC number type (0x$[:pick $pdu $skip ($skip + 2)])" } :set skip ($skip + 2) # END SMS Type section # BEGIN SENDER section :local sender "" :local senderLen [:tonum "0x$[:pick $pdu $skip ($skip + 2)]"] :if (($senderLen % 2) = 1) do={:set senderLen ($senderLen + 1)} :local type [:tonum "0x$[:pick $pdu ($skip + 2) ($skip + 4)]"] # 0x91 = 145 :if ($type = 145) do={ :set sender "+$[$invertnibble [:pick $pdu ($skip + 4) ($skip + 4 + $senderLen)]]" :if ($sender~"F\$") do={:set sender [:pick $sender 0 ([:len $sender] - 1)]} } else={ :return "ERROR: Unexpected SENDER number type (0x$[:pick $pdu ($skip + 2) ($skip + 4)])" } :set ($return->"sender" ) $sender :set ($return->"senderType") $type :set skip ($skip + 4 + $senderLen) # END SENDER section # BEGIN PROTOCOL section :local protocol "" :local type [:tonum "0x$[:pick $pdu $skip ($skip + 2)]"] # 0x00 = 0 :if ($type = 0) do={ :set protocol $type } else={ :return "ERROR: Unexpected PROTOCOL number type (0x$[:pick $pdu $skip ($skip + 2)])" } :set ($return->"protocol") $protocol :set skip ($skip + 2) # END PROTOCOL section # BEGIN CLASS section :local class "" :local type [:tonum "0x$[:pick $pdu $skip ($skip + 2)]"] # 0x00 = 0 :if ($type = 0) do={ :set class $type } else={ :return "ERROR: Unexpected CLASS number type (0x$[:pick $pdu $skip ($skip + 2)])" } :set ($return->"class") $class :set skip ($skip + 2) # END CLASS section # BEGIN DATETIME section :local datetime [$invertnibble [:pick $pdu $skip ($skip + 12)]] :if ([:tonum "$[:pick $datetime 0 2]"] > 39) do={:set datetime "19$datetime"} else={:set datetime "20$datetime"} :local separators {"";"-";"-";" ";":";":"} :local positn -1 :local output "" :while (13 > $positn) do={ :set output "$output$[:pick $datetime ($positn + 1) ($positn + 2)]" :if (($positn % 2) = 0) do={:set output "$output$($separators->($positn / 2))"} :set positn ($positn + 1) } :set ($return->"datetime") $output :set skip ($skip + 12) # END DATETIME section # BEGIN TIMEZONE section :local tza [:tonum "0x$[:pick $pdu ($skip + 1) ($skip + 2)]"] :local tzb [:tonum "0x$[:pick $pdu $skip ($skip + 1)]"] :local tzs "+" ; :if (($tza & 0x8) = 0x8) do={:set tzs "-"} :set tza ($tza & 0x7) :local tzmin ((($tza * 10) + $tzb) * 15) :set ($return->"tzminutes") [:tonum "$tzs$tzmin"] :local tzhou ($tzmin / 60) ; :if ($tzhou < 10) do={:set tzhou "0$tzhou"} :set tzmin ($tzmin % 60) ; :if ($tzmin < 10) do={:set tzmin "0$tzmin"} :set ($return->"timezone") "GMT$tzs$tzhou:$tzmin" :set skip ($skip + 2) # END TIMEZONE section # BEGIN SMSlength section :local SMSlength [:tonum "0x$[:pick $pdu $skip ($skip + 2)]"] :set ($return->"SMSlength") $SMSlength :set skip ($skip + 2) # END SMSlength section # BEGIN SMSPDU section :local smspdu [:pick $pdu $skip [:len $pdu]] :set ($return->"SMSPDU") $smspdu # END SMSPDU section :return $return } :put [$PDUdecode 07912180958739F1040B917120069876F000009140503223218A21D4F29C0E6A97E7F3F0B90CA2BF41412A68F86EB7C36E32885A9ED3CB72 48] }The length at the end is optional, if specified, the validity of the PDU is calculated.
Fortunately, I found an easy way to convert bits into regular numbers. It turns out that in MikroTik, there is a function for that:I understand not knowing the programming language, but at least what is a Byte you should know...
A Byte consists of 8 bits ranging from 00000000 to 11111111, because bits can only have 2 values, either 0 or 1,
this so that there are 256 possible combinations,
:put [ :tonum ( "0x" . "bits" ) ]
They don't make anything easy. Section 9.2.3.11 of the Rel 16 SMS spec:For example, two dates are provided: 22112051314180 and 32501031613521. Ideally, the first date should be interpreted as 22/11/02 15:13:41 with an 08 time zone offset, and the second date as 23/05/01 13:16:53 with a 12 time zone offset. However, according to the PDUspy program, the first date is displayed as 02.11.22 15:13 GMT+2.00, and the second date as 01.05.23 13:16 GMT+3.00. Both dates are considered correct by the program.
How do you actually convert the time zone?
See https://www.etsi.org/deliver/etsi_ts/12 ... 60000p.pdf9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
The TP-Service-Centre-Time-Stamp field is given in semi-octet representation, and represents the local time in the following way:
Year, Month, Day, Hour, Minute, Second, Time Zone (2 semi-octets each)
The Time Zone indicates the difference, expressed in quarters of an hour, between the local time and GMT. In the first of the two semi-octets, the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field) represents the algebraic sign of this difference (0: positive, 1: negative).
Honestly, I would prefer not to deal with these octets. I would prefer a simpler explanation.See https://www.etsi.org/deliver/etsi_ts/12 ... 60000p.pdf9.2.3.11 TP-Service-Centre-Time-Stamp (TP-SCTS)
...(bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field) represents the algebraic sign of this difference (0: positive, 1: negative).
PDU are all octet, you want to take a bath without touch the water...Honestly, I would prefer not to deal with these octets. I would prefer a simpler explanation.
To create, we need to understand why.Create one array with all 256 possible values with corresponding real value...
+----+--------+----------------------------------------+
|04 | Value | Explanation |
+----+--------+----------------------------------------+
| | | |
| 1. | = 0 | TP-MTI: SMS-DELIVER (since 0) |
| 2. | = 0 | TP-MMS: Messages exist (since 0) |
| 3. | = 0 | |
| 4. | = 0 | |
| 5. | = 0 | |
| 6. | = 1 | TP-SRI: Report will be sent (since 1) |
| 7. | = 0 | TP-UDHI: User Data block contains only |
| | | message (since 0) |
| 8. | = 0 | TP-RP: No reply path requested (since 0) |
+----+--------+----------------------------------------+
+----+--------+----------------------------------------+
| 40 | Value | Explanation |
+----+--------+----------------------------------------+
| | | |
| 1. | = 0 | TP-MTI: SMS-DELIVER (since 0) |
| 2. | = 1 | TP-MMS: No message (since 1) |
| 3. | = 0 | |
| 4. | = 0 | |
| 5. | = 0 | |
| 6. | = 0 | TP-SRI: No report requested (since 0) |
| 7. | = 0 | TP-UDHI: User Data block contains only |
| | | message (since 0) |
| 8. | = 0 | TP-RP: No reply path requested (since 0) |
+----+--------+----------------------------------------+
+----+--------+----------------------------------------+
| 44 | Value | Explanation |
+----+--------+----------------------------------------+
| | | |
| 1. | = 0 | TP-MTI: SMS-DELIVER (since 0) |
| 2. | = 1 | TP-MMS: No message (since 1) |
| 3. | = 0 | |
| 4. | = 0 | |
| 5. | = 0 | |
| 6. | = 1 | TP-SRI: Report will be sent (since 1) |
| 7. | = 0 | TP-UDHI: User Data block contains only |
| | | message (since 0) |
| 8. | = 0 | TP-RP: No reply path requested (since 0) |
+----+--------+----------------------------------------+
+----+--------+----------------------------------------+
| 60 | Value | Explanation |
+----+--------+----------------------------------------+
| | | |
| 1. | = 0 | TP-MTI: SMS-DELIVER (since 0) |
| 2. | = 1 | TP-MMS: No message (since 1) |
| 3. | = 1 | |
| 4. | = 0 | |
| 5. | = 0 | |
| 6. | = 0 | TP-SRI: No report requested (since 0) |
| 7. | = 0 | TP-UDHI: User Data block contains only |
| | | message (since 0) |
| 8. | = 0 | TP-RP: No reply path requested (since 0) |
+----+--------+----------------------------------------+
TPDU Fields: https://en.wikipedia.org/wiki/GSM_03.40 - TP-MTI M M M M M M 2 bits Message Type IndicatorBut if we take two bits, then everything becomes clear.
Only now I'm starting to understand what it's all about.10.5.4.7 (not 6, the article is also wrong)
Possible plausible values used only on SMS (read the full guide to understand what are)...
[…]
************************
about 40 0D D0 4669B1487C3601
************************
0x40 type
0x0D on decimal is... 13 because for store seven 7-bit GSM-7 characters are needed 13 nibble (half byte), [for store 7 bit, each 8 bytes, one less byte is required]
and because the nibble can't be one odd number, the last nibble is unused, but is still required 13+1 nibble = 7 bytes and 46/69/B1/48/7C/36/01 is 7 bytes long...
0xD0 is the coding: binary 1101 - 0000 = PDU encoded name with GSM-7 alphabet
4669B1487C3601 = 0x64961B84C76310 = binary 01100100100101100001101110000100110001110110001100010000 (notice the unused last nibble / 4 bits)
and the 7-bit 0x64 0x96 0x1B 0x84 0xC7 0x63 0x10 converted to 8-bit GSM-7 is 0x46 0x52 0x45 0x45 0x44 0x4F 0x4D,
and 8-bit GSM-7 0x46 0x52 0x45 0x45 0x44 0x4F 0x4D converted to readable CP 1252 is....
FREEDOM
[…]
The situation with the explanation of the time zone field is repeated. I had to ask a lot of questions to get a description for the average person. Although I have already begun to understand bits and bytes a little, questions still remain. And your explanation does not shed any light on them.instead of constantly asking the same questions in a circle, it would be enough for you to read what has already been written...