"Nic" (Mac + PHY) Knowledge

Source: Internet
Author: User

An Ethernet NIC consists of two layers of the OSI (open-party system interconnection) model. Physical Layer and data link layer. The physical layer defines the electrical and optical signals, line statuses, clock baselines, data encoding, and circuits required for data transmission and receiving, and provides standard interfaces to data link layer devices. The data link layer provides addressing mechanisms, data frame construction, data error check, transfer control, and standard data interfaces to the network layer.

1. Basic Nic Structure

The data link layer chip in an Ethernet Card is generally called a Mac controller, while the physical layer chip is called a Phy. Many Nic chips enable Mac and PHY functions as one chip, such as Intel 82559 nic and 3Com 3c905 Nic. However, the Mac and PHY mechanisms still exist independently, but the appearance is in the form of a single chip. Of course there are also a lot of network card Mac and PHY is made separately, such as D-LINK DFE-530TX.

2. What is Mac?

First, let's talk about the functions of the Mac chip of the Ethernet Card. The Ethernet data link layer actually contains the MAC (Media Access Control) Sub-layer and the LLC (Logical Link Control) Sub-layer. An Ethernet Card Mac chip not only needs to implement MAC Sub-layer and LLC sub-layer functions, but also provides a compliant PCI interface for data exchange with the host.

After Mac receives an IP packet (or a packet from other network layer protocols) from the PCI bus, it splits the packet and repacks it into a frame with a maximum of 1518 bytes and a minimum of 64 bytes. This frame includes the target MAC address, the source MAC address, and the protocol type in the data packet (for example, the IP data packet type is expressed as 80), and the last DWORD (4 bytes).

But where does the target MAC address come from? This involves an ARP Protocol (a protocol between the network layer and the data link layer ). When transmitting data from a destination IP address for the first time, an ARP packet is first sent, and the target MAC address of the packet is the broadcast address, which says, "Who is XXX. xxx. xxx. the host of the IP address XXX?" Because it is a broadcast package, all hosts on this LAN have received this ARP request. The host that receives the request compares the IP address with its own IP address. If the IP address is different, the host rejects the request. If the IP address is the same, the host sends an ARP response packet. The host with this IP address replies to the ARP response after receiving this ARP request packet and says, "I am the master of this IP address ". This package contains his MAC address. The target MAC address of the frame for this IP address will be determined later. (Other protocols, such as IPX and SPX, also have corresponding protocols to complete these operations .)

The relationship between the IP address and the MAC address is stored in the host system, which is called the ARP table, which is completed by the driver and the operating system. In Microsoft, you can run the ARP-a command to view the ARP table. The same is true when data frames are received. After CRC is completed, if there is no CRC verification error, the frame header will be removed and the data packets will be transmitted to the driver and the upper-layer protocol inn through a standard excuse, in the end, our application will be correctly implemented. There are also some control frames. For example, the traffic control frame also needs to be recognized and executed by the Mac directly.

One end of the Ethernet MAC chip is connected to the computer PCI bus, and the other end is connected to the PHY chip. The Ethernet physical layer also includes the MII/gmii (Media independent interface) Sub-layer, PCs (physical encoding sub-layer), PMA (physical media attached) Sub-layer, and PMD (physical media related) child layer and MDI child layer. The PHY chip is one of the important functional devices for implementing the physical layer. It implements all the features of the front physical layer.

3. network transmission process

When sending data, phy receives data from MAC (for phy, there is no frame concept, and for it, it is data regardless of the address, data or CRC ), an Error Code of 1 bit is added for every 4 bits. Then, parallel data is converted into serial stream data, and the data is encoded according to the physical layer encoding rules (NRZ encoding of 10based-t or Manchester encoding of 100based-t, then the analog signal is used to send the data. Otherwise.

Another important feature of PHY is to implement some CSMA/CD functions. It can detect whether data is being transmitted on the network. If data is being transmitted, it waits. Once it detects that the network is idle, it waits for a random time and sends the data out. If the two NICs send data at the same time, a conflict occurs. At this time, the conflict detection organization can detect the conflict and wait for a random time to resend the data. This random time is very exquisite. It is not a constant. The random time calculated at different times is different, there are multiple algorithms to cope with the second conflict between the two hosts with low probability.

Many netizens like to use a network card with strong "snatching" when connected to internt bandwidth, because different methods for calculating the random time after PHY collision are designed differently, this makes some NICs "take advantage ". However, leeching is only applicable to the broadcast domain network and does not make sense for the point-to-point connection between the exchange network and ADSL to the local device, in addition, "leeching" is only relative, and there will be no qualitative changes.

4. Network conflicts

Now, the popularity of switches has made exchange networks more popular, reducing the number of conflicting domain networks and greatly increasing the network bandwidth. However, if you use a hub or shared bandwidth to access the Internet, it is still in a conflicting domain network, with a conflict or collision. The biggest difference between a vswitch and a hub is that one is a LAN exchange device that builds a point-to-point network, and the other is a LAN interconnection device that builds a conflicting domain network.

Phy also provides important functions for connecting to the peer device, and displays the current connection status and working status through the LED lights. When the network card is connected to the network card, phy continuously sends pulse signals to detect that there are devices on the peer end. they communicate with each other in a standard "language, negotiate with each other and determine the connection speed, duplex mode, and whether to use flow control. Generally, the negotiation result is the maximum speed and the best duplex mode supported by both devices. This technology is called auto negotiation or Nway. They mean automatic negotiation.

5. Output part of phy

Now let's take a look at the following part of the output of Phy. When a CMOS chip is working, the signal level is always greater than 0 V (depending on the chip's process and design requirements ), however, if such a signal is sent to a location of 100 meters or longer, there will be a great loss of DC components. In addition, if the external network is directly connected to the chip, electromagnetic induction (Thunder) and static electricity can easily cause damage to the chip.

In addition, if the grounding method of the device is different, the power grid environment may cause the 0 V levels of both parties to be inconsistent. In this way, the signal is transmitted from A to B because the 0 V level of the device is different from the 0 V level of the B point, this will lead to a large amount of current flowing from devices with high potential to devices with low potential. How can we solve this problem?

The transformer (isolating transformer) device appears. It filters the differential signals sent by PHY with the difference mode coupled coil to enhance the signal, and is coupled to the other end of the connected network cable through the electromagnetic field conversion. In this way, not only does the network cable and the PHY have no physical connection, but the signal is transferred instead, the DC component in the signal is cut off, and data can be transmitted in devices of different 0 V levels.

The isolating transformer is designed to withstand 2kv ~ 3kv voltage also plays a role in Lightning Protection (I personally think it is inappropriate to use lightning protection. Some of my friends' network devices are easily burned out during thunderstorms. Most of them are caused by unreasonable PCB design, and most of them burn down the interfaces of the devices, with few chips burned out, isolation transformer plays a protective role.

6. About transmission media

The isolating transformer itself is a passive component. It only coupling the PHY signal to the network cable and does not play the role of power amplification. Who determines the maximum distance for a NIC signal transmission? The maximum transmission distance of a network adapter and its compatibility with the peer device are determined by Phy. However, the output power of the PHY that can send a signal more than 100 meters is also relatively large, which is more prone to EMI problems. At this time, a suitable transformer should be used with it. The former company, Marvell, is often able to send 180 ~ The distance of 200 meters far exceeds the IEEE Standard of 100 meters.

The connector of the RJ-45 realizes the connection between the nic and the network cable. It has eight copper clips that can be connected to four pairs of twisted-pair (8) wires in the network cable. In the M network, 1 and 2 send data, and 3 and 6 receive data. 1 and 2 are a pair of differential signals, that is to say, their waveforms are the same, but the phase difference is 180 degrees, and the voltage ranges at the same time are positive and negative. Such signals can be transmitted further and provide strong anti-interference capabilities. Similarly, 3 and 6 are also differential signals. The eight cables in the network cable are twisted together to form a pair. When creating a network cable, make sure that 1 and 2 are in one pair, and 3 and 6 are in one pair. Otherwise, the connection may fail or be unstable when the network cable is used for long distances.

The new PHY now supports the auto MDI-X feature (also requires transformer support ). It can realize the transfer signal line on 1 and 2 of RJ-45 interface and the function of receiving signal line on 3 and 6 automatically exchange with each other. Some PHY even supports automatic switching of positive and negative signals in a pair of lines. In this way, you don't have to worry about using a straight-through or cross-network cable to connect to a device. This technology has been widely used in vswitches and SoHo routers.

In the 1000basd-t network, the most common transmission mode is to use all four pairs of twisted pair wires in the network cable, with 4, 5, 7, and 8 added to send and receive data together. Because the 1000based-t network specification contains the auto MDI-X function, it is not strictly determined their outgoing or receiving relationship, depending on the specific negotiation results of both parties.

7. Communication between PHY and Mac

Next, let's take a look at how data is transmitted and communicated between PHY and Mac. Use the standard MII/gigamii (Media independedinterfade) interface defined by IEEE to connect Mac and PHY. This interface is defined by IEEE. The MII interface controls all the data and data on the network. Mac determines the operating status of the PHY and controls the PHY by using the SMI (Serial managementinterface) interface to read and write the PHY register. Some registers in the PHY are also defined by IEEE. In this way, the PHY reflects its current status to the Register, mac constantly reads the Status Register of the PHY through the SMI bus to get the current PHY status, such as connection speed and duplex capability. Of course, you can also set the register of the PHY through SMI to achieve the purpose of control. For example, if the throttling is enabled or disabled, the self-negotiation mode or the forced mode can be used.

We can see that both the MII interface of physical connection and the status registers and control registers of SMI bus and PHY have IEEE specifications. Therefore, Mac and PHY of different companies can coordinate their work. Of course, in order to match the features specific to PHY of different companies, the driver needs to be modified accordingly.

The implementation of the main functions of a NIC is basically the above. In addition, there is an EEPROM chip, usually a 93c46 chip. It records the NIC chip supplier ID, subsystem supplier ID, Nic MAC address, Nic configurations, such as the PHY address on the SMI bus and bootrom capacity, whether to enable the bootrom boot system. Many NICs also have bootrom. It is used to boot the operating system with a diskless workstation. Since there is no disk, some of the programs and protocol stacks necessary for boot are put in it, such as RPL and PXE. In fact, it is a standard PCI Rom. Therefore, some hard disk write protection cards can be implemented by burning the bootrom of the NIC. In fact, the ROM of the PCI device can be placed in the BIOS of the motherboard. The ROM can be detected and correctly identified when the computer is started. The configuration of AGP is the same as that of PCI in many places. Therefore, the BIOS of many graphics cards can also be placed in the BIOS of the motherboard. This is why we have never seen bootrom for onboard NICs.

8. Nic Power Supply

The final part is the power supply. Most NICs now use 3.3v or a lower voltage. Some are dual-voltage. Therefore, the power conversion circuit is required. In addition, in order to implement the wake on line function, the NIC must ensure that a very small portion of all the PHY and Mac servers are always in the active state, this requires converting the 5 V standby voltage on the motherboard to the power supply voltage. After the host is started on, the operating voltage of PHY should be replaced by the voltage transferred from 5 V to reduce the consumption of 5 V standby. (Many poor network cards do not do this ).

NICs with the wake on line function generally have a Wol interface. That is because pci2.1 previously did not have the PCI device to wake up the host, so a thread needs to be connected to the nanqiao through the wol interface on the motherboard to implement the wol function.

The new motherboard adapter generally supports pci2.2/2.3, and extends the PME # signal function. You can use the PCI bus to enable the wake-up function without that interface.

Conclusion

An Ethernet Card is composed of these parts. They work closely together and coordinate with each other to provide us with a stable and informed network access. The popularization of networks not only greatly increases work efficiency, but also enables us to freely ride in the ocean of the internet!

Annotation:

Is the analog signal or digital signal on the network cable? Answer: analog signal. Because it uses analog technology for outgoing and receiving. Although the information it sends is digital, rather than digital, the signal can be called a digital signal.

A simple example: we know that the phone is a simulated signal, but when we dial the Internet, the telephone line transmits digital information, but the signal itself is still simulated. However, ADSL also transmits digital signals over telephone lines. This depends on the technology it uses for outgoing and acceptable use.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.