IP Subnetting Tutorial (Classless) – With Interactive Examples and Simulation 5

Q1. What is classless IP address?

Answer: Classless is also called IP subnetting. It divides classful network addresses into smaller networks (subnet). The rules are simple: – In classful addressing scheme, a 32 bit address is divided into Network ID and Host ID in 8-bIt boundary:

Class Network_ID Host_ID Examples……………..Leftmost_byte_range(a.b.c.d)

A……….8 bit……. 24 bit…..,…………0~127

B………16 bit…… 16 bit……,…..128~191

C……. 24 bit……… 8 bit……,…192~223

– Classless IP allows more left bits for network ID (and fewer bits for host ID). The number of bits used by

network ID is called network mask. For example, a.b.c.d/m says “network ID is the leftmost m bit.” – Examples of classful and classless addresses:

IP address Mask Class? Network address Network ID Host ID Number of hosts in this network /8 class A 100 4.5.6 16,777,216 /16 classless 100.4 5.6 65,536 /24 classless 100.4.5 6 256 /25 classless 6 128

Q2. Why classless?

Answer: Using fixed boundary to allocate bits for network ID and hosts ID results side effects: IP address starvation. Consider this example: A network has 100 computers to be connected to Internet. They are using a class C network Then the network grows to 500 computers. It needs a class B network, say However, covers 65,536 class B IP addresses. This network only uses 500 of them. 65,036 IP addresses are wasted. This causes the shortage of IP address due classful addressing scheme’s fixed networ/host boundary. This problem can be solved by classless addressing. For example, allows 512 host ID. It covers addresses

Q3. How to subnetting and creates network ID crossing byte boundary?

Answer: Subnetting uses network mask to allocate leftmost bits for network ID. The rules are simple: – Start with a classful address (class A, B, or C). – Add more bits to the classful network ID bits. Class B uses leftmost 16 bits for network ID. Its mask is /16. With classless addressing, the network mask for class B derived network can be /16~.31. – For example, is a class B network address. Its default mask is /16. It covers 65,536 addresses. is a classless subnet derived from class B network. Its mask is /24 and contains 256 addresses. is a classless subnet derived from a class B network. Its mask is /25 and has 128 addresses. The table below presents classful and classless addresses in binary form:

Network ID/Mask Binary form (32 bits) Network ID/class Number of host ID and range

– is a class B address, network ID 150.1 (16 bit), contains 65,356 hosts, (, Its binary presentation is 10010110. 00000001.00000000.00000000

– is classless derived from class B, network ID 150.1.2 (24 bits), contains 256 host addresses ( ). Its binary form is 10010110. 00000001.00000010.00000000.

– is classless derived from class B, network ID is (25 bit), contains 128 host addresses ( its binary form is 10010110. 00000001.00000010.10000000

Q4. Can we subnetting to create Answer: No. Subnetting starts with classful address scheme. is a class B address (150 is within class B range: 128~191). Class B network mask is /16. Subnetting a class B network address can only use masks to reduce the size of network, or increase the mask. /16~/21 are allowed. /1~/15 are not allowed.

Q5. How does a router lookup a classless IP address?

Answer: Let’s use examples to explain router’s operations: 1) When R1 receives ping sent by Jack, it compares ping’s destination IP address ( with destination networks listed in routing table.

–’s left most 8 bit is 150, not 100. Not a match.

–’s left most 16 bit is 150.1. It’s a match. R1 forwards ping to 2) When R2 receives ping, it compares ping’s destination IP address ( with routing table’s destination networks. -’s left most 24 bit is 150.1. 2, not 150.1.0. Not a match.

-’s left most 24 bit is 150.1. 2, not 150.1.1. Not a match.

-’s left most 24 bit is 150.1. 2. It’s a match. R2 forward ping to network 3) When R3 receives ping, it compares ping’s destination IP address ( with routing table. -’s left most 25 bit is 2, not, Not a match.

–’s left most 25 bit is A match. R3 forwards ping to Rose.

Note: This example is more clear if read together with topology from the companion simulation.

This article is the FAQ of an interactive simulation. You may get more clear concepts by playing the simulation with visualized topology, packets, table. It is located under External links.

Source by Ishun Chang

RS-232 Tutorial – 3 Easy Steps to Understand and Control Your RS232 Devices

Step 1: Understand RS-232 Connections & Signals

-RS-232C, EIA RS-232, or simply RS-232, refers to the same standard defined by the Electronic Industries Association in 1969 for serial communication.

-DTE and DCE

-DTE stands for Data Terminal Equipment. A computer is a DTE. DCE stands for Data Communication Equipment. A modem is a DCE.

-DTE normally comes with a Male Connector, while DCE comes with a Female Connector. However, that is not always true. Use the simple way below to confirm:

Measure Pin 3 and Pin 5 of a DB-9 Connector with a Volt Meter, if you get a voltage of -3V to -15V, then it is a DTE device. If the voltage is on Pin 2, then it is a DCE device.

Note: The result for a DB-25 Connector is reversed (Please refer to DB-9 to DB-25 conversion table below).

RS-232 Pinouts (DB-9)

A male DB-9 connector viewed from the front. Reverse or back view of male connector for Female Connector.

DTE Pin Assignment (DB-9) DCE Pin Assignment (DB-9)

1 DCD Data Carrier Detect 1 DCD Data Carrier Detect

2 RxD Receive Data 2 TxD Transmit Data

3 TxD Transmit Data 3 RxD Receive Data

4 DTR Data Terminal Ready 4 DSR Data Set Ready

5 GND Ground (Signal) 5 GND Ground (Signal)

6 DSR Data Set Ready 6 DTR Data Terminal Ready

7 RTS Request to Send 7 CTS Clear to Send

8 CTS Clear to Send 8 RTS Request to Send

9 RI Ring Indicator 9 RI Ring Indicator

DB-9 to DB-25 Conversion

DB-9 DB-25 Function

1 8 DCD Data Carrier Detect

2 3 RxD Receive Data

3 2 TxD Transmit Data

4 20 DTR Data Terminal Ready

5 7 GND Ground (Signal)

6 6 DSR Data Set Ready

7 4 RTS Request to Send

8 5 CTS Clear to Send

9 22 RI Ring Indicator

RS-232 Connections

A straight-through cable is used to connect a DTE (e.g. computer) to a DCE (e.g. modem), all signals in one side connected to the corresponding signals in the other side in a one-to-one basis.

A crossover (null-modem) cable is used to connect two DTE directly, without a modem in between. They cross transmit and receive data signals between the two sides and there are many variations on how the other control signals are wired, below is one of them:

Straight-through (DB-9) Crossover (Null-Modem) (DB-9)


1 DCD ——- DCD 1 1 DCD DCD 1

2 RxD ——- TxD 2 2 RxD ——- TxD 3

3 TxD ——- RxD 3 3 TxD ——- RxD 2

4 DTR ——- DSR 4 4 DTR ——- DSR 6

5 GND ——- GND 5 5 GND ——- GND 5

6 DSR ——- DTR 6 6 DSR ——- DTR 4

7 RTS ——- CTS 7 7 RTS ——- CTS 8

8 CTS ——- RTS 8 8 CTS ——- RTS 7

9 RI ——- RI 9 9 RI RI 9

Null-Modem (Model: CVT-Null-1)

RS-232 Signals

RS-232 Logic Waveform (8N1)

The graphic above illustrates a typical RS-232 logic waveform (Data format: 1 Start bit, 8 Data bits, No Parity, 1 Stop bit). The data transmission starts with a Start bit, followed by the data bits (LSB sent first and MSB sent last), and ends with a “Stop” bit.

The voltage of Logic “1” (Mark) is between -3VDC to -15VDC, while the Logic “0” (Space) is between +3VDC to +15VDC.

RS-232 connects the Ground of 2 different devices together, which is the so-called “Unbalanced” connection. An unbalanced connection is more susceptible to noise, and has a distance limitation of 50 ft (which is around 15 meters).

Step 2: Learn about the Protocol

-A protocol is one or a few sets of hardware and software rules agreed to by all communication parties for exchanging data correctly and efficiently.

-Synchronous and Asynchronous Communications

-Synchronous Communication requires the sender and receiver to share the same clock. The sender provides a timing signal to the receiver so that the receiver knows when to “read” the data. Synchronous Communication generally has higher data rates and greater error-checking capability. A printer is a form of Synchronous Communication.

Asynchronous Communication has no timing signal or clock. Instead, it inserts Start/Stop bits into each byte of data to “synchronize” the communication. As it uses less wires for communication (no clock signals), Asynchronous Communication is simpler and more cost-effective. RS-232/RS-485/RS-422/TTL are the forms of Asynchronous Communications.

Drilling Down: Bits and Bytes

Internal computer communications consists of digital electronics, represented by only two conditions: ON or OFF. We represent these with two numbers: 0 and 1, which in the binary system is termed a Bit.

A Byte consists of 8 bits, which represents decimal number 0 to 255, or Hexadecimal number 0 to FF. As described above, a byte is the basic unit of Asynchronous communications.

Baud rate, Data bits, Parity, and Stop bit

RS-232 Logic Waveform (8N1)

The baud rate is the communication speed that measures the number of bit transfers per second. For example, 19200 baud is 19200 bits per second.

Data bits are a measurement of the actual data bits in a communication packet. For example, the above graphic shows eight (8) data bits in a communication packet. A communication packet refers to a single byte transfer, including Start/Stop bits, Data bits and Parity. If you are transferring a standard ASCII code (0 to 127), 7 data bits are enough. If it is an extended ASCII code (128 to 255), then 8 data bits are required.

Parity is a simple way to error-check. There are Even, Odd, Mark and Space indicators. You can also use no parity. For Even and Odd parity, the serial port sets the parity bit (the last bit after the data bit) to a value to ensure that the data packet has an Even or Odd number of logic-high bits. For example, if the data is 10010010, for Even parity, the serial port sets the parity bit as 1 to keep the number of logic-high bits Even. For Odd parity, the parity bit is 0 so that the number of logic-high bits is Odd. Mark parity simply sets the parity bit to logic-high and Space sets the parity bit to logic-low, so that the receiving party can determine if the data is corrupted.

Stop bits are used to signal the end of a communication packet. This also helps to synchronize different clocks on the serial devices.

Handshaking (Flow Control)

Handshaking is also called “Flow Control”. The main purpose of Handshaking is to prevent receiver overloading. By using Handshaking signals, receivers will be able to tell the sending device to pause data transmission if the receiver is overloaded. There are three types of handshaking: Software handshaking, Hardware handshaking and Both.

Software handshaking uses two control characters: XON and XOFF. The receiver sends these control characters to pause transmitter during communication. XON is decimal 17 and XOFF is decimal 19 in the ASCII chart. The drawback of Software handshaking is that these two control characters can not be used in data. This is quite important when you are transmitting Binary data as you might need to use these two codes in your data.

Hardware handshaking makes use of actual hardware lines, such as RTS/CTS, DTR/DSR, and DCD/RI (for modem).

In DTE/DCE communication, RTS (Request to Send) is an output on the DTE and input on the DCE. CTS (Clear to Send) is the answering signal coming from the DCE. Before sending a data, the DTE asks permission by setting its RTS output to high. No data will be sent until the DCE grants permission by using the CTS line.

The DTE uses the DTR (Data Terminal Ready) signal to indicate it is ready to accept information, whereas the DCE uses the DSR signal for the same purpose. DTR/DSR are normally ON or OFF for the whole connection session (e.g. Off-hook), while RTS/CTS are ON or OFF for each data transmission.

DCD (Data Carrier Ready) is used by the modem when a connection has been established with remote equipment, while RI (Ring Indicator) is used by the modem to indicate a ring signal from telephone line

Data formats (Binary, Hex, Dec, Oct, and ASCII)

Serial devices use Binary for communication, which consists of just two unique numbers: 0 and 1. Binary is the Base-2 numbering system. One byte of data consists of 8 binary digits, from 0000 0000 to 1111 1111.

Hexadecimal is the base-16 system, which consists of 16 numbers: 0 to 9 and the letters A to F (decimal number 15). The Hexadecimal numbering system is useful because it can represent every byte as two consecutive hexadecimal digits, and it is easier for humans to read Hexadecimal numbers than Binary numbers. Most of the manufacturers use Hexadecimal in their protocol documentation. It is simple to convert a value from Hexadecimal to Binary. Just translate each Hexadecimal digit into its 4-bit binary equivalent. E.g. Hexadecimal number F3 equals Binary number 1111 0011.

Octal refers to the base-8 numbering system, which uses just eight unique symbols (0 to 7). Programmers often use Octal format because it is relatively easy for people to read and can easily be translated into binary format: each Octal digit represents 3 binary digits. E.g. Octal number 73 equals to Binary number 111 011.

Decimal refers to numbers in base 10, which is the numbering system we use most in everyday life. It’s not as easy as Hexadecimal and Octal to converter Decimal to Binary number, but it is easier for us to understand Decimal.

ASCII (American Standard Code for Information Interchange) is a character encoding based on the English alphabet. ASCII codes (both readable and unreadable) are widely used in communications, such as Modem communications. Letters A to Z and numbers 0 to 9 are readable ASCII codes. Some ASCII codes are unreadable, such as the control codes: XON and XOFF, which are used in Software flow control.


Many serial protocols use checksum (additional bytes added at the end of the data string) to check the data integrity, as errors might occur during data transmission.

There are many types of checksum, from the simplest uses of it in Modula or BCC to sophisticated CRC calculation. Using Modula as an example, we learn that before data transmission, the sender adds all command bytes together then mod it by 255 (decimal) to get an additional byte. This is to be added at the end of the command string. When the receiver receives the command string, it will first check the added byte to see whether data remain unchanged or not. If that is the case, it will accept the data, and if not, it will ask the sender to resend the data.

Examples of protocol commands

A protocol command is a data string sent from one serial device (e.g. a Computer) to another (i.e. a Modem). Here are some examples:

ASCII command example: ATI1 to query Modem manufacturer’s information. (Note: are the control codes: Carriage Return and Line Feed)

Convert the command string above to Hexadecimal and it becomes:

41 54 49 31 0D 0A

Convert the command string above to Decimal and it becomes:

065 084 073 049 013 010

Convert the command string above to Octal and it becomes:

101 124 111 061 015 012

Convert the command string above to Binary and it becomes:

01000001 01010100 01001001 00110001 00001101 00001010

Step 3: Start controlling your RS-232 devices by using 232Analyzer

-232Analyzer is an Advanced Serial Port (protocol) Analyzer software, which allows you to control/debug, monitor/sniff serial devices (RS-232/RS-485/RS-422/TTL) right from your PC.

-232Analyzer is a shareware, the FREE version has some limitation but is more than enough to test and control your serial devices. Click here to download a FREE copy.

Checksum calculation

232Analyzer comes with a Checksum calculator, which allows you to calculate the complicated checksum byte in seconds, here is an example:

Suppose that you are controlling a projector, and the projector protocol uses xOR to get the additional checksum byte, the command string to turn ON the projector is: “1A 2B 3C” plus the Checksum byte. Use the following procedures to calculate the Checksum byte:

1. Select Hex as an operands format

2. Select xOr as an operator

3. Key in the command string and append a comma (,) after each byte of command code: e.g. 1A,2B,3C,

4. Click on the “Calculate” button and you will get the result of 0D (0 is omitted)

Select COM port and Setup communication formats

From the toolbar (as shown above), you can choose the COM port that is connected to the projector (i.e. Port 5), the Baud rate (i.e. 19200 bps), the Data bit (i.e. 8), the Parity (i.e. Even) and the Stop bit (i.e. 1).

Note: After you have set up the correct communication formats (they must match with the projector’s COM port settings), click on the “Connect” button on the left to activate the COM port.

Setup Flow control

You can set up the flow control from the window above. It could be either Software (XON/XOFF), Hardware (RTS/CTS), Both (Software + Hardware), or None.

Control your RS-232 devices

1) Control / Monitor Line States

232Analyzer allows you to control / monitor line states of your COM ports.

1. Line states of RTS and DTR will be toggled when the respective LED is clicked, you can use a voltage-meter to verify the changes, you should get +6V to +15V when the line state is ON, and -6V to -15V when the line state is OFF.

2. Other line states can be monitored through the Virtual LEDs, such as RX, TX, DSR, CTS, DCD and RI.

2) Send / Receive commands

Use the above example to control a projector (turn ON the projector), key in the complete command string “1A,2B,3C,0D,” into the Send_Command_Pane as shown above (note: You need to add a “,” sign after each command code), and then click on the “Send” button…

Congratulations! You just controlled a RS-232 device by yourself!


1) In the FREE version, Hex mode is not available. You can use Decimal format to send out the command string: “26,43,60,13,”

2) You can use any RS-232 device for testing, as long as you know the protocol commands.


Source by Anson Zhuang

VB .NET Card Shuffling – A Tutorial on Random Card Allocation

This article deals with the concept of shuffling cards for a computer version of a normal 52 card deck card game. I developed my own algorithm for shuffling and dealing cards to use in my card games. I am sure it is not the most elegant nor is it the best. Therefore, I thought it would be good to check against some of the ideas presented in different forums and articles available. I did find several good ways to accomplish this and some better than mine. This was not a surprise for me. However, I was dumbfounded by the sheer number of times that people asked this question and the number of methods shown in reply that were either not random or had errors. I felt compelled to write this article in order to show one manner in which to accomplish the task and as a warning to verify any method you find on the web before implementing.

To start, you must find a way to generate random numbers. There are several manners to do this. You can even create your own method. If you are like me, you have better things to do. I just used the Random class available in VB .NET. You can access this class by defining a variable as New Random(). You can then access random numbers by using the .Next function of the class (ie Dim RandomNumbers As New Random() then RandomNumbers.Next(0,52)). You will notice the arguments of the Next function. I have chosen these to provide integers from 0 to 51. Your lower bound is the first number and is inclusive of that number. If your lower bound is zero, it can be omitted. Your upper bound is one less than the second number as it is not inclusive. Since I am using an array of integers to represent my deck and array indices start at zero, I want numbers from 0 to 51.

Now that we have the random number generator figured out, it is time to figure out how to implement it into our shuffling process. I have included the code I used below. I include this algorithm in a function. You will see reference to an array cards(index). I have defined this variable outside of the function in order to use it throughout the program. It was defined as: Dim cards(51) as Integer.

Sample Code:

Dim shuffleCount As Integer

Dim currentCard As Integer

Dim RandomNumbers As New Random()

Dim MyRandomNumber As Integer

For counter = 0 To 51

cards(counter) = counter


For shuffleCount = 1 To 10000

MyRandomNumber = RandomNumbers.Next(52)

currentCard = cards(0)

For counter = 1 To MyRandomNumber

cards(counter – 1) = cards(counter)


cards(MyRandomNumber) = currentCard


This code is actually not very sophisticated. I first load the cards into the deck represented by the card number in the cards.dll library. I chose to keep the card number as is in the cards array and then separate it into face and suit as needed. Next, I get to the task of shuffling. In essence, I simply take the bottom card of the deck and place it at a random point in the deck. I do this a total of ten thousand times. The number of times is arbitrary. However, it should be enough times to shuffle the deck thoroughly and not so many that the user is waiting on you.

That is all there is to it. I hope this article helps you to get off to a good start in programming your own VB.Net card game.

Source by M D Stephens

Java Tutorial – What Is Object Oriented Programming in Java?

Java is termed an Object Oriented language. So, exactly what does Object Oriented indicate? It signifies that the foundations of virtually any computer program built-in Java may very well be imagined in terms of Objects. A good example of this idea is to take a look at a number sample business requirements for a product. Imagine that we are actually tasked with developing a computer program which should manage a huge public library system. This system will have to account for the whole set of branches belonging to the libraries, each of the materials that might be contained in the branches, in addition to any individual visitors that may would like to borrow books in the library’s branch.

First of all we could begin doing is look at these specifications and spot each of the words which happen to be nouns. For the record, a noun is really a person, place or thing. Thus, when you assess these specifications we discern the foregoing nouns:

1) Library

2) Book

3) Branch

4) Customer

All of these phrases definitely symbolize Objects in Java. That is, fundamentally, Object Oriented programming (aka O-O programming). What we might now go about doing, is just transfer these four Objects on to a single piece of old fashioned paper, and begin to find what types of attributes each one of these Objects possess What do I mean by attributes? Okay, in O-O development it is often known as recognizing the “has a” relationships. Here is an example, a Branch “has an” address, a Book “has a” title, a Customer “has a” designation. We could map out all of the significant attributes that all of these Objects have, and build ourselves a superb beginning point for the design of any Java application.

Object Oriented development enables developers to think in terms of real world “things” or Objects, and simply solve problems with those Objects. It is advisable to note that Java is actually not the only O-O programming language in existence, as it was actually recognized nearly five decades ago and a lot of popular programming languages make use of Object Oriented principles. Those languages may include C++, C#, Objective-C, Python, Ruby, and Visual Basic.

There are a lot more notions that happen to be essential in O-O programming languages including inheritance, polymorphism along with encapsulation. If you are interested in figuring out much more Object Oriented programming as it pertains to the Java language, there are lots of terrific Java tutorial blogs in existence nowadays.

Source by Trevor J Page

Network Marketing Tutorial – Learn the 4 Personality Types

If you’re not having a ton of fun with your Network Marketing business, this information about how to become a master of the 4 Personality Types is just for you.

Theories of Personality Types

Theories about the Personality Types have been around since Hippocrates. You might have heard them by other terms: Sanguine, Phlegmatic, Melancholy, and Choleric or Expressive, Amiable, Analytical, and Driver.

I’m going to teach them to you in a simple and fun way that I learned from my Mentors, Tom ‘Big Al’ Schreiter and Michael Dlouhy. Never again, will you be bored when around people. The 4 Personality Types by Colors are:

  • BLUE — think Snoopy of Peanuts
  • YELLOW — think Charlie Brown of Peanuts
  • GREEN — think Linus of Peanuts
  • RED — think Lucy of Peanuts

To make Colors easier to understand, I will exaggerate a bit. Most people will be a combination of Colors, with one being their predominant Color. Also, a person might be predominately one Color at home and a different Color at work.

Why the Colors are important for Your Network Marketing Business

I will explain how each Color makes a unique contribution to your team. Ideally, you will want at least one team member from each of the 4 Colors, because each Color has their own strengths and your organization will be stronger as you learn to draw on each others strengths.

Are you thinking, ‘Wait a minute? When I was in school, I was tested. My teachers told me to work on my weak areas.’

Forget that. I’m going to teach you how to teach the members of your organization to work in their strengths. How does that feel?

This system allows people to contribute what they are good at and enjoy doing.

  • Would you like a good promoter in your organization? You want a BLUE.
  • Would you like someone who is great at developing tools? You want a GREEN.
  • Would you like someone who is a great trainer? You want a YELLOW.
  • Would you like someone who is great at getting results? You want a RED.

This touches on another trait of a strong organization. Robert Kiyosaki says, ‘Success is a Team Sport.’ Highly successful Leaders are not Lone Rangers. They learn to attract and work with a wide variety of people and are great at bringing out the best of others.

Draw a Diagram of the Colors

Take a sheet of paper. Draw horizontal and vertical lines to make 4 quadrants.

  • At the top, write Open (Hugger, talks about Family).
  • At the bottom, write Self-Contained (not Hugger, my Family is none of your business).
  • At the left, write Indirect (Listener).
  • At the right, write Direct (Talker).
  • In the top left quadrant, write YELLOW.
  • In the top right quadrant, write BLUE.
  • In the bottom left quadrant, write GREEN.
  • In the bottom right quadrant, write RED.

Brief Description of the 4 Colors

I’m just going to give a brief description of the 4 Colors here and go into each Color in greater detail in a separate article.

  • BLUEs are Open and Direct. Their motto is — Let’s have fun.
  • YELLOWs are Open and Indirect. Their motto is — Let’s be friends.
  • GREENs are Self–Contained and Indirect. Their motto is — Let’s get the facts and figures.
  • REDs are Self–Contained and Direct. Their motto is — Let’s get results.

It may be more difficult for you to identify your own Color than someone else’s. That’s not unusual. Don’t worry. It is much more important for you to identify the other person’s Color, because once you’ve identified their Color, I’m going to teach you how to speak their Secret Language.

Source by Wilma Woodson