Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CPU: brother Nic, how on earth do you work?

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > IT Information >

Share

Shulou(Shulou.com)11/24 Report--

This article comes from the official account of Wechat: programming Technology Universe (ID:xuanyuancoding), author: Xuanyuan Wind O

A Q visited me as a network card, living on a motherboard in a chassis, responsible for the network communication of the whole computer. Without me, this place would have become an isolated island of information. It would be too boring.

Last weekend, the server was cut off for maintenance. It was a rare break for me. I was going to take a nap.

As soon as I closed my eyes, Ah Q from workshop No. 1 of CPU came to visit.

"how come it's you, boy? I heard you said a lot of bad things about me behind my back! why did you think of me today?"

"Brother Network Card, who are you listening to this rumor? I have wanted to visit you for a long time. I am not usually too busy to get away from my work. I asked for you as soon as I was free from the power outage today." Ah Q said with a smile.

"you are a very busy man. You go to the three temples for everything. Come on, what can I do for you?"

Ah Q smiled awkwardly and politely. "then I'll come straight to the point. it's the end of the year, isn't it? our factory has recently evaluated excellent students. I want to learn some network knowledge. I've come to ask you for advice."

"this is it. Come and sit inside." I invited Ah Q to come in and sit down.

As soon as he was seated, Ah Q could not help asking, "Brother, how does your network card work?" I heard that you can catch data packets from other hosts? can you show me something? "

"Oh, not anymore," I sighed.

"what's the matter?"

I looked up and began to tell Ah Q my story.

The era of hubs a long time ago, when all the computers in the network were connected by a guy called Hub Hub, through hubs, we all physically formed a star network and gave it a name: Ethernet. At that time, our transmission speed could achieve 10Mbps, in that era, it was already very remarkable.

The hub guy, I don't know whether to call him stupid or lazy. He never cares who sends the data to whom. It's just an emotionless forwarding machine that works at the physical layer. After an enhanced processing, the received signal is sent to all ports.

In this way, we logically become a bus network. The bus is a common resource, shared by all the hosts connected to it, and others have to wait while someone is transmitting the data, otherwise the data will conflict and get messed up.

In order for everyone to coexist peacefully and not to be unhappy in order to scramble for routes, we have made a set of rules: CSMA/CD.

Every time I have to send data, I have to monitor whether the line is free, and if someone else is transmitting data, I have to wait. As for how long to wait, I don't know, because it's a random value.

When I am free, I can send the data. However, while sending, I also have to check whether there is a conflict, because there may be others like me who think that they are sending data when they are free.

So this is where the CSMA / CD-- carrier sense multiple access / collision detection name comes from.

But if the length of the data is too short, I will send it quickly, and the vanguard is still on the way, and then I will not be able to find out if I encounter a conflict after that. In order to deal with this situation, we have to consider that even in extreme cases, we can still detect conflicts.

The maximum distance that our network can support is 2500 meters, and in extreme cases, conflicts occur only when they reach the farthest end. The collision signal has to be sent back before I finish sending the last bit, which is 5000 meters this time.

It takes 57.6 microseconds for the signal on the line to run back and forth, and our transmission speed is 10Mbps. I can send 576bit in a round trip, that is, 72 bytes. Except for the 8-byte frame leader and the frame start character, the remaining Ethernet frame length can not be less than 64 bytes, so that even collisions at the farthest ends can be transmitted back and forth in time to be detected.

With this set of agreements, everyone can concentrate on their work instead of fighting over them.

"I said," Why does it have to be at least 64 bytes before you send it? there is still this history! so how exactly do you send and receive data? " Speaking of which, Ah Q interrupted me.

"then listen to me and continue to tell you."

In the process of receiving and sending data, my daily job is to receive and send data packets. after the operating system gives me the data, I encapsulate the data into Ethernet frames and send them out according to the Ethernet data format.

The header of the frame has the address of the recipient and sender. We call it the MAC address. This is the ID number of each of our network cards, which has been determined from the moment we were born.

The sender is my MAC address, but I don't know the recipient's address. The data packet given to me by the operating system protocol stack department has only the IP address, and we don't know this. We only use the MAC address to send and receive data frames.

In order to solve this problem, we have developed a set of protocols: ARP, address resolution protocol, to achieve the translation of these two addresses. Send a broadcast when you don't know the MAC address corresponding to IP. The sender address of this broadcast is mine, and then the recipient address is FF:FF:FF:FF:FF:FF, which is a special MAC address. We agreed that everyone should receive the broadcast and not discard it.

This broadcast filled in the IP address, who received it and found a match with their own will answer me, so that I can know the other party's MAC address, and then can communicate.

Of course, in order to avoid wasting time asking each time, I will cache the queried records so that I can use them directly next time.

However, this also has security risks, if someone pretends to be the real recipient to reply to me, I can not tell, this is called ARP deception.

"Oh, wait, you'd better tell me how you can get other people's communication data. I'm more interested in this." Ah Q interrupted me again.

Because the hub guy forwarded it around with his eyes closed, no matter who sent the data, everyone could see it.

Because of this, there is a lot of data flowing in the bus every day, but I usually don't grab all of it and give it to you to deal with, otherwise you CPU people will probably scold me to death. So every time I get a data frame, I check to see if it is addressed to me, and if not, I just throw it away, with the exception of the broadcast message I mentioned earlier.

The secret that I can catch other people's communication data is: I provide a working mode called hybrid mode, in this mode, I will capture all the data frames I see in the bus and give them to you CPU to deal with. Generally, it is some packet grabbing software that requires me to do this, but there are also some rogue software and virus Trojans that often let me grab other people's data packets. So they can sniff the communications of other hosts in the network.

I don't like this, because every time I turn on hybrid mode, your CPU and I are so busy that the fans on the motherboard will spin like crazy.

"I see, so if you turn on the mixed mode and show me, you can see other people's communication data, this is so exciting!" Ah Q interrupted me again.

"Don't worry, listen to me go on, don't keep interrupting me, and now the power is out, I don't think I can show anything?"

"all right, you go on, I won't interrupt."

I don't know when the switch era began, and even if I turned on hybrid mode, I couldn't catch other people's packets, because I found that the packets in the network were only relevant to me.

Later, upon inquiry, I found out that it was not only my network card, but also the others.

It turned out that the guy in the hub had retired, and a new boss called the switch took his place.

This big guy lives up to his reputation. Not only does he simply connect everyone together, he also learns to write down everyone's MAC address and connection port number with a table. Every time the data is received, it is only forwarded to the corresponding port, not forwarded everywhere like a hub. I can no longer see other people's communication data!

"Ah? that guy on the switch is really troublesome!" Ah Q showed a disappointed expression.

This is also a good thing, ah, the switch boss does not have to forward data everywhere to occupy the line, which is equivalent to isolating the conflict domain. I only have my own data on the line I connect, and there is no data of others. There will be no conflict with other host data transmission. Not only that, the network cable we connected has also been upgraded, and now we can communicate in full duplex, receive and send at the same time, without having to conflict with the downlink data sent to me by the switch!

Isolation collision domain + full-duplex communication, now no longer use CSMA / CD, because there will be no collisions, you can send data at will, it's so cool! Our transmission speed is also changing with each passing day, from 10Mbps to 100Mbps, and then to 1000Mbps, faster and faster, which was unthinkable before.

Ah Q nodded and said, "impressive, Brother Network Card!" what a blessing. "

With that, Liu Liu of CPU No. 6 workshop appeared at the door and saw him sweating all over his head and said, "Brother Q, I can't find you everywhere. There you are. Go back. The leader told us to go on a trip."

Not finished to be continued

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

IT Information

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report