Send and detect message using cdma - networking

Suppose three devices A, B and C in a CDMA network with the following 8-bit orthogonal codes:
A = 10101010
B = 11001100
C = 10010110
The transmission power of B is twice as compared to A and C. Perform all the steps to send and
detect 00 for Sender A, 10 for Sender B and 0X for Sender C (where X means that the sender
doesn’t transmit in this interval).

Related

CRC: false positive under some circumstances

Consider two computers A and B. A has uses G and B uses G' where G' != G and of different degrees. Computer A wants to send a data D and it uses CRC for that cause.
The claim says that there couldn't be a scenario where A sends a CRC-message corresponding to data D and computer B will accept it as a valid message. Why is that?
We know that computer A sends D*2^r XOR R (r is the degree of G) and computer B divides by G'. So in other words, why can't G', accidentally, divide D*2^r XOR R?
Obviously it has something to do with the fact that deg(G) != deg(G') but I didn't figure it out.
Thanks!

Z80 register pairs

I am fairly new to the Z80 and machine code, so please don't assume I know anything.
Basically, what I want to know is this: If you load register H with a value (I'll call it y), will HL then be 0xy0? e.g. if H was loaded with 0xAF would HL be 0xAF00?
And would the same be true for loading L with y?
Thanks in advance.
The H and L 8-bit registers can be treated independently. Loading a value in H, will not affect the value in L, and vice versa. The two registers H and L can also be treated as a 16-bit register pair. The following source FIRST STEPS IN MACHINE CODE describes this.
two single register transfers, e.g.
LD H, B
LD L, C
to copy BC into
HL.
and
You can, if you wish, load a register pair directly with a single
instruction, rather than use two instructions. From last time, you
will recall that the H and L, B and C, and D and E registers can be
paired such that they effectively can hold any number between 0 and
65535 (00 to FFFF hex). C, E, and L form the low byte of the pair,
while B, D, and H are the high bytes.

Routing table interpretation

Given the following table, where the network is using 8-bit host addresses, I am asked to compute the associated range of destination host addresses for every interface. Then I am also asked about the number of addresses in every range.
Table:
prefix match Interface
00 0
010 1
011 2
10 2
11 3
I determined that I am given the prefixes of the 8-bit binary IP's and the concluded that:
00000000 to 00111111 (0-63 in decimal) uses interface 0
addresses in the range = 2 to the power of (8 - the number of bits in the prefix, so 2) = 64
01000000 to 01011111 (64-95 in decimal) uses interface 1
addresses in range = 2^(8-3) = 32
01100000 to 10111111 (96-191 in decimal) uses interface 2
addresses in range = 2^5 = 32
11000000 and higer (192+ in decimal) uses interface 3
addresses in range = 2^5 = 32
Is my reasoning correct?
The number of addresses in each range is 2(8 - prefixlen). So if the prefix has 2 bits, the number of addresses is 26 = 64.

Encryption at two levels (with a twist)

I have a scenario where I need to encrypt a document, then convert it to another format and then decrypt from that particular format converting into the format which would have gotten had we converted the original document without encryption.
In Steps -
Document D, Encryption E, Conversion C
D with E gives ED
ED converted with C gives CED
D converted with C gives CD
CED when decrypted should return CD
Does anyone know any algorithm/software/technology which help me to do this?
Thanks for the help,
Regards
In terms of encryption, this would only be possible if your encryption E was a stream cypher, and the conversion C was an exact byte to byte translation. Any change to the number of bytes (for example, different end-of-line codes) would render it impossible.
In symbolic terms:
D XOR E => ED (encryption)
ED XOR C => CED (conversion ED -> CED)
D XOR C => CD (conversion D -> CD)
CED XOR E => CD (decryption)
Much simpler to separate encryption and conversion. Only convert a decrypted version of the document.

Calculating FCS(CRC) for HDLC frame

I have the following frame:
7e 01 00 00 01 00 18 ef 00 00 00 b5 20 c1 05 10 02 71 2e 1a c2 05 10 01 71 00 6e 87 02 00 01 42 71 2e 1a 01 96 27 be 27 54 17 3d b9 93 ac 7e
If I understand correctly, then it is this portion of the frame on which the FCS is calculated:
010000010018ef000000b520c1051002712e1ac205100171006e8702000142712e1a019627be2754173db9
I've tried entering this into a number of online calculators but I cant produce 0x93ac from the above data.
http://www.lammertbies.nl/comm/info/crc-calculation.html with input type hex.
How is 0x93ac arrived at?
Thanks,
Barry
Answering rather for others who got here while searching for advice.
The key is what several points in the closely related ITU-T recommendations (e.g. Q.921, available online for quite some time already) say:
1. the lowest order bit is transmitted (and thus received) first
This legacy behaviour is in contrary to the daily life conventions where highest order digits are written first in the order of reading, and all the generic online calculators and libraries perform the calculation using the conventional order and provide optional settings to facilitate the reversed one.
Therefore, you must ask the online calculator
to reverse the order of bits in the message you've input in the "conventional" format before performing the calculation,
to reverse the order of bits of the result so that you get them in
the same order like in the message itself
Quite reasonably, some calculators offer just a single common setting for both.
This reasons the settings "reverse data bytes" and "reverse CRC result before Final XOR" recommended in the previous answer;
2. the result of the CRC calculation must be bit-inverted before sending
Bit inversion is another name of "xor by 0xffff...". There is a purpose in bit-inverting the CRC calculation result before sending it as the message FCS (the last two bytes of the message, the '93 ac' in your example).
See point 4 for details.
This reasons the setting "Final value ffff", whose name is quite misleading as it actually defines the pattern to be for xor'ed with the result of the calculation. As such operation is required by several CRC types, only the xor patterns vary from 0 (no op) through 0xfff... (complete inversion), generic calculators/libraries offer it for simplicity of use.
3. the calculation must include processing of a leading sequence of 0xffff
This reasons the point "initial value ffff".
4. on the receiving (checking) side, it is recommended to push the complete message, i.e. including the FCS, through the CRC calculation, and expect the result to be 0x1d0f
There is some clever thinking behind this:
the intrinsic property of the CRC algorithm is that
CRC( x.CRC(x) )
is always 0 (x represents the original message and "." represents concatenation).
running the complete message through the calculation rather than
calculating only the message itself and comparing with the FCS
received separately means much simpler algorithm (or even circuitry)
at the receiving side.
however, it is too easy to make a coding mistake causing a result to become 0. Luckily, thanks to the CRC algorithm intrinsic properties again,
CRC( x.(CRC(x))' )
yields a constant value independent of x and different from 0 (at least for CRC-CCITT, which we talk about here). The "'" sign represents the bit inversion as required in point 2.
First of all, CRC value is 0xac93
Use this calculator: http://www.zorc.breitbandkatze.de/crc.html
Set CRC order 16
Polynomial 1021
Initial value ffff
Final value ffff
"reverse data bytes"
"reverse CRC result before Final XOR"
Enter your sequence as:
%01%00%00%01%00%18%ef%00%00%00%b5%20%c1%05%10%02%71%2e%1a%c2%05%10%01%71%00%6e%87%02%00%01%42%71%2e%1a%01%96%27%be%27%54%17%3d%b9
Press "calculate" and you get 0xAC93
This is simple Python script for HDLC CRC calculation. You can use it for DLMS
def byte_mirror(c):
c = (c & 0xF0) >> 4 | (c & 0x0F) << 4
c = (c & 0xCC) >> 2 | (c & 0x33) << 2
c = (c & 0xAA) >> 1 | (c & 0x55) << 1
return c
CRC_INIT=0xffff
POLYNOMIAL=0x1021
DATA_VALUE=0xA0
SNRM_request=[ 0x7E, 0xA0, 0x08, 0x03, 0x02, 0xFF, 0x93, 0xCA, 0xE4, 0x7E]
print("sent>>", end=" ")
for x in SNRM_request:
if x>15:
print(hex(x), end=" ")
else:
a=str(hex(x))
a = a[:2] + "0" + a[2:]
print(a, end=" ")
lenn=len(SNRM_request)
print(" ")
crc = CRC_INIT
for i in range(lenn):
if( (i!=0) and (i!=(lenn-1)) and (i!=(lenn-2)) and (i!=(lenn-3)) ):
print("i>>",i)
c=SNRM_request[i]
c=byte_mirror(c)
c = c << 8
print(hex(c))
for j in range(8):
print(hex(c))
print("CRC",hex(crc))
if (crc ^ c) & 0x8000:
crc = (crc << 1) ^ POLYNOMIAL
else:
crc = crc << 1
c = c << 1
crc=crc%65536
c =c%65536
print("CRC-CALC",hex(crc))
crc=0xFFFF-crc
print("CRC- NOT",hex(crc))
crc_HI=crc//256
crc_LO=crc%256
print("CRC-HI",hex(crc_HI))
print("CRC-LO",hex(crc_LO))
crc_HI=byte_mirror(crc_HI)
crc_LO=byte_mirror(crc_LO)
print("CRC-HI-zrc",hex(crc_HI))
print("CRC-LO-zrc",hex(crc_LO))
crc=256*crc_HI+crc_LO
print("CRC-END",hex(crc))
For future readers, there's code in appendix C of RFC1662 to calculate FCS for HDLC.

Resources