My Github address

Notes on data Structures and Algorithms

Notes for geek Time iOS Developer Class

IOS large factory interview high frequency algorithm summary

Summary of iOS interview materials

The MAC address

  • Each nic has a 48-bit Media Access Control Address.
  • Unique in the world, embedded in the ROM of a network card, specified by the IEEE802 standard
    • First three bytes: Organizationally Unique Identifier (OUI), which is allocated to the manufacturer by the IEEE registration authority
    • Last 3 bytes: network interface identifier, which is assigned by the vendor

MAC address format

  • Windows
    • 40-55-82-0A-8C-6D
  • Linux, Android, Mac, iOS
    • 40:55:82:0A:8C:6D
  • Packet Tracer
    • 4055.820 a. 8 c6d

Obtaining a MAC Address

  • If all 48 bits are 1, it indicates the broadcast address
    • FF-FF-FF-FF-FF-FF
  • If you do not know the MAC address of the host, you can obtain the MAC address by sending ARP broadcasts
    • After the IP address and MAC address mapping information is obtained, the DEVICE caches ARP cache
    • MAC addresses obtained through ARP broadcast belong to dynamic cache
    • The storage time is short (2 minutes by default). When the storage time expires, it will be automatically deleted

Relevant command

  • Arp -a[host address]: Queries ARP cache
  • Arp -d[host address]: Deletes ARP cache
  • Arp -s Host address MAC address: Add a cache message (this is a static cache, storage time is relatively long, different systems storage time is different)

The IP address

  • IP Address (Internet Protocol Address): Every host on the Internet has an IP address
  • The original isIPv4Version,32 bits (4 bytes)On November 25, 2019, the world ran out of IP addresses
  • It follows thatIPv6Version,128 - bit (16 bytes)

IP address composition

  • IP addresses are divided into two parts based on functions:Network ID (Network ID).Host ID (Host ID)
    • The network ids of computers on the same network segment are the same
    • The network ID can be calculated by the subnet mask:Subnet mask & IP address

    • Network ID: 192.168.1
    • Host ID: 0

IP address classification

  • Class A address: The default subnet mask is255.0.0.0

  • Class B address: The default subnet mask is255.255.0.0

  • Class C address: The default subnet page number is255.255.255.0

  • Class D address: a multicast address starting with 1110
  • Class E addresses: start with 1111 and are reserved for future use
  • Only class A, B, and C addresses can be assigned to hosts
    • All host ids are 0, indicating the network segment where the host resides
    • All host ids are 1, indicating the broadcast address of the network segment where the host resides

Class A address

  • Network ID

    • 0Can’t use,127Reserved network segment. Among them127.0.0.1Is a Loopback address, indicating a local address
    • That can be assigned to the host
      • The value range of the first part:1~126
  • The host ID

    • The first2,3,4The value range of the part is0-255.
    • The maximum number of hosts that each Class A network can hold is:256 * 256 * 256-2 = 2 ^ 24-2 = 16777214

A class B address

  • Network ID
    • That can be assigned to the host
      • The first1Value range of parts:128 ~ 191
      • The first2Value range of parts:0 ~ 255
      • The smallest segment128.0, the maximum network segment191.255
  • The host ID
    • The first3, 4The value range of the part is0 ~ 255
    • The maximum number of hosts that a Class B network can hold is:256 * 256-2 = 2 ^ 16 -2 = 65534

Class C address

  • Network ID
    • That can be assigned to the host
      • The first1Value range of parts:192 ~ 223
      • The first2, 3,Value range of parts:0 ~ 255
  • The host ID
    • The first4The value range of the part is0 ~ 255
    • The maximum number of hosts that each Class C network can hold is:256-2 = 254

The class D address

  • No subnet mask, used for multicast (multicast) addresses
  • The first1Value range of parts:224 ~ 239

Class E address

  • Reserved for future use
  • The first1Value range of parts:240 ~ 255

CIDR representation of a subnet mask

  • CIDR: Classless inter-domain Routing (CIDR): Classless interdomain Routing

  • CIDR representation of a subnet mask

    • 192.168.1.100/24, indicates that the subnet mask exists24a1, that is,255.255.255.0
    • 123.210.100.200/16, indicates that the subnet mask exists16a1, that is,255.255.0.0

Why subnets?

  • If 200 hosts need to reside on the same network segment, you can allocate a Class C network segment, for example, 192.168.1.0/24

    • A total of254An availableThe IP address:192.168.1.1 ~ 192.168.1.254
    • more54A freeThe IP addressThis is not a waste of resources
  • If 500 hosts need to be on the same network segment, assign a class B network segment, such as 191.100.0.0/16

    • A total of65534An availableThe IP address:191.100.0.0/16 ~ 191.100.255.254
    • more65034A freeThe IP addressThis is a huge waste of resources
  • How to avoid wasting IP address resources?

    • Divide subnets properly
      • Equal-length subnet division: A network segment is divided into multiple subnet segments, and each subnet segment has the same number of available IP addresses.
        • Equally divided into two subnets

        • Evenly divided into four subnets

        • Equal broadcast address divided into four subnets

        • Equally divided into eight subnets

      • The number of available IP addresses for each subnet can be different.

Super net

  • Hypernet: As opposed to a subnet, it combines multiple contiguous network segments into a larger network segment
  • Need: Originally200Computer use192.168.0.0/24Network segment, now want to increase200All devices are on the same network segment
    • 200in192.168.0.0/24A network segment,200in192.168.1.0/24Network segment
    • merge192.168.0.0/24.192.168.1.0/24For a network segment:192.168.0.0/23(Subnet mask moved 1 bit to the left)

Merge four network segments

  • The subnet mask moves to the left2Bit, can be combined4A network segment

Rules of merging network segments

  • Assuming thatN is 2 to the k.
    • If the network number of the first network segment can benDivisible, so it starts off continuousnTwo network segments, can pass the left shiftkBit subnet mask to merge

  • Such as
    • The network number of the first network segment is binary0The end, so it starts with the continuous2Two network segments, can pass the left shift1Bit subnet mask to merge
    • The network number of the first network segment is binary00The end, so it starts with the continuous4Two network segments, can pass the left shift2Bit subnet mask to merge
    • The network number of the first network segment is binary000The end, so it starts with the continuous8Two network segments, can pass the left shift3Bit subnet mask to merge

Determine whether a network segment is a subnet or a hypernet

  • First of all,

    • Look at the type of network segment, yesClass A network.A class B network.Class C network?
    • By default,Class A subnet maskNumber of bits is8.Class B subnet maskNumber of bits is16.Class C subnet maskNumber of bits is24
  • then

    • If the network segmentSubnet maskDigit ratio defaultSubnet maskMore than thatsubnet
    • If the network segmentSubnet maskDigit ratio defaultSubnet maskLess, that is,Super net
  • Such as

    • 25.100.0.0/16Is aClass A subnet
    • 200.100.0.0/16Is aClass C network