Octet String: What is it?

Networking

Networking Problem Overview


I am starting to look into some network programming concepts for a project I am about to take over, and I keep running into this concept of an octet string. Can anyone out there provide some feedback into what this is, and how it relates to network programming?

Networking Solutions


Solution 1 - Networking

Octet = byte.

Octet string = sequence of bytes.

Also, see Wikipedia.

Solution 2 - Networking

"Octet" is standardese for "8-bit byte". It's supposed to be a less ambiguous term compared to just "byte", because some platforms have bytes of different width (not sure if there are any are still remaining, but they used to exist).

Solution 3 - Networking

Suppose a representation of binary 00000000 to 11111111 as 0x00 to 0xFF in hexadecimal. Then the octetString is simply 00 to FF.

Combining several octets to a string is then like 0x00 0x01 0x02 ... or simply 000102.. as an octetstring.

Binary files can be encoded into octetstrings and sent from a webbclient to a server in the form of an ASCII-string containing the 0-F alphabet, like a8b9457fc6e3e410589f or it's capitals. There are javascript using BASE-64 encoding used to store pictures in Strings. The larger alphabet, in this case(I think ) A-Z,a-z,0-9, the less data needs to be transferred. every octet has 256 different possible values, and are to be stored in an alphabet of 62 letters, clearly one needs to use more than one letter / octet. Possibly the theoretical number is proportional to log62(256).

The conclusion is that improved readability takes more space than it's binary version, in the octetstream example it's twice as long since each ascii char is eight bits and 2 chars (16 bits) represent an octet which is eight bits. Quite inefficient.

Solution 4 - Networking

octet string:

it is representation of information in the limited 8 bit mode. During transferring the data from a point of electronics device to another point of device or any other device it need to convert them into package of minimum size. So it is used to divide the main data in small and system understandable. eg: So the integer 2680, in binary 101001111000 will be converted into that 7-bit format as follows:

Remaining integer-------------------encoded bytes

101001111000------------------------

10100-------------------------------01111000

0-----------------------------------11111000&00010100

Which is represented as (120) (20) separately as decimal. then the divide 120 by 16 an store as result = 7 & reminder = 8 again divide 20 by 16 an store as result = 1 & reminder = 4

the new form of number is 0X78 + 0X14

here 78 & 14 are Octet String.

to encode them to Normal stage: ((16*7)+8)128^0+((161)+4)*128^1 = 2680

I think it is the better explanation, but still i am searching more about it. Please help me to get about the alphabets. I think it depends on its ASCII value.

Solution 5 - Networking

A group of 8 bits in a computer is called an octet. A byte is the same for most practical purposes, but does not equal 8 bits on all computer architectures. More can be found here .. Link

Solution 6 - Networking

Octet is the term to mention 8 bit data in computer. Byte is the term to mention number of bit required to encode a string character in computer.

Octet is always 8 bits. But Byte size varies depends on the hardware. Most of the system is supporting ASCII way of encoding strings. In those machines Byte size is eight bits. Some of the unicode supporting hardware is using 16bits as one Byte.

Solution 7 - Networking

A variable-length sequence of octets, as in Abstract Syntax Notation One (ASN.1), is referred to as an octet string.

Solution 8 - Networking

The term "octet" is used to avoid ambiguity, because some old computers had different numbers of bits per byte.

Unlike what the name suggests, this data type is not limited to string values but can store any byte based data type (including binary data).

Below is a Java based class that tries to convert a Decimal to its OctetString.

public class deboctetstring {

private String findOctet (int num) {

    int rem;
    String output ="";
    char ind[] = {0,1,2,3,4,5,6,7};
    while (num > 0) {
     
        rem = num%8;
        output = ind[rem] + output;
        num = num/8;

    }  
    
    return output;
}

public static void main(String[] args) {
    System.out.println("Start octet test");
    deboctetstring deboct = new deboctetstring();
    int x = 72;
    String octetval = deboct.findOctet(x);

    System.out.println("Octet Value of Decimal "+ x + " is: "+ octetval );
}

}

Solution 9 - Networking

Here is a python3 Code for the conversion of decimal to OctetString: Very easy

Number = 2680
Bin = format(Number, 'b')
Sp = [hex(int(Bin[::-1][i:i+7][::-1],2)) for i in range(0, len(Bin), 7)]
print(Sp)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCraig HView Question on Stackoverflow
Solution 1 - NetworkingSøren LøvborgView Answer on Stackoverflow
Solution 2 - NetworkingPavel MinaevView Answer on Stackoverflow
Solution 3 - Networkinguser1165316View Answer on Stackoverflow
Solution 4 - NetworkingBiswadeb PandaView Answer on Stackoverflow
Solution 5 - NetworkingThunderboltzView Answer on Stackoverflow
Solution 6 - NetworkingrashokView Answer on Stackoverflow
Solution 7 - NetworkingAnkit BatraView Answer on Stackoverflow
Solution 8 - NetworkingDebView Answer on Stackoverflow
Solution 9 - NetworkingSadegh KarimiView Answer on Stackoverflow