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 Transport layer (Transport)

  • The transport layer has two protocols
    • TCP(Transmission Control Protocol),Transmission control protocol.
    • UDP(User Datagram Protocol),User datagram protocol.

UDP

The data format

  • UDPIs connectionless, reducing the overhead of establishing and releasing connections.
  • UDPMaximum capacity delivery, no guarantee of reliable delivery.
    • Therefore, there is no need to maintain some complicated parameters8Bytes (at least the header of TCP20Bytes).

  • UDPLength (Length)
    • Account for16Bit, the length of the header + the length of the data.

Inspection and

  • Test and calculation content:Pseudo header + header + data
    • Pseudo header: only works when calculating checksum and is not passed to the network layer.

port

  • The UDP header port is occupied. Procedure2Bytes.
    • It can be inferred that the value range of the port number is:0 ~ 65535.
  • The source port of the client is a random port that is enabled temporarily.
  • Firewalls can enable/disable certain ports to improve security.
  • Common command lines
    • netstat -an: View the occupied ports
    • netstat -anb: Displays occupied ports and applications
    • Telnet host port: Checks whether a port on the host can be accessed

TCP

The data format

  • Data migration
    • There are four digits in the range of0x0101~0x1111
    • Multiply by 4: Header Length
    • The head length is20~60bytes
  • keep
    • Account for6Bit, currently all0

A detail

  • whyTCPandUDPIs the length of the data in the first record different?
    • UDP has a header16The field of bits records the entireUDPLength of message segment (header + data)
    • However,TCPThere is only one in the head of4The field of bits is recordedTCPThe header length of the packet segment, and no field is recordedTCPThe data length of the packet segment
    • Analysis of the
      • UDPThe first of16The bit-length field is redundant, purely to ensure that the header is32bitalignment
      • TCP/UDPThe length of the data can be predicted from the header of the IP packet
      • Data length of the transport layer = total length of the network layer - length of the head of the network layer - length of the head of the transport layer

Inspection and

  • Like UDP, TCP checks and computes content: false header + header + data
    • Pseudo-header: takes up 12 bytes and is only useful for calculating checksums and is not passed to the network layer

Sign a

  • URG (urgent)
    • whenURG = 1Is valid, indicating that urgent data exists in the current packet segment and should be transmitted as soon as possible
  • ACK (Acknowledgment)
    • whenACK = 1, the confirmation number field is valid
  • PSH (Push)
  • RST (Reset)
    • whenRST = 1Is displayed, indicating that a serious error occurs in the connection. The connection must be released and then re-established
  • The SYN (Synchronization)
    • whenSYN = 1.ACK = 0, indicating that this is a request to establish a connection
    • If the other party agrees to establish a connection, replySYN = 1.ACK = 1
  • FIN (Finish)
    • whenFIN = 1“, indicating that data has been sent and the connection needs to be released

Serial number, confirmation number, window

  • Sequence Number
    • Account for4byte
    • First, each byte is assigned a number during transmission
    • After the connection is established, the serial number indicates: this time to the other partyTCPThe number of the first byte in the data section
  • Acknowledgement Number
    • Account for4byte
    • After a connection is established, the confirmation number represents the one expected to cross next timeTCPThe number of the first byte in the data section
  • Windows
    • Account for2byte
    • This field has flow control and is used to tell the other party how much data (in bytes) is allowed to be sent next time.