What is the IPV4 class ? - ipv4

I'm trying to identify the classes of IPV4 IP's. I convert the first octet or block into binary and then i follow the algorithm here in the photo. My problem is when the IP starts with 7 for example then its binary is 111 and it doesn't match any of classes and another thing when i turn 47 for instance to binary (101111) then it should belong to class B but instead its class is A and i don't know why?

The binary number you have separated on each net doesn't mean the class definition, a class is defined by the network portion, for example the ip you mention that starts with 7 belongs to the A class:
7 = 00000111
The A class defines the first 8 bits as the network portion
The B class defines the fisrt 16 bits as the network portion
The C class defines the first 24 bits as the network portion
Check the following tables and let me know if you have more questions.

Related

Nand2Tetris-Obtaining Register from RAM chips

I've recently completed Chapter 3 of the associated textbook for this course: The Elements of Computing, Second Edition.
While I was able to implement all of the chips described in this chapter, I am still trying to wrap my head around how exactly the RAM chips work. I think I understand them in theory (e.g. a Ram4K chip stores a set of 8 RAM512 chips, which itself is a set of 8 RAM64 chips).
What I am unsure about is actually using the chips. For example, suppose I try to output a single register from RAM16K using this code, given an address:
CHIP RAM16K {
IN in[16], load, address[14];
OUT out[16];
PARTS:
Mux4Way16(a=firstRam, b=secondRam, c=thirdRam, d=fourthRam, sel=address[12..13], out=out);
And(a=load, b=load, out=shouldLoad);
DMux4Way(in=shouldLoad, sel=address[12..13], a=setRamOne, b=setRamTwo, c=setRamThree, d=setRamFour);
RAM4K(in=in, load=setRamOne, address=address[0..11], out=firstRam);
RAM4K(in=in, load=setRamTwo, address=address[0..11], out=secondRam);
RAM4K(in=in, load=setRamThree, address=address[0..11], out=thirdRam);
RAM4K(in=in, load=setRamFour, address=address[0..11], out=fourthRam);
}
How does the above code get the underlying register? If I understand the description of the chip correctly, it is supposed to return a single register. I can see that it outputs a RAM4K based on a series of address bits -- does it also get the base register itself recursively through the chips at the bottom? Why doesn't this code have an error if it's outputting a RAM4K when we expect a register?
It's been a while since I did the course so please excuse any minor errors below.
Each RAM chip (whatever the size) consists of an array of smaller chips. If you are implementing a 16K chip with 4K subchips, then there will be 4 of them.
So you would use 2 bits of the incoming address to select what sub-chip you need to work with, and the remaining 12 bits are sent on to all the sub-chip. It doesn't matter how you divide up the bits, as long as you have a set of 2 and a set of 12.
Specifically, the 2 select bits are used to route the load signal to just one sub-chip (ie: using a DMux4Way), so loads only affect that one sub-chip, and they are also used to pick which of the sub-chips outputs are used (ie: a Mux4Way16).
When I was doing it, I found that the simplest way to do things was always use the least-significant bits as the select bits. So for example, my RAM64 chip used address[0..2] as the select bits, and passed address[3..5] to the RAM8 sub-chips.
The thing that may be confusing you is that in these kinds of circuits, all of the sub-chips are activated. It's just that you use the select bits to decide which sub-chip's output to pass on to the outputs, and also as a filter to decide which sub-chip might perform a load.
As the saying goes, "It's turtles (or ram chips) all the way down."

Convert EM4x02 ID to Hitag2 Value

I've been working on an RFID project to produce our own RFID cards to work on our existing timeclocks and readers.
I've got most of the work done, and have been able to successfully write a Hitag2 card using the value of page 4 & 5 from another card (so basically copying the card) then changing the config bit which makes it act like an EM4x02 which allows our readers to read it.
What I'm struggling with is trying to relate the hex code on page4/5 to the output you get when scanning as an EM4x..
The values of the hitag page 4/5 are FF800000/003EDF10. This translates to 0000001EBC when read as an EM4x.
Does anybody have an idea on how this translation is done? I've tried using the methods in RFIDIOT but that doesn't seem to work for this.
I've managed to find how this is done after finding a hitag2 datasheet from 1999 (the only one I could find that explains the bits when hitag is in public mode A)
Firstly, convert the number you want on the EM4 card to hex.
Convert that hex into binary.
Split the binary into 4 bit chunks, then work out the even parity for each section and add it to the end of each chunk. (So you'll end up with 5 bits per chunk)
Then, work out the even parity of each column in the data (i.e first character of all chunks, then second etc. But ignoring the parity bit you added) and add these 4 bytes to the binary string.
Then add the correct amount of zeros at the start to ensure the data section has 50 bits.
Once you have the data section sorted, add 9 bits of 1 to the beginning (header) and a final 0 to the very end of the binary.
Your whole binary string should be 64 bits long.
Convert this to hex and split it in half. You can then write these onto pages 4/5 of a Hitag2 card.
You then need to change the configuration bit to 0x02 for the tag to work in public mode a.
Just thought I would send you the diagram of how this works.Em4X tag data

Is it possible / common sense to change a CIDR prefix to meet a certain requirement of a network?

Say for example, you have an IP address with a CIDR prefix of /27 (mask of 255.255.255.224) and are required to create 4 subnets each with an equal amount of usable host addresses, would it be commonplace / accepted to adjust the prefix to /26 (using only 2 additional
bits, leaving 6 for the Host ID) to allow for 4 subnets, each with 62 (60 usable addresses ?
Or
Is just a case of when a prefix is already set (in this case /27) you simply “get what your given” and utilise only 4 of the possible 8 subnets that can be created with the additional 3 bits and have 4 subnets, each with 32 (30 usable addresses)?
I understand the prefix denotes how many bits are considered significant for the network address with the remainder allocated for the host / node.
Thanks in advance, I am quite new to networking but feel like common sense might apply in this case?
I haven to been able to find anything that confirms or denies the possibility of doing this when required.

HTML tel: link to emergency number

How do I create a HTML link to an emergency number like 911 or 112?
The RFC says
The
phone number can be represented in either global or local
notation. All phone numbers MUST use the global form unless they
cannot be represented as such.
[Emergency numbers ("911", "112")] cannot be represented in global form and
need to be represented as a local number with a context.
From the local-context section I don't find it easy to understand what a "local-context" is, let alone what the correct one for this case is. It lists domain prefixes like houston.example.com or a numeric prefix like +1, and in one paragraph it says
A context consisting of the initial digits of a global number does
not imply that adding these to the local number will generate a valid
E.164 number. It might do so by coincidence, but this cannot be
relied upon. (For example, "911" should be labeled with the context
"+1", but "+1-911" is not a valid E.164 number.)
But the phrasing of this paragraph is again very confusing.
Is
112
now the correct way of doing it, and the fact that it is not a valid E.164 number is irrelevant?
Or is the fact that it is not a valid E.164 number a problem?
In some other places I see people using
112
And again other people recommend
112
But when I tap that link on Android, the dialer opens with the number
112;746632668398+49
The cited Section 5.1.5 the RFC states
A context consisting of the initial digits of a global number does
not imply that adding these to the local number will generate a valid
E.164 number. It might do so by coincidence, but this cannot be
relied upon. (For example, "911" should be labeled with the context
"+1", but "+1-911" is not a valid E.164 number.)
I interpret this that emergency numbers should be prefixed by their country-secific prefixes, i.e.
in the US, 911 should be used as 911
in Germany 112 should be used as 112
The rest of the paragraph is about this syntax not being compliant to the E.164 recommendation. As far as I understand, E.164 is irrelevant in this context though.

State diagram and Transition table for a Moore machine

I have drawn a mealey machine for this circuit, with two states, however I can't draw a Moore machine state diagram, I don't understand how to do this.
The circuit is as follows :
The circuit is a Moore machine with one binary input X and one binary output Y . The output Y
depends on the two values of X sampled at the two most recent clock pulses. Y should always
be the result of the XOR combination of these two input values.
So, basically, if the state is 1 and the input is 1, it goes to 0. If it is 0 and it get's a 1, then it goes to 1. It goes to 1 as long as it is the opposite of it's state.
How is this represented on a state diagram? What about a transition table?
I am referring to the actual circuit:
You can't have the output change directly when you get the input, because that would imply it is a mealy machine. In order for it to be a moore machine, there must be at least 1 clock cycle between input and relevant output.
One simple way to do this would be to take the mealy machine that you already built, and add a register either on the input line or on the output line.
check example for a moore machine to detect the pattern 0x01 here.
There are two types of finite state machines- Moore and mealy. In mealy FSM the output depends on both the internal states and the inputs. But for a moore machine the output depends only on the internal states.