---
# System prepended metadata

title: '<center><i class="fa fa-edit"></i> Network Fundamentals: IP Addressing </center>'
tags: [Internship]

---

# <center><i class="fa fa-edit"></i> Network Fundamentals: IP Addressing </center>
###### tags: `Internship`
:::info
**Goal:**
To gain a basic understanding of the components behind network technologies. Focus on vocabulary and systems overview.
- [x] IP Addressing

**Resources:**
[Juniper Online Learning Modules](https://learningportal.juniper.net/juniper/user_activity_info.aspx?id=769)
[Pre-Internship Notes by Jessica Chen](https://hackmd.io/@j-chen/SyfRATOmD)
[Daily Report by Lin Yen-Ting](https://hackmd.io/@8KbRc796SnuYA2Dvsvk_BA/SJU_CawIL)
:::
## Module 4: IP Addressing

### Overview
 ![](https://i.imgur.com/UptJ5Gt.png)
 - IPv4(IP version 4): used by most home and business networks
 - IPv6(IP version 6): next generation protocol
 - When a computer needs to send data, the Internet Layer adds an IP header to the data to form an IP packet
### Parts of an IP Address
- Bits : 0-31
    - 4-bit field identifying IP version. For IPv4 field value = 4; IPv6 field value = 6.
- IP Header Length 
    -  4-bit field that can range from 20 to 24 octets (five to six 32-bit words)
-  DiffServ (Differentiated Service) : 
    - formerly Type of Service (ToS)
    - 8-bit fielld
    - used as a method of adding Quality of Service (QoS), which is traffic prioritization where devices support it 
-  Total Length 
    -  16-bit field specifies the entire packet size in octets, including both header and data
-  Bits : 32-63
    -  Identification: Used with the Flags and Fragment Offset fields; 16-bit field that uniquely identifies fragments of an original IP datagram
    -  Flags  3-bit field used to control or identify fragments
    -  Fragment Offset: 3-bit field (units of 8 octets) of a particular fragment relative to the beginning of the original un-fragmented IP datagram; first fragment offset = 0
-  Bits : 64-95
    * Time to Live (TTL) : Preventa packets from persisting indefinitely on a network; 8-bit field is set to a number, commonly 64, when the packet is created
        * Each router that a packet crosses decrements the TTL field by one. Once it reaches reaches zero, the router discards the packet and sends an error message to the sending device.
    * Protocol: 8-bit field specifies the number of the Layer 4 protocol used in the data portion of the packet (6 for TCP, 17 for UDP, 1 for ICMP)
    * Header Checksum: 16-bit field used for error correction for only the IP header. At each hop, the router recalculates the checksum and update the field before forwarding the IP packet
- Bits: 96-127
    - Source IP Address: 32-bit IP address of the originator of the IP packet
- Bits: 128-159
    - Destination IP Address: 32-bit IP address of the destination of the IP packet
- Bits: 160-191
    - Options: optional, variable length field, for testing and troubleshooting
### Two Parts of a Layer 3 Address 
1. Network prefix (aka: network portion, network number) 
2. Host portion
    - Number of bits in the network prefix is not a fixed value
    - Network masks (aka address mask, subnet mask, netmask): used to identify the network portion of the address
        - network prefix: bit = 1
        - host portion: bit = 0
![](https://i.imgur.com/hAwvSYU.png)
- Classless Inter-Domain Routing (CIDR, aka slash notation): the address followed by a forward slash and prefix length; another method to determine network prefix and host portion
    - Prefix length: number after the forward slash
    - Network masks must fall on an octet boundary but CIDR does not
- Classful Routing (older system of routing): divided the IP address into different size classes of a based on the number of octets used for the network portion and host number
![](https://i.imgur.com/hUd0bji.png)
![](https://i.imgur.com/QRPi5Jm.png)
- Challenge: most networks were too large for a single Class C network number, which allows only 254 host
- Solution: Many organizations used Class B (allows over 65,000 hosts)
    - End Result: Many IP addresses were wasted
- Fixed boundaries limited flexibility and the number of addresses that could be assigned while Internet routing tables were growing exponentially
- Switch to CIDR
![](https://i.imgur.com/MeWix0d.png)
- Calculating the Number of Networks and Hosts
![](https://i.imgur.com/7RcLGbF.png)
![](https://i.imgur.com/iOZK3XU.png)
![](https://i.imgur.com/2HueSOG.png)
- If the network prefix does not fall on an octet boundary, it is impossible to determine the actual subnet number without the mask
![](https://i.imgur.com/mcdIkIM.png)
- Loopback interface: virtual software interface not associated with or connected to any hardware that a device uses to send a message back to itself; commonly used for troubleshooting and network testing
- Uses of loopback interfaces
    1. Testing services without exposing them to the security risks of accessing them through the network
    2. The same PC might want to communicate with the web server directly -> Use loopback address in the URL to communicate with the local web server
- Multicast IP Address: similar to multicast MAC addresses; used to send the same data to a specific group of device
    - often used by routing protocols, streaming media services, and Internet Television (IPTV)

### Example of Data Flow Between PCs
All the prefix lengths are 24 and the destination address 192.168.3.2 full with n 192.168.3.0/24 network range (192.168.3.0 ~ 192.168.3.255. Routing table shows that the next-hop router is 192.168.2.2.
![](https://i.imgur.com/rGUHChP.png)
Router needs to add a new Layer 2 frame, including the next-hop router’s MAC address. 
1. Performs the address resolution process to determine that the MAC address for the next-top router 192.168.2.2 is bb
2. Adds it’s own source MAC address for the port on which will be sending the data. That address is aa
3. Forwards the frame out the desinated port
![](https://i.imgur.com/cuf2z6T.png)
Destination IP adress fulls in the 192.168.3.0/24 network range
![](https://i.imgur.com/AFGsaQy.png)
Router uses ARP to learn the PC 192.168.3.2’s MAC address is ee. It adds the Layer 2 header with the appropriate destination MAC addressthe, source MAC address for the port in which will be sending the frame(dd)
![](https://i.imgur.com/YBDRRBh.png)
Router transmits the data through direct routing (because devices are on same network). Data arrives at destination PC and unwraps the data layer by layer
![](https://i.imgur.com/nArXN3w.png)
- Routers always use the longest match available to forward traffic (i.e. best match)
- Challenge faced by packets: Before a packet can be encapsulated, it needs to make sure that itt is small enough to fit Layer 2’s frame size. Different Layer 2 technologies have different frame formats
    - Maximum Transmission Unit (MTU): Fixed upper limit on the size of a packet that can be sent in a single frame
- Solution: IP Fragmentation. Fragments are then sent individually and reassembled into the original packet by the receiving device
![](https://i.imgur.com/AJwZdGT.png)
### IPv4 vs IPv6
- IPv4: Pool of available IPv4 IP addresses has almost been exhausted -> increasing number of research and educational facilities, service provider and corporate lab networks are using IPv6
- IPv6: 4 times larger than IPv4, defined by the Internet Engineering Task Force and standardized in 1998
![](https://i.imgur.com/FQExRYb.png)
- Advantages of IPv6
    1. Solves address exhaustion 
    2. Eliminates the need for Network Address Translation (NAT)
    3. Reduces administrative overhead: Hosts can use stateless address autoconfiguration or DHCPv6 to assign an IP address to themselves
    4. Supports greater levels of security by integrating features that were optional add ons in IPV4
    5. Makes processing more efficient in a number of ways
### IPv4 Header versus IPv6 Header
![](https://i.imgur.com/C7ot74b.png)
![](https://i.imgur.com/36HhkQt.png)
- Protocol
![](https://i.imgur.com/FdjP7SA.png)
![](https://i.imgur.com/Rat5pyA.png)
- Six Extensions
    - Each extension specifies the type of header that follows. Other types of headers may be added in the future
![](https://i.imgur.com/rtLbARC.png)
    1. Hop-by-Hop Options
    ![](https://i.imgur.com/Yn5HUva.png)
    2. Destination Options
    ![](https://i.imgur.com/iwZZkEl.png)
    3. Routing
    ![](https://i.imgur.com/jPlJlcb.png)
    4. Fragment
    ![](https://i.imgur.com/LbZTmqe.png)
    5. Authentication
    ![](https://i.imgur.com/3OtKBAt.png)
    6. Encapsulating Security Payload (ESP)
    ![](https://i.imgur.com/U7KedvD.png)
- IPv4 Header
![](https://i.imgur.com/QdjnDEE.png)
- IPv6 Header
![](https://i.imgur.com/OpfFhc7.png)
    - Version
    ![](https://i.imgur.com/orB68Pn.png)
    - Traffic Class
    ![](https://i.imgur.com/Qgx3sL0.png)
    - Flow Label
    ![](https://i.imgur.com/S3LONuN.png)
    - Payload Length
    ![](https://i.imgur.com/HYYRHzw.png)
    - Next Header
    ![](https://i.imgur.com/ntd9doS.png)
    - Hop Limit
    ![](https://i.imgur.com/sNOam4C.png)
    - Source IP Address (128-bit)
    ![](https://i.imgur.com/cJ8BT0r.png)
    - Destination IP Address (128-bit)
    ![](https://i.imgur.com/tBJTtfs.png)
### IPv6 Address
- IPv6 Addressing: 128-bit address in eight 16-bit hexadecimal sections separated by colons, allows for abbreviations, and are not case senstive
    - Hard to search for this address through a UNIX system and many applications exist that do not provide this capability
-  Internet Engineering Task Force developed a set of recommendations for how IPv6 addresses should be consistently represented
![](https://i.imgur.com/jghdGGf.png)
- Network Prefix
    - /24 IPv4 address: first 24 bits are the network prefix
    - /64 IPV6 address: first 64 bits are the network prefix
        - broken down into two sections: a global routing prefix and a subnet ID
            - global routing prefix: typically assigned by ISP or regional address allocation entity
            - subnet ID: managed internally
-  Each of the characters represents a 4-bit binary number
- Interface ID: Equivalent to the host portion in IPv4
- IPv6 Subnetting: Used to create multiple broadcast domains that are smaller than your entire network, basically the same as IPv4
![](https://i.imgur.com/Ds6HnuA.png)
![](https://i.imgur.com/xRrJilP.png)
- Reserved Prefixes: Just like with IPV4, certain prefixes are reserved and should be used for specific types of traffic
    - RFC 4291 defines the latest rules regarding prefix notation
![](https://i.imgur.com/TVqn8rz.png)

:::warning
**SIDE NOTE**
No notes were taken for decimals, binary numbers, and hexadecimals since this was previously acquired knowledge
:::

:::success
### Module 4 Summary
![](https://i.imgur.com/zk0NSLF.png)
![](https://i.imgur.com/LfnEbml.png)
![](https://i.imgur.com/Q2yV6iY.png)
:::