create by db on 2020-10-17 12:55:25

Recently revised in 2020-10-19 14:35:50

Idle time to have a tight mind, busy time to have leisure fun

directory

  • preface

  • Gateway routing and all that stuff

  • Read the illustration of TCP/IP

  • Reference documentation

preface

Returns the directory

Recently, I was reading the “Diagram of TCP/IP”, which did not know much about the concept of network protocol. I happened to see a very good article, which vividly illustrates the abstract concept of network. I want to share it with you.

Gateway routing and all that stuff

The story of One-inch

Let’s say you live in a big yard (local area network), have a lot of neighbors (network neighbors), and have a gatekeeper in the gatehouse. Mr. Li is your gateway. When you want to play with someone in the yard, just shout his name in the yard (ping him) and he will hear you and run out to play with you.

But you are not allowed to go out of the gate, and all your contact with the outside world must be with Uncle Li (gateway) to help you contact by telephone. If you want to talk to your classmate Xiaoming, xiaoming lives far away in another yard (xiaoming and you are not on the same LAN), there is a gatekeeper in his yard wang Uncle (Xiaoming gateway). You don’t know xiao Ming’s phone number, but your homeroom teacher has a list of the names and phone numbers of all the students in your class. Your teacher is your DNS server. So I called Uncle Li at home and had the following conversation:

Xiao One-spot: Grandpa Li, may I ask the head teacher for Xiao Ming’s phone number? (DNS query)

Grandpa Li: Ok, you wait. (Then Uncle Li hung up a phone to your head teacher and asked xiao Ming’s phone number) Yes, his home number is 211.99.99.99 (Xiao Ming’s IP address)

Tiny Spot: That’s great! Uncle Li, I want to find Xiao Ming, please help me contact Xiao Ming.

Uncle Li: No problem. (Then Uncle Li sent a request to the telephone office to connect xiaoming’s phone number. The last step, of course, was transferred to Uncle Wang in the courtyard of Xiaoming’s home. Then Uncle Wang transferred the call to Xiaoming’s home.)

So you got in touch with Xiao Ming. (Establish a connection)

As for the DHCP server, it can be compared like this:

Your home in the yard, there are more and more people of Mr. Lee is a message there telephone exchange already cannot satisfy the needs of so many people (the original partner, rarely use fixed IP), too much, not to be able to tube, using DHCP, residents on random we get a phone number, when every times the number may be different. Every once in a while, the number you rent is taken back and you need to get a new one next time. (This is the LEASE for DHCP.)

  • Uncle Li at your door: it’s your gateway
  • Your homeroom teacher: is your DNS server
  • The telephone exchange in the receptionist’s room is your DHCP server

Likewise, the conversation between Uncle Li and Uncle Wang is called routing.

In addition: if there is a child named Xiao Dark, the doorkeeper of his yard is Uncle Sun, because xiao Dark’s yard has just been built, uncle Sun just arrived (new route), he does not have the phone number of Uncle Li and Uncle Wang’s office (uncle Li and Uncle Wang certainly do not have his phone number), then there will be two situations:

  1. The neighborhood committee zhao Aunt told Uncle Sun about li, Wang two uncle’s phone (at the same time Zhao Aunt also told Li, Wang about sun’s phone), this is called static set routing
  2. Zhao Dama ill, big ye sun oneself call everywhere, people said: “I am a little dark they yard tube”, the result is li, wang two heard, write it on the address book, then, uncle wang li to give grandpa a call sun says: “I’m xiao Ming (little) their yard tube telephone”, this is called dynamic routing

Then one day, One-inch wanted to find Xiao-an. As a result, One-inch called Uncle Li and said, “Grandpa, I’m looking for Xiao-an” (the process of checking xiao-an’s phone is omitted here, assuming that he knows xiao-an’s phone number). Uncle Li looked for the address book: “Oh, uncle Samson is the telephone number of the small dark yard of the tube, to find a little dark natural first to inform sun big ye, I can inform uncle wang to let him go to the big ye sun (routing jump), also can directly find our sun, that is, of course, direct sun fang find show”, so, the big ye called him uncle li big ye sun then transferred the phone to small dark house. Here Uncle Li’s address book is called the routing table.

Uncle Li’s choice whether to directly find Uncle Sun or let Uncle Wang help transfer is called route selection.

Mr. Lee chose to find big ye are based on the sun directly, because he found big ye sun directly can one pace reachs the designated position, if you want to uncle wang transfer requires two steps to complete, the “step” is called “the hop”, the choice of the big ye li follows the principle of minimum steps (hop) (if he didn’t abide by the principle of one-inch could wait some more time to find a little dark, The end result may result in Uncle Li being fired for his poor work, which is called “too long delay, unreasonable route selection principle, changing a router”)

The routing tables on the Internet are always going around in this way, and if the central router goes down one day, that’s it, lots of points associated with it can’t find their destination, and you can’t get on the Internet.

Of course, things always change, One-inch and Ming quarreled, these days One-inch always call Xiao Ming, Ming thought: “fuck, is he saying bad things about me?” So Ming decided to eavesdrop on spot and Dark, but he can’t go out of the yard, what to do? Xiao Ming made this decision:

First of all he told his courtyard tube telephone wang uncle said: “you call li uncle said small dark moved to our yard, later every call to his phone I will pick up”, Wang uncle did not reflect (after all, old ah!) Give li big ye made a phone call, said: “now I come to manage the small dark phone, Sun has left”, the result li big ye changed his address book, this is called routing fraud.

After little black again, uncle Li will transfer to uncle Wang (in fact, should be transferred to Uncle Sun), Uncle Wang received this phone to Xiao Ming (because he had agreed with Xiao Ming before), Xiao Ming received this phone pretend to be small dark and little Black correspondence. Because Xiaoming is guilty of the crime, afraid of tomorrow little spot and small dark meet to ask him face to face, so after the communication is broken, and his own in the name of small dark through a phone to repeat the words just now, there is this call data eavesdropping.

Later, Spot kept in touch with Dark, but ignored Ming. Ming said to himself, “I can’t always talk to Spot like this as Dark. What if I get caught one day?” So he thought of a more sinister way: “Simply I also don’t eavesdrop on your phone, you little dot is not to call me! That I let you also give small dark dozen can’t, hum!” How did he do it? Let’s see:

He contacted a group of evil friends, colluded with them, every day a fixed time together to call the small dark courtyard messenger room, content of anything, as long as the messenger room uncle Sun answered the phone, will hear “thunder, rain clothes ah!” , “the person is the person his mother gave birth to, the demon is the demon his mother gave birth to”, “your mother surname” and so on, listen to the head are big, do not listen to and not good, the phone keeps ringing ah! Finally, one day, Uncle Sun could not help Shouting: “I can’t stand pulling !!!!” “And hung himself and fainted!

This is the simplest DDoS attack, sun’s weak psychological ability is called “datagram processing module BUG”, Sun’s collapse is called” router crash “. If it is, and I will smile and their broad, for example, tell them, “I should have listened to the weather forecast, the clothes have closed 10 minutes before the” or “that your mother is a person or a demon” or “and your grandmother a surname” and so on, I this sound psychological is called “robust data processing, able to withstand any attack”, even so, Xiao Ming find a bunch of evil friends (chicken), the same can let Uncle Sun die.

Sun was paralyzed the big ye, one-inch was finally no longer call small dark, because no matter how he hit the other side is busy, this phenomenon is called “denial of service”, so xiao Ming’s approach has a name called “denial of service attack (DoS attack),” evil, is called a distributed denial of service attack (DDoS). Xiaoming finally quiet for a few days…

A few days later, a beautiful girl came to Xiao Ming’s yard. Her name was Xiao Li. Xiao Ming liked her very much. But Xiao Li has a handsome boyfriend and Xiao Ming can’t help it. Of course, here or to follow the above principle: xiao Li is not out of the yard. The man wanted to pick up Xiao Li and could only make a phone call, so Xiao Ming was ready to move again:

Do you still remember that Uncle Wang was the telephone manager in Xiaoming courtyard? The reason why he can manage the telephone is that he has an address book. There may be two children named Xiao Ming in the same yard, and they cannot be distinguished by their names, so there are only two items in each line of the address book:

Telephone (IP) House number (MAC)
1234567 Door 1 (this is Xiao Ming’s)
7654321 Door number two (this is Xiaoli’s)

. IP addresses correspond to MAC addresses

Uncle Wang has a short memory, but is that right? For example, when someone says “1234567”, Uncle Wang compares, “Oh, it’s door no.1”, he knocks at door No.1 to “listen to the phone”. If it’s “7654321”, he goes to door No.2 to “listen to the phone”.

This phone number is known as “IP address.”

The door number here is the legendary ‘MAC’ address of the nic (each NIC has a different MAC address, which is written into the nic chip by the nic manufacturer).

Xiao Ming thought, “Grandma, Lao Tzu can’t bubble you don’t want to bubble,” so he played wang uncle address book idea, after careful observation, careful preparation, he finally found wang Uncle has frequent urination problems (after all, is the old man ah…) , finally in a dark and windy day, Uncle Wang went to the toilet, Xiao Ming secretly touch into the room, carefully changed the address book……

A few days later, Xiao Li’s boyfriend called her again. The phone number of the other party was “7654321”. Uncle Wang looked at his address book and leaned:

Telephone (IP) House number (MAC)
1234567 Door 1 (this is Xiao Ming’s)
7654321 Door no. 1 (note: this was originally Xiaoli’s, but xiaoming changed it)

.

Uncle Wang did not know to change ah, then went to find a door xiaoming, xiaoming heart this beauty ah, he with xiaoli father’s tone of stern lessons between that man and xiaoli improper relationship between men and women, the result of that man respectfully hung up the phone. Of course Xiao Li didn’t know the whole thing was happening…

Ming’s behavior is called “ARP spoofing “, and Uncle Wang’s address book is called “ARP table”

Here we should note: Uncle Wang now has two address books, one is to record every yard of the reception room phone book, called “routing table”, one is now said to record the yard of detailed information book, called “ARP table “.

Uncle Wang’s system has one is written so that “every month to re-check the house number and phone corresponding this (that is, ARP table)”, this action is called “refresh ARP table”, each month time limit is called “refresh ARP table cycle”. So xiao Ming in order to let that man can never find xiao Li, after every month to secretly change that address book, but this is also had to do!

As a bonus, Ming is smart enough to change the address book (ARP table) to something like this:

Telephone (IP) House number (MAC)
1234567 Door 1 (this is Xiao Ming’s)
1234567 Door no. 2 (Note: This has been changed by Xiao Ming, but he temporarily dizziness changed the wrong)

When two Macs correspond to the same IP address, the computer will pop up a dialog box saying “Duplicate IP address appears.” Finally, Uncle Wang will be confused and inform door 1 and Door 2 that your phone number has been repeated. That way, Li knows that someone’s trying to sabotage her, a phenomenon called “scam exposed.”

Xiaomin knew that Xiaoming eavesdropped on his phone with xiaomin, so he and xiaomin agreed a password. Spot encrypts what he wants to say at home and tells Dark.

Ciphertext: Potatoes - > Wednesday, sweet potato - > treat, idiot - > little spot home.Copy the code

So Spot told Dark: potato stupid sweet potato. Xiaoming listened:?? Don’t understand… Depressed… It’s encrypted.

In addition, Xiao Li also knew that Xiao Ming changed his home phone number. So uncle Wang went to the door one by one to write down the phone number and the number of the house. And hide not allow outsiders to modify, only their own keys (password). This is IP address and MAC address binding. When someone changes their phone number, they have to ask Uncle Wang to change it. Trouble is trouble, but it’s safe. However, Xiaoming secretly matched the key of Uncle Wang secretly (theft password success), so he can also modify.

ARP spoofing (supplementary) :

Xiao wang and xiao zhang lived in A building (A, B computer on A network segment), to find, they must pass the guard at the gate of A big ye (gateway), and A big ye have A bad memory, according to zhang wang told him: I am xiao wang, I was in A room to the record, tells visitors, you go to A room for wang. Under normal circumstances, you want to find Xiao Wang, first find Uncle Zhang, and then Uncle Zhang tells you that Xiao Wang is in room A (the address of computer A).

If Xiao Zhang always says to Uncle Zhang: in fact, I am Xiao Wang… I’m in room B

So when you came to see Xiao Wang, Uncle Zhang told you xiao Wang was in room B… As a result, you took Xiao Zhang for Xiao Wang. You were taken in.

This is a case of ARP spoofing

There is a situation is, wang in the virus, the virus does not stop sending ARP packets, tell Small Zhang, I am the gatekeeper zhang Uncle, also tell others, I am Zhang Uncle, you want to go out, have to find me. Because Xiao Wang is not the real Uncle Zhang, many gatekeeper jobs (gateway) Xiao Wang can not do, as a result, many people can not access the Internet or to visit the website should not go to download viruses, this is session hijacking.

The storm about rising ARP firewall, simple understanding, is like this:

Wang to prevent ARP fraud, every period of time with gateway Zhang uncle said: I am wang, I am in A room, you don’t remember wrong ah…

For a while, and again, Uncle Zhang said, oh, I know. (Don’t bother asking if you have something to do.)

Here’s the problem:

Xiao Wang kept Shouting: “I am Xiao Wang, I am Xiao Wang”, Shouting ah shout, Uncle Zhang was bored to death; If all the people in the building do not listen to find zhang uncle say this sentence……. Uncle Zhang kept responding: “I know I know”. I’m afraid uncle Zhang has been saying “I know.” This person is coming and going, everyone is doing this to this big uncle, the gatehouse (gateway) is blocked.

1. People are busy in the corridor, which affects normal walking (the Internet speed is slow, and many ARP packets are passed)

2, This xiao Zhang, Xiao Wang, xiao XX… And so on dozens of hundreds of people shout ah shout ah, Uncle Zhang will have to keep the answer: good, I know, but also record down, there is no time to do other things. (Make the CPU load of network devices such as routers fully loaded)

What’s the solution?

  1. Don’t let a bunch of people are Shouting at Uncle Zhang, broadcast in a small area.

  2. Don’t yell too often and at long intervals.

Using the above method to guard against ARP viruses and spoofing, in some cases, is not worth the cost.

To deal with ARP viruses, the most thorough method is bidirectional IP and MAC binding between the switch port and the local port. This is really physical work. Can put the network management tired to death, anti-virus is very key

Read the illustration of TCP/IP

Returns the directory

Network protocol layering

Network protocol layering Corresponding OSI stratification The agreement Duties and responsibilities
The application layer Medical layer/presentation layer/session layer TELNET, SSH, HTTTP, SMTP, POP, SSL/TLS, FTP, MIME, HTML, SNMP and MIB, SIP and RTP,… Define the data format and interpret the data in the corresponding format.
The transport layer The transport layer TCP,UDP,UDP-Lite,SCTP,DCCP Define the port, confirm the identity of the application on the host, and deliver the packet to the corresponding application;
The network layer The network layer ARP,IPv4,IPv6,ICMP,IPsec Define THE IP address, confirm the network location of the host, use THE IP address for MAC address, and forward external network data packets.
The link layer Data link layer/physical layer Ethernet, Wireless LAN, PPP^(Twisted pair, wireless, fiber…) Group 0 and 1, define data frames, confirm the physical address of the host, and transmit data;

Network model communication flow

To concatenate the responsibilities of each layer of the model, a simple phrase can be used:

  • When you enter a url and press Enter, the application layer protocol formats the request packet. Then the transport layer protocol adds the port number of both sides, confirming the application of communication between the two sides; The network protocol then adds the IP addresses of both parties to confirm the network location of both parties. Finally, the link layer protocol adds the MAC addresses of the two parties to confirm their physical locations. At the same time, data is grouped to form data frames, which are broadcast and sent to the host of the other party through the transmission medium. For different network segments, the packet is first forwarded to the gateway router and finally sent to the target host after multiple forwarding. After receiving the packet, the target machine uses the corresponding protocol to assemble the frame data, and then parses the frame data through layer by layer protocol. Finally, the frame data is parsed by the protocol of application layer and handed to the server for processing.

Read the illustration of TCP/IP

Today, I finally finished reading “Schematic TCP/IP” and said my feelings about it.

First of all, this is a popular network protocol introduction books, suitable for small white network reading.

The book describes TCP/IP protocol family layer by layer according to the seven-layer network model. Common protocols such as IP, TCP, and UDP are explained in detail. Used to understand the computer network knowledge is a good choice.

The book is like a dictionary, slightly dry, but with lots of illustrations to help you understand, it’s not bad. Which introduces many knowledge points, mostly not too deep, some of the nouns are not too clear explanation, need to look at baidu side…… In addition, the book was published in July 2013 (printed in 2020) and some of the content is out of date (without affecting the quality of the book). There is a slight mention of HTTP and network secrecy. If you want to know more, please refer to the Illustrated HTTP. In general, reading is recommended.

Note: Network protocols are designed by humans to communicate between network devices. Its design accords with the communication habit of human beings, and it is suggested to understand the network protocol with human thinking.

The road ahead is long, and I see no end.

Reference documentation

  • The gateway DNS routing | CSDN – yugui_huang0305 DHCP

  • A simple TCP/IP protocol stack | blog garden – a pixel

Postscript: Hello friends, if you think this article is good, remember to give a thumbs-up or star, your thumbs-up and star is my motivation to write more and richer articles!Making the address

Document agreement



dbThe document library 由 dbusingCreative Commons Attribution – Non-commercial Use – Same way Share 4.0 International LicenseGrant permission.

Based on thegithub.com/danygitgitOn the creation of works.

Use rights other than those authorized by this License agreement may be obtained from
Creativecommons.org/licenses/by…Obtained.