Introduction to computer networking for Interviews and Self-learning
Published: 2021-12-10 05:08:07

Before starting the topic let me tell you why I started writing about computer networks. 

> I am currently pursuing my final year Engineering degree. I had this topic (Computer Networking) in my 3rd year. Unfortunately due to covid, we were having classes online, so I couldn't get most from the subject. I felt the subject was a bit difficult to learn so I left it without much bothering about it. But when I started attending my interviews I got to know that computer networking is an important topic to learn. so let me share my learnings with you.


###  Defining a Network :

*let's start with defining a network. what exactly is a network?* 
 if you would have asked me  6months ago I would have said that: 
*a network is a connection where computers are connected with each other(a definition I learned from college).*
Yes, it's quite true that 
**a network is nothing more than two or more computers connected by a cable or by a wireless radio connection so that they can exchange resources and information.**

You can create a simple computer network of your own by hooking together all the computers in your office/home with cables and using the computer’s network interface (an electronic circuit that resides inside your computer and has a special jack on the computer’s backside). I will speak about network interface in my next blog, but for now, let's just assume that the network interface helps a computer in connecting to the network. Then you tweak a few simple settings in the computer’s operating system (OS) software, and — **yo!** — you have a working network. 

If you don’t want to mess with cables, you can create a wireless network instead.
In a wireless network, the computers use wireless network adapters that communicate via radio signals. All modern laptop computers have built-in wireless
network adapters, as do most desktop computers. (If yours doesn’t, you can purchase a separate wireless network adapter that plugs into one of the computer’s USB ports.)

**Network adapter**: A network adapter is the component of a computer's internal hardware that is used for communicating over a network with another computer.


![Mydoc-1.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1639036153257/LchwkcBRiD.jpeg)

the above figure shows a typical network with four computers. You can see that all four computers are connected by a network cable to a central network device: the **switch**. You can also see that Faizan’s computer has a fancy laser printer attached to it. Because of the network, Maaz, Muiz, and the Ruman can also use this laser printer.
Don't worry about switch, for now, we will discuss it later. but just for now, I want you to have a clear image of a word network.


### What is the benefit of having a network?

Frankly, computer networks are a bit of a pain to set up. So, why bother? Because the benefits of having a network outweigh the difficulties of setting one up.

You don't have to be a PhD to understand the benefits of networking. In fact, we all have learned we need to know in our kindergarten. Networks are all about sharing. Specifically, networks are about sharing three things: files, resources, and programs.

**Sharing Files** : 
Networks enable you to share information with other computers on the network. One of the methods of sharing files is to copy the file to a disk on another computer and then tell your friend where you
put the file so that your friend can retrieve it later. One way or the other, the data travels to your friend’s computer over the network cable and not on a CD or DVD. 

**Sharing Resources**:
You can set up certain computer resources such as hard drives or printers so that all computers on the network can access them. For example, the laser printer attached to Faizan’s computer in the above figure is a shared resource, which means that anyone on the network can use it. Without the network, Maaz, Muiz, and the Ruman would have to buy their own laser printers.

**Sharing Programs**:
Instead of keeping separate copies of programs on each person’s computer, put programs on a drive that everyone shares. For example, if ten computer users all use a particular program, you can purchase and install ten copies of the program, one for each computer. Or you can purchase a ten-user license for the program
and then install just one copy of the program on a shared drive. Each of the ten users can then access the program from the shared hard drive.


 **Servers and Clients**

 Let's move ahead with the most commonly used terms in computer networking named servers and clients.

- The computer which is connected to a network that contains the hard drives, printers, and other resources that are shared with other network computers is a server.

- Any computer that's not a server is a client or the network computer which tends to use the resources of other network computers is a client.

- In many networks, a computer functions as either a server or a client, not both. For the sake of an efficient network, a server can't be a client, nor can a client become a server.

- Usually smaller networks can be more evenhanded by allowing any
computer in the network to be a server and allowing any computer to be both a server and a client at the same time 


### Types of Networks :

I was having many misconceptions about this topic in my college days. Let's get a clear picture of it.

Networks come in all sizes and shapes. In fact, networks are commonly based on the geographical size they cover, as described below:

1. **Local area networks (LANs)**:
In this type of network, computers are relatively close together, such as within the same office or building. Don't let the word "local" fool you. A LAN doesn’t imply that a network is small. A LAN can contain hundreds or even thousands of computers. What makes a network a LAN is that all its connected computers are located within close space. Usually, a LAN is contained within a single building, but a LAN can extend to several buildings on campus, provided that the buildings are close to each other.

2. **Wide area networks (WANs)**: 
These networks span a large geographic territory, such as an entire city or a region, or even a country. WANs are typically used to connect two or more LANs that are relatively far apart. For example, a WAN may connect an office in San Francisco with an office in New York. The geographic distance, not the number of computers involved, makes a network a WAN. If an office in San Francisco and an office in New York each has only one computer, the WAN will have a grand sum of two computers — but will span more than 3,000 miles.

3. **Metropolitan area networks (MANs):**
This kind of network is smaller than a typical WAN but larger than a LAN. Typically, a MAN connects two or more LANs within the same city that are far enough apart that the networks can’t be connected via a simple cable or wireless connection.


### Understanding network topology :

I think this is one of the topics in computer networking that students can easily understand, including me.

The term network topology refers to the shape of how the computers and other network components are connected to each other. There are several different types of network topologies, each with advantages and disadvantages.
       
Before going forward, let's just look at some important terms :  

**» Node**: A node is a device that’s connected to the network. For your purposes here, a node is the same as a computer. Network topology deals with how the nodes of a network are connected to each other.

**» Packet**: A packet is a message that’s sent over the network from one node to another node. The packet includes the address of the node that sent the packet, the address of the node the packet is being sent to, and data.

**1. Bus Topology: ** 


![bus.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1639037956780/oe5kT8Txt.jpeg)

I think all have loved bus topology from the start including me.
In this topology, the nodes are connected to a single cable as shown in the figure above. The key to understanding how a bus topology works is to think of the entire network as a single cable, with each node “tapping” into the cable so it can listen in on the packets being sent over that cable. 
- In a bus topology, every node on the network can see every packet that’s sent on the cable.
- Each node looks at each packet to determine whether the packet is intended for it. If so, the node claims the packet. If not, the node ignores the packet.
- This way, each computer can respond to data sent to it and ignore data sent to other computers on the network.
- If the cable in a bus network breaks, the entire network is effectively disabled.
 

**2. Star Topology:**


![start.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1639037969439/2POQb0eXo.jpeg)

In a star topology, each node is connected to a central device called a hub or a switch, as shown in the figure below. Star topologies are commonly used with LANs.

- If a cable in a star network breaks, only the node connected to that cable is isolated from the network. The other nodes can continue to operate without interruption unless, of course, the node that’s isolated because of the break happens to be the file server.

I think this is the best place to talk about the hub and a switch.

**Hub**: Hub is a device that can connect many computers together to form a network. A hub doesn’t know anything about the computers that are connected to each of its ports. So when a computer connected to the hub sends a packet to a computer that’s connected to another port, the hub sends a duplicate copy of the packet to all its ports. It's like sending a message to everyone who is connected to me regardless of the fact to whom that message was intended.

**Switch**: Switch is similar to the hub but the main difference is that a switch knows which computer is connected to each of its ports. As a result, when a switch receives a packet intended for a particular computer, it sends the packet only to the port that the recipient is connected to.

Strictly speaking, only networks that use switches have a true star topology. If the network uses a hub, the network topology has the physical appearance of a star, but it’s actually a bus. That’s because when a hub is used, each computer on the network sees all the packets sent over the network, just like in a bus topology. In a
true star topology, as when a switch is used, each computer sees only those packets that were sent specifically to it, as well as packets that were specifically sent to all computers on the network (those types of packets are called broadcast packets).


**3. Ring Topology: **


![ring.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1639037982648/ubUNZehqC.jpeg)

The third type of network topology is called a ring (see figure).
- In a ring topology, packets are sent around the circle from computer to computer.
- Each computer looks at each packet to decide whether the packet was intended for it. If not, the packet is passed on to the next computer in the ring.
- In this data travels in unidirectional forms means in only one direction but it can also do bidirectional by having 2 connections between each Network Node, it is called Dual Ring Topology.

**4. Mesh Topology:**


![mesh.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1639038046231/UtvomTf-Z.jpeg)

- The fourth type of network topology, known as mesh, has multiple connections between each of the nodes on the network, as shown in the figure.
- The advantage of a mesh topology is that if one cable breaks, the network can use an alternative route to deliver its packets.
- Mesh networks aren’t very practical in a LAN setting. For example, to network eight computers in a mesh topology, each computer would have to have seven network interface cards, and 28 cables would be required to connect each computer to the seven other computers in the network. This type isn’t very scalable.



> In this blog, I have tried to provide a clear picture of what is a network and its benefits, I have also discussed types of networks and types of topologies. I have also discussed server, client, hub, and switch. Hope you find it helpful.
 

>**Reference : 
           Networking all in one for dummies 7th edition by Doug Lowe**