Learn Networking
485 subscribers
24 photos
6 links
Learn Networking from Scratch.
Download Telegram
OSI Model - The Physical Layer:
The Physical layer (Layer-1) controls the signaling and transferring of raw bits onto the physical medium. The Physical layer is closely related to the Data-link layer, as many technologies (such as Ethernet) contain both datalink and physical functions.

The Physical layer provides specifications for a variety of hardware:
• Cabling
• Connectors and transceivers
• Network interface cards (NICs)
• Wireless radios
• Hubs
Physical-layer devices and topologies are covered extensively in other guides.
IP Protocol:
IP (Internet Protocol) determines where we are going to send packets to by looking at the destination IP address. How we determine where to send them is up to the routing protocol, we‟ll talk more about routing later.

IP uses Packets called IP packets to carry information. Every IP packet is a single unit of information and besides data it carries information to determine where to send the packet.

Let's take a look at some of its characteristics:
1. Operates at the network layer of the OSI model.
2. Connectionless protocol: IP itself does not setup a connection, in order to transport data you need the “transport” layer and use TCP or UDP.
3. Every packet is treated independently; there is no order in which the packets are arriving at their destination.
4. Hierarchical: IP addresses have a hierarchy; we'll discuss this a bit more in depth when we talk about subnetting and subnet masks.
We need an IP address to uniquely identify each network device on the network.
An IP address is just like a phone number (I'm talking about regular phone numbers, no cellphones).

Everyone in a city who has a phone at home has a unique phone number where you can reach them.
An IP address is 32-bit and consists of 2 parts, the network part and the host part:
The IP address is 32-bit but we write it down in 4 blocks of 8 bits. 8 bits is what we call a
“byte”. So the IP address will look like this:
The network part will tell us to which “network” the IP address will belong, you can compare this to the city or area code of a phone number.

The “host” part uniquely identifies the network device; these are like the last digits of your phone number.
IP address 192.168.1.1 would come along with the subnet mask 255.255.255.0. The subnet mask tells your computer which part is the “network” part and which part is the “host” part.

Despite the name it does not “hide” or “mask” anything. We'll talk about binary and subnetting calculations later on, for now just hold the thought that your subnet mask tells us which part of the IP address is the “network” part and which part is for “hosts”.
IP address that we just used (192.168.1.1) is an example of a class C network.

We have 3 different classes to work with:
- Class A
- Class B
- Class C
Class A: 0.0.0.0126.255.255.255
Class B: 128.0.0.0191.255.255.255
Class C: 192.0.0.0223.255.255.255

Hmm now this raises 2 questions:
- If you look closely, do you see a 127.0.0.0 subnet? It‟s not in the class A range so what happened to it?
- Why does Class C stop at 223.255.255.255?

To answer the first question: Go to your command prompt of your computer and type in “ping 127.0.0.1” and you'll get a response. This network range is being used as “loopback”. Your loopback interface is something to check if your IP stack is OK.

To answer the second question I have to tell you that there‟s actually a class D range, we don‟t use those IP addresses to assign to computers but it‟s being used for “multicast”.

We'll get back to multicast later in the book; it starts with the 224.0.0.0 range.
The last thing I need to tell you about classes is the difference between “private” and “public” IP addresses.

- Public IP addresses are used on the Internet.
- Private IP addresses are used on your local area network and should not be used on the Internet.

These are the Private IP address ranges:
Class A: 10.0.0.010.255.255.255
Class B: 172.16.0.0172.31.255.255
Class C: 192.168.0.0192.168.255.255

Do you see our 192.168.1.1 example IP address falls within class C and is a private IP address? I like to use this IP address since it's most common to people, it's used a lot on home networks and SOHO (small office home office) routers.
There are 2 IP addresses we cannot use on our network.
- Network address.
- Broadcast address.
The network address cannot be used on a computer as an IP address because it's being
used to “define” the network.

The broadcast address cannot be used on a computer as an IP address because it's used by
broadcast applications. A broadcast is an IP packet that will be received by all devices in
your network.

So how do we recognize these two IP addresses that we cannot use?
- Set all the host bits to 0 gives you the network address.
- Set all the host bits to 1 gives you the broadcast address.
- These 2 IP addresses we cannot use for computers.
IP addresses can be configured statically or dynamically. If you go the static way you have to configure the IP address yourself on your computer, router or switch.

Dynamic means we use DHCP (Dynamic Host Configuration Protocol). DHCP is a server process that assigns IP addresses from a “pool” to network devices.
A cisco router can be used as a DHCP server but you will also see this often on Microsoft or Linux servers.
The Transport Layer TCP and UDP:
Let's work our way up the OSI-model, we just covered IP and now it's time to pick a “transport” protocol.

Keep in mind IP is “nothing more” but a number (ok that's very simplistic) but I want to make sure you understand we need a transport protocol for actually setting up the connection and sending data between our computers.

I want to focus on the transport protocols that are used most of the time:
- TCP (Transmission Control Protocol)
- UDP (User Datagram Protocol)
So why do we have 2 different transport protocols here, why do we care and when do we need one over another?
The short answer is:
- TCP is a reliable protocol.
- UDP is a unreliable or best-effort protocol.

Unreliable you might think? Why do I want data transport which is unreliable? Does that make any sense? Let me tell you a little story to explain the difference between the two protocols.
You are sitting behind your computer and downloading the latest greatest movie in 1080P HD with 7.1 surround super sound directly from Universal studio's brand new “download on demand” service (hey you never know…it might happen one day…).

This file is 20GB and after downloading 10GB there's something going wrong and a couple of IP packets don't
make it to your computer, as soon as the entire download is done you try to play the movie and you get all kind of errors. Unable to watch the movie you are frustrated and head for the local dvd rental place to watch some low-quality movie…

Ok maybe I exaggerate a bit but I think you get the idea; you want to make sure the transport of your download to your computer is reliable which is why we use TCP. In case some of the IP packets don't make it to your computer you want to make sure this data will be retransmitted to your computer!
In our second story you are the network engineer for a major company and you just told your boss how awesome this brand new open source Voice over IP solution is.

You decide to implement this new VoIP solution and to get rid of all the analog phones but your users are now complaining big time that their phone call quality is horrible. You contact the open source VoIP solution provider and you find out that they thought it would be a good idea to use a reliable transport protocol like TCP since well, we want phone calls to be reliable right?

Wrong thinking! TCP does error correction which means that data that didn‟t make it to your
computer will be retransmitted. How weird will your phone call sound if you are talking to
someone and you hear something that they said a few seconds ago?

It's real-time so we don't want retransmission. It's better to send VoIP packets and lose a few than
retransmitting them afterwards, your VoIP codec can also fix packet loss up to a certain degree.

In this example we'll want to use a best effort or unreliable protocol which is UDP.
What do we have in the table above? First of all you see “connection type”. TCP is connection-oriented which means it will “setup” a connection and then start transferring data.

UDP is connectionless which means it will just start sending and doesn't care if it arrives yes or not.

The connection that TCP will setup is called the “3 way handshake”.

Sequencing means that we use a sequence number, if you download a big file you need to make sure that you can put all those packets back in the right order.

As you can see UDP does not offer this feature, there's no sequence number there.
So what about VoIP? Don't we need to put those packets back in order at the receiver side?

Well actually yes we do otherwise we get some strange conversations. UDP does not offer this “sequencing” feature though…let me tell you a little secret: for VoIP it's not just UDP that we use but we also use RTP which does offer sequencing! (And some other cool features we need for VoIP).
Let's sum up what we now know about UDP and TCP:
UDP:
- It operates on the transport layer of the OSI model.
- Is a connectionless protocol, does not setup a connection…just sends data.
- Limited error correction because we have a checksum.
- Best-effort or unreliable protocol.
- No data-recovery features.

TCP:
- It's a reliable protocol.
- Before you send data you will setup the connection by using the 3 way handshake.
- After sending X amount of bytes you will receive an acknowledgment (ACK) from the other side.
- How many bytes you send before you get an ACK is controlled by using the “window size”.
- TCP can do retransmissions.
Ethernet:

Ethernet is the protocol that we are running on our LAN. So what layer(s) of the OSI model do you think Ethernet will describe? If you are thinking “Data link” layer you got it right but it also describes the physical layer.

Now here things will get a bit funky, Ethernet describes the Data link layer but it has been split up in two pieces, so it looks like this: