Skip to content

Instantly share code, notes, and snippets.

@OddExtension5
Last active June 11, 2022 06:54
Show Gist options
  • Save OddExtension5/9b966b8fe674036df9356a5566c12b2d to your computer and use it in GitHub Desktop.
Save OddExtension5/9b966b8fe674036df9356a5566c12b2d to your computer and use it in GitHub Desktop.
Networking

Networking

What is Networking?

Computer Networking is the subject which explains how computers connect with each other for sharing resource and information and what technologies and devices they use for the coonectivity.

Three components of networking

  • Medium ( How are you connected? )
  • Addressing ( How do you locate and identify the other party? )
  • Content ( What information are sharing with the other party? )

Addressing

Uniquely identify device on a network

IPv4 Addressing

  • 32-bit address
  • 192.168.112.20

The range of all possible IPv4 addresses was originally segmented into five classes, A through E. A, B, and C were used for general unicast assignments, class D was designated for multicast addressing, and class E was set aside for "experimental" use.

Addressing Space

Here's a visualization of the entire IPv4 address space. Each square represents one possible value of the first octet of an address. For instance, the square on the top right, labeled 15, represents all the IPv4 addresses that start with 15 as their first octet (e.g. 15.72.9.277).

c2l1-8d-ipv4-address-space-visualization01-v3

Visualization of the IPv4 address space. Each square represents the first octet of an IPv4 network address.

Additional Resources

Question : How many individual addresses are there on a /22 network? 2^10 - 3 = 1021 addresses 192.168.112.10/22 (Classless Interdomain Routing )(CIDR)

Conversion : IP Address to Binary

Binary to IP Address

Question: IP addresses are on the same subnet as 122.48.253.2/18? 122.58.200.200 , 122.48.193.61

Question: Write an IP address that is in same subnet as 172.254.3.17/8? All IP address between 172.0.0.0 - 172.254.3.17 are is in same subnet.

Reserved Addresses on a Netblock

If you recall, the number of addresses that are available for use in a netblock were reduced by three, because those three addresses are reserved for something. Well, what are they?

  • The first address (.0) is used for identification of the network,
  • The follow address (.1) is often assigned to the router,
  • The last address (.255) is called the broadcast address. Anything sent to the broadcast address will be sent out to all devices on the network.

Additional Resources

Some basic reading on subnetworks and Classless Inter-Domain Routing (CIDR):

  • Subnetworks,
  • A good read on CIDR with a helpful table on all IPv4 CIDR blocks.

And several technical reports on the following subjects:

OSI (Open Systems Interconnection)

The OSI model is a breakdown of the various aspects of network communication. It is concerned with the ability of different systems to be connected with each other. It's a conceptual breakdown of all the parts that are involved and groups them into logical sections. Let's check them out.

Layers in the OSI Model

There are 7 layers in the OSI model. We'll start at the top-most layer, layer 7, and work our way down to layer 1.

Layer 7 - Application

Layer 6 - Presentation

Layer 5 - Session

Layer 4 - Transport

Layer 3 - Network

Layer 2 - Data Link

Layer 1 - Physical

Remember that the OSI model is a conceptual model of how network communication occurs. For network communication to happen, the layers must work together to transmit a message from one device to another.

( People Do Not Throw Sausage Pizza Away )

Standard & Protocols

osi-model-v3

The OSI model is a conceptual model and helps describe data in many ways. It provides a standard for how network communication occurs, how data is transferred, and provides a way to group similar protocols together.

For example, network devices can be grouped at several different layers in the OSI model. Layer 1 of the OSI model deals with the physical and electrical specification for devices. Items such as physical cables, wireless signless, the network identification card (NIC) inside a computer are all grouped at the Layer 1 level. But even though Layer 1 is called the physical layer, that doesn't mean that every physical device shows up there. For example, a switch is a Layer 2 device and a router is a Layer 3 device.

The OSI Model also helps group network protocols together. Here are some of the most common protocols at each layer:

Layer 7 = HTTP

Layer 6 = SSL and TLS

Layer 5 = socket

Layer 4 = TCP and UDP

Layer 3 = IP and ICMP

Layer 2 = ARP

Layer 1 = 1000BASE-T, DSL, DOCSIS, 802.11a/b/g/n

Sibling Dependence

In the OSI model, a layer is only concerned with the layers above and below it. For example, layer 3 (the Network layer) is only concerned with the two layers that are on either side of it:

Layer 4 - the Transport layer

Layer 2 - the Data Link layer

Layer 3 will receive data from Layer 4 and send it to Layer 2 or it will receive data from Layer 2 and send it to Layer 4.

Layer 7 (the Application layer) is at the very top of the OSI model. Since it is at the top, it is only concerned with sending data to Layer 6 (the Presentation layer) or receiving data from Layer 6.

A single layer does not need to know the whole path that data takes through the OSI model. It just need to know about the layers above and below it that it needs to interact with. Now, why is this important? Each layer in the OSI model is an abstraction layer. An abstraction layer is:

a way of hiding the working details of a subsystem

For example, the way that the data is formatted, processed, and changed in Layer 2 does not matter to Layer 4, because Layer 3 abstracts those implementation details away. All Layer 4 has to worry about is how it needs to receive data from Layer 3 - it doesn't have to worry about the specifics of Layer 2 (since that's Layer 3's job).

Earlier, I said:

Layer 3 will receive data from Layer 4 and send it to Layer 2 or it will receive data from Layer 2 and send it to Layer 4.

When does data move down the layers from Layer 4 to Layer 3 to Layer 2 and when does the data move up the layers from Layer 2 to Layer 3 to Layer 4? These two processes are called encapsulation and decapsulation. Let's take a look at them in more detail.

Encapsulation and Decapsulation

Remember that the OSI model is a conceptual model of how data is packaged and sent across a network to another device. In this scenario, let's assume that there are only two devices that are trying to communicate with each other. The OSI model is used on both devices.

As the data is being packaged up on a sending device, the data moves down the OSI model; this process of the data moving down the OSI model is called encapsulation.

When the data is being unpacked on a receiving device, the data moves up OSI model; this process of the data moving up the OSI model is called decapsulation.

To recap, when data travels down the OSI model, the data from a higher layer becomes the "payload" for a lower layer. When the data moves from a higher layer to a lower layer, the data is wrapped in new information called a "header" and a "footer". This is where it gets the name "encapsulation"; because the data is wrapped (or encapsulated) with new header/footer layers.

Conversely, the opposite happens when traveling up the OSI model. As the data moves up the OSI model, these header/footer layers are removed. This is where it gets the name "decapsulation".

Further Research

Switching

A network switch is a multiport network bridge that uses media access control addresses(MAC) to forward data at the data link layer (layer 2) of the OSI model. Some switches can also forward data at the network layer (layer 3) by additionally incorporating routing functionality. Such switches are commonly known as layer-3 switches or multilayer switches.

Unicast 1:1 Multicast 1:Many Broadcast 1:All

Further Research

Frame Structure

Ethernet Packets

Screenshot-2

Further Reading

Fully Qualified Domain Name (FQDN)

A Fully Qualified Domain Name (FQDN) consists of three parts - the hostname, domain, and top-level domain (TLD). The format looks like so,

[host name].[domain].[tld]

For the FQDN www.github.com - www is the hostname, github is the domain, and com is the top-level domain.

Other examples of FQDNs include:

Further Research

Types of DNS Records

Screenshot-4

Nameservers for IPv4 and IPv6 Reverse Zones (2010)

  1. Datagrams: A datagram is a basic transfer unit associated with a packet-switched network. Datagrams are typically structured in header and payloads sections. Datagrams provide a connectionless communication service across a packet-switched network.

    Datagram Nomenclature

    OSI layer Name
    Layer 4 Data segement
    Layer 3 Data packet
    Layer 2 Frame, Cell
    Layer 1 Chip (CDMA)

  2. IP multicast : It is a method of sending Internet Protocol (IP) datagrams to a group of interested receivers in a single transmission. It uses specially reserved multicast address blocks in IPv4 and IPv6. One Packet Source - Multiple Receivers

  3. CSMA/CD : Used to determine when the communication channels are clear, and when a device is free to trasmit data. Carrier Sense Multiple Access / Collision Detection

Networking Command

  • ping: Send an ICMP ECHO_REQUEST to network hosts
  • traceroute: Print the route packets trace to a network host
  • ip: Show/manipulate routing, devices, policy routing, and tunnels
  • netstat: Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
  • ftp: Internet file transfer program
  • wget: Non-interactive network dowloader
  • ssh: OpenSSH SSH client (remote login program)

Examining and Monitoring a network

ping

The ping command sends a special network packet called an ICMP ECHO_REQUEST to a specified host. Most network devices receiving this packet will reply to it, allowing the network connection to be verified.

For example, to see whether we can reach www.google.com, we can use ping like this:

$ ping www.google.com

Once started, ping continues to send packets at a specified interval(the default is one second) until it is interrupted. After it is interrupted by pressing CTRL-C, ping prints performance statistics.

A successful "ping" will indicates that the elements of the network (its interface cards, cabling, routing, and gateways) are in generally good working order.

traceroute

The traceroute program (some systems use the similar tracepath program instead) lists all the "hops" network traffic takes to get from the local system to a specified host.

Exam 1: Find Subnet Facts, Easy Marks

  • Masks of /16 and /24 (255.255.0.0 and 255.255.255.0) Only

Questions:

  1. What is the subnet ID of the subnet containing 128.1.101.200 255.255.255.0?

Ans: 128.1.101.0

  1. What is the subnet broadcast address of the subnet containing 128.1.101.200 255.255.255.0?

Ans: 128.1.101.255

  1. List Subnets Facts

Address : 128.1.101.200 Mask : 255.255.255.0

Ans: Subnet ID : 128.1.101.0
1st Usable : 128.1.101.1
Last Usable : 128.1.101.254
Subnet Broadcast Address : 128.1.101.255

Exam 2: Find Subnet Facts, Difficult Masks

Procedure:

  1. Set Up the Problem on Paper

    A. Mask Above, Address Below, Column Aligned
    B. Space for: Subnet ID, Broadcast, +2

  2. If Mask = 255:

    A. Copy Address Octet(s) to Subnet ID
    B. Copy Address Octet(s) to Broadcast Address

  3. If Mask = 0:

    A. Write 0s in the Subnet ID
    B. Write 255s in Subnet Broadcast Address

  4. If Mask Is Neither 0 Nor 255:

    A. Calculate Magic = 256 - Mask_Value
    B. Subnet ID: Use Nearest Magic Multiple (Not Greater Than)
    C. Broadcast: Use Next Magic Multiple, Minus 1

  5. To Find the Rnage of Addresses in the Network:

    A. In 4th Octet, Subnet ID: +1
    B. In 4th Octet, Broadcast: -1

Questions:

  1. What is the subnet ID of the subnet containing 172.20.89.79 255.255.252.0?

Ans: 172.20.88.0

  1. What is the subnet broadcast address of the subnet containing 172.20.89.79 255.255.252.0?

Ans: 172.20.91.255

  1. List Subnets Facts

Address: 172.20.89.79
Mask: 255.255.252.0

Ans: Subnet ID: 172.20.88.0
First Address: 172.20.88.1
Last Address: 172.20.91.254
Broadcast: 172.20.91.255

  1. List Subnet Facts

Address: 192.168.201.45
Mask: 255.255.255.248

Ans: Subnet ID: 192.168.201.40
First Address: 192.168.201.41
Last Address: 192.168.201.46
Broadcast: 192.168.201.47

  1. List Subnet Facts

Address: 10.104.15.19
Mask: 255.248.0.0

Ans: Subnet ID: 10.104.0.0
First Address: 10.104.0.1
Last Address: 10.111.0.254
Broadcast: 10.111.255.255

Exam 3: Convert DDN Subnet Masks to Prefix

  • Three Formats
    • Begin with DDN (e.g., 255.255.0.0)
    • Convert to Binary (e.g., 11111111 11111111 00000000 00000000)
    • Convert to Prefix (e.g., /24)

Question:

  1. What prefix-style mask is the equivalent of Dotted Decimal Notation (DDN) mask 255.255.254.0?

Ans: /23

Exam 4: Find Network Facts

Range of First Octet (Inclusive) Class #Network Octets # Host Octets Default Mask
1..126* A 1 3 255.0.0.0
128..191 B 2 2 255.255.0.0
192.223 C 3 1 255.255.255.0
224..239 D
240..255 E
  1. Set Up the Problem on Paper

    A. Mask Above, Address Below, Column Aligned
    B. Space for: Network ID, Broadcast, +2

  2. If Mask = 255:

    A. Copy Address Octet(s) to Network ID
    B. Copy Address Octet(s) to Broadcast Address

  3. If Mask = 0:

    A. Write 0s in the Nwtwork ID
    B. Write 255s in Network Broadcast Address

  4. To FInd the Range of Addresses in the Network

    A. In 4th Octet, Network ID: +1
    B. In 4th Octet, Broadcast: -1

Question

  1. Find Network Facts of IP Address 172.24.1.223

Ans: Class : B
# Network Octets : 2
# Host Octets : 2
Default Mask : 255.255.0.0
Network ID (Subnet ID) : 172.24.0.0
First Address : 172.24.0.1
Last Address : 172.24.255.254
Network Broadcast Address : 172.24.255.255

Exam 4 : Find All Subnets, Easy Masks

Questions

  1. When listing all subnets of network 9.0.0.0 and using mask 255.255.0.0 for all subnets, what subnet is the third subnet form the start of the list?

  2. When listing all subnets of network 172.23.0.0 and using mask 255.255.0.0 for all subnets, what subnet is the third subnet form the end of the list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment