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

Network interconnection model

  • In order to better promote the research and development of the Internet, the international standardization organization ISO established in 1985Network interconnection model
  • OSI Reference Model (Open System Interconnect Reference Model) with7 layer structure
  • In actual development and learning, 4 layers are mainly usedTCP/IP protocolAnd 5 layersLearning Research Edition.

Request process

  • Requesting on the NetworkThe clienttoThe serverEach layer is responsible for sending dataJoining togetherPart of the data.
  • inThe clientreceiveThe serverEach layer is responsible for the data returneddemolitionPart of the data.

The basis of communication between computers

  • Need to know each otherThe IP address
  • Ultimately based onMAC Address (NIC address), and send data toThe network card,The network cardreceive
    • The data includeThe source IP,Destination IP address,The source MAC address,Destination MAC Address
    • If the nic discovers the target of the dataThe MAC addressIf it is itself, it will pass the data to the next level of processing
    • If the nic discovers the target of the dataThe MAC addressNot themselves, will be the datadiscardedIs not passed to the previous layer for processing

The way computers are connected

Cable directly connected

  • Need to use cross wires (not straight wires)

  • pingThe command uses theThe ICMP protocolIf you need to know the other personThe IP addressAnd ultimately according toThe MAC addressSend data toThe network card,The network cardTo receive.
  • Don’t know each otherThe MAC addressWhen usingARP protocol,radio.
  • radioOnly in the same placeNetwork segmentThe purpose is to obtainThe MAC address, to all connected devicesradio, ask for correspondenceThe IP addressUnder theThe MAC address.
  • ARP protocolIn the broadcast of the targetThe MAC addressforFFFF.FFFF.FFFF. That is, the MAC address in hexadecimal format1.
  • Is full of1The MAC address of theNetwork segmentCan be received by all connected devices.

  • ARP protocolThere is a cache. The next one ispingWhen, there is no need to acquireThe IP addressInstead, ICMP is implemented directly.

Coaxial Cable Coaxial cable

  • Multiple devices connection mode

  • Half duplex communication
    • At the same time, one-way communication
  • Easy to conflict
    • Conflicts occur when data is imported in both directions of the cable.
  • unsafe
    • Instead of going one way to the corresponding computer, data is sent to all devices.
  • There was a break, and the whole thing collapsed
    • The termination resistance is lost

Hub

  • Advantages:
    • If two lines conflict, the other lines can communicate
  • Disadvantages:
    • If 1,000 devices are connected,ARP protocolIt sends 1000 pieces of data. Even knowing each otherThe MAC address, the data still needs to be sent to 1000 devices simultaneously.
    • Half duplex communication
    • Easy to conflict
    • unsafe

Bridge (Hub)

  • To be able to learn which side of each structureThe MAC addressSo as to isolate the conflict domain.
    • throughThe MAC address table
    • When the data crosses the bridgeThe MAC address tableIdentify the targetThe MAC addressWhen you’re not on the other side, you don’t continue to send data to the other side.
    • If the left and right sides of the data can be separated by a bridge, then the left and right sides can communicate simultaneously.

Switch

  • Equivalent to a bridge with more interfaces
    • Learning ability: Can remember the MAC address of each interface
  • Full duplex communication, bidirectional communication
  • Safer than hubs
  • Regional network final scheme

What if all the devices in the world were connected by switches?

  • It receives broadcasts from devices around the world
  • The IP address is insufficient

Router

  • Data can be forwarded between different network segments
  • isolationBroadcast domains
    • differentNetwork segmentThere’s no way to broadcast between

How do different network segments communicate

  • Determine the host data before sending itDestination IP addressAnd whether the host is in the sameNetwork segment
    • In the sameNetwork segment, sendARPThrough theswitches,A hubPass data.
    • Not in the sameNetwork segment
      • Host sends firstARPTo the routerThe gateway, determine the gatewayThe MAC address.
      • The host sends data toThe gateway.The gatewayAnd then decide which exit to takeThe gateway.
      • inExport gatewaysendARPTo confirm the recipientThe MAC address.
      • The lastExport gatewaySend the data to the receiver.

conclusion

  • Cable direct connection, coaxial cable, hub, bridge, switch
    • The connected device must be inThe same network segment
    • The connected device is locatedSame broadcast domain
  • The router
    • Can be found inDifferent network segmentForwarding data between
    • isolationBroadcast domains
      • differentNetwork segmentThere’s no way to broadcast between
  • The host determines the target host before sending dataThe IP addressAnd whether it’s in the same placeNetwork segment
    • In the same network segment:ARP
    • Not in the same network segment: YesThe routerForwarding data