5

How would I detect in code whether a computer's Ethernet port is Auto-MDIX, and therefore can use a regular Ethernet cable (-not crossover) to connect to another computer?

I've looked in NetworkInterface's properties and searched for this, but I might be using the wrong search terms.

Both .net and UWP welcome.

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • The PC connector is never cross-over. Only cable. To check cable you have to look at connectors at both ends and see if two wires are crossed. A regular cable both ends will have wires that look flat. A cross-over cable one end you will see two wires that are not flat. You will never see a cable with cross-over on both ends. – jdweng Jul 12 '17 at 17:57
  • @jdweng According to the linked Wikipedia page and [this](https://stackoverflow.com/questions/45056235/communicate-between-computers-through-ethernet-cable#comment77087838_45056948) comment to another question of mine - modern ports are auto-detect, and don't need a crossover cable. – ispiro Jul 12 '17 at 18:01
  • Yes some hubs/modems will auto detect, but not PC. You don't want both the modem and PC to be auto detecting at same time. – jdweng Jul 12 '17 at 18:08
  • 5
    That's incorrect. PCs can certainly implement Auto-MDIX and many do. Note that all 1000Base-T (GigE) ports have a built-in equivalent to Auto-MDIX (transmit/receive negotiation per pair) and will work. – NetMage Jul 12 '17 at 18:33
  • 4
    @jdweng Auto MDI-X is designed to work on both sides. It uses a random generator to avoid getting constantly unmatched interfaces. – Zac67 Jul 12 '17 at 20:32
  • @jdweng A "crossover cable on both sides" is TIA568B for TIA568A standard and vice versa and totally equivalent to a straight cable. A crossover uses TIA568A pinout on one side and TIA568B on the other. – Zac67 Jul 13 '17 at 20:37
  • As @NetMage alludes to, the 1000BASE-T standard actually requires interfaces to implement Auto-MDI/X, so all gigabit ethernet copper interfaces will do this, even on PCs. – Ron Maupin Jul 13 '17 at 20:37
  • Sorry Ron, Auto MDI-X is still optional for 1000BASE-T interfaces, check Clause 40.4.4. Since it comes "for free" (1000BASE-T ports don't require any additional hardware to implement), practically all GbE interfaces implement it. – Zac67 Jul 13 '17 at 20:43
  • See section 40.8.2 - effectively 100Base-T requires Auto-Negotiation so it requires something that acts like Auto-MDI-X for 1000Base-T connections. If you are connecting below 1Gbps, then it depends on the NIC. – NetMage Jul 13 '17 at 21:01
  • @NetMage 1000BASE-T requires Autonegotiation, but it doesn't require Auto MDI-X (ie. when connecting to 10BASE-T or 100BASE-TX devices) which is what Clause 40.4.4 explictly says: "Implementation of an automatic MDI/MDI-X configuration is optional for 1000BASE-T devices." With a 1000BASE-T link, Clause 40.8.2 comes into play, where all pairs need to be crossed (and matched in the PCS sublayer) but this is NOT Auto MDI-X. Note that a (hypothetical) 1000BASE-T crossover differs from a 100BASE-TX/10BASE-T one. – Zac67 Jul 14 '17 at 11:20
  • In the context of the original question ("to connect to another computer"), I doubt if 10Base-T or even 100Base-T is relevant today. Can there be such a thing as a 1000Base-T crossover cable? – NetMage Jul 14 '17 at 15:51
  • A gigabit crossover is described in Clause 40.8.2 - crossing all four pairs - but it's not used in practice because it's not necessary. It's a frequent misconception that 1000BASE-T uses Auto MDI-X but that's only for 10/100BASE-TX. – Zac67 Jul 15 '17 at 13:37

1 Answers1

5

The Windows NDIS drivers are ignorant about layer 1 details such as full or half duplex and MDI/MDI-X status. Some drivers obviously expand on that so that a custom tool can display these details, but these extensions are proprietary and there's no standard way to access the information - if at all.

Zac67
  • 2,761
  • 1
  • 10
  • 21