{"id":80121,"date":"2026-03-04T12:09:48","date_gmt":"2026-03-04T04:09:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/80121.html"},"modified":"2026-03-04T12:09:48","modified_gmt":"2026-03-04T04:09:48","slug":"%e7%ae%80%e5%8d%95%e7%90%86%e8%a7%a3%ef%bc%9amac%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f%e5%8d%95%e7%89%87%e6%9c%ba%e4%bb%a5%e5%a4%aa%e7%bd%91%e9%80%9a%e4%bf%a1%e5%85%a8%e9%93%be%e8%b7%af%e6%98%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/80121.html","title":{"rendered":"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f"},"content":{"rendered":"<p>PHY \u662f\u7269\u7406\u5c42\u82af\u7247&#xff0c;MAC \u662f\u4ecb\u8d28\u8bbf\u95ee\u63a7\u5236\u5c42&#xff0c;\u4e24\u8005\u4e0d\u662f\u4e00\u56de\u4e8b\u3002<\/p>\n<h2>1. \u4e00\u53e5\u8bdd\u5206\u6e05&#xff1a;MAC vs PHY<\/h2>\n<ul>\n<li>MAC&#xff1a;\u7ba1 \u201c\u6570\u636e\u600e\u4e48\u6253\u5305\u3001\u53d1\u7ed9\u8c01\u201d&#xff08;\u6570\u5b57\u903b\u8f91&#xff0c;\u7eaf\u6570\u5b57\u7535\u8def&#xff09;<\/li>\n<li>PHY&#xff1a;\u7ba1 \u201c\u600e\u4e48\u628a\u6570\u636e\u53d8\u6210\u7f51\u7ebf\u4e0a\u7684\u7535\u4fe1\u53f7\u201d&#xff08;\u6a21\u62df &#043; \u6570\u5b57&#xff0c;\u5fc5\u987b\u5916\u63a5\u82af\u7247&#xff09;<\/li>\n<\/ul>\n<p>\u5b83\u4eec\u7684\u5173\u7cfb&#xff1a;<\/p>\n<p>MCU \/ CPU \u2192 MAC \u2192 MII\/RMII\/RGMII \u2192 PHY \u2192 \u7f51\u53e3\u53d8\u538b\u5668 \u2192 \u7f51\u7ebf<\/p>\n<h2>2. \u4f60\u6700\u5173\u5fc3\u7684&#xff1a;<\/h2>\n<h3>MAC \u5728\u54ea\u91cc&#xff1f;<\/h3>\n<p>MAC \u4e00\u822c\u662f\u96c6\u6210\u5728 MCU \/ \u5904\u7406\u5668\u5185\u90e8\u7684&#xff0c;\u4e0d\u662f\u72ec\u7acb\u82af\u7247&#xff01;<\/p>\n<ul>\n<li>\n<p>STM32F4\/F7\/H7\u3001IMX6UL\u3001IMX8\u3001ESP32\u3001GD32\u3001AT32 \u7b49\u2192 \u5185\u90e8\u81ea\u5e26 MAC\u2192 \u5fc5\u987b\u5916\u63a5 PHY&#xff08;\u6bd4\u5982 RTL8211E&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u53ea\u6709\u6781\u5c11\u6570\u8001\u82af\u7247 \/ \u4e13\u7528\u82af\u7247\u4f1a\u628a MAC&#043;PHY \u505a\u5728\u4e00\u8d77\u6bd4\u5982&#xff1a;ENC28J60\u3001W5500&#xff08;\u8fd9\u79cd\u53eb\u786c\u4ef6 TCP\/IP \u82af\u7247&#xff09;<\/p>\n<\/li>\n<\/ul>\n<h2>3. \u6240\u4ee5\u4f60\u4f1a\u9047\u5230\u4e09\u79cd\u4ee5\u592a\u7f51\u7ed3\u6784<\/h2>\n<h4>\u2460 \u6700\u5e38\u89c1&#xff1a;MCU \u5185\u7f6e MAC &#043; \u5916\u7f6e PHY<\/h4>\n<ul>\n<li>MAC&#xff1a;MCU \u5185\u90e8<\/li>\n<li>PHY&#xff1a;RTL8211E \/ KSZ9031 \/ YT8522 \u7b49\u2192 \u4f60\u73b0\u5728\u7528\u7684\u5c31\u662f\u8fd9\u79cd&#xff01;<\/li>\n<\/ul>\n<h4>\u2461 \u8001\u65b9\u6848&#xff1a;\u5916\u7f6e MAC &#043; \u5916\u7f6e PHY<\/h4>\n<ul>\n<li>MAC&#xff1a;\u72ec\u7acb\u82af\u7247&#xff08;\u5982 ENC28J60 \u91cc\u7684 MAC&#xff09;<\/li>\n<li>PHY&#xff1a;\u4e5f\u5728\u91cc\u9762\u2192 \u73b0\u5728\u5f88\u5c11\u7528<\/li>\n<\/ul>\n<h4>\u2462 \u5168\u96c6\u6210\u7f51\u5361\u82af\u7247&#xff08;MAC&#043;PHY \u4e00\u4f53&#xff09;<\/h4>\n<ul>\n<li>W5500\u3001CH395<\/li>\n<li>\u5185\u90e8 &#061; MAC &#043; PHY &#043; \u534f\u8bae\u6808\u2192 \u9002\u5408\u6ca1\u6709 MAC \u7684\u4f4e\u7aef MCU<\/li>\n<\/ul>\n<h2>4. \u76f4\u63a5\u56de\u7b54\u4f60\u7684\u95ee\u9898<\/h2>\n<p>\u95ee&#xff1a;MAC \u4e5f\u662f\u50cf PHY \u90a3\u6837\u7684\u72ec\u7acb\u82af\u7247\u5417&#xff1f;\u7b54&#xff1a;\u73b0\u4ee3\u7cfb\u7edf\u91cc\u57fa\u672c\u4e0d\u662f\u3002<\/p>\n<ul>\n<li>MAC \u5927\u591a\u5728 MCU\/CPU \u5185\u90e8<\/li>\n<li>PHY \u4e00\u5b9a\u662f\u72ec\u7acb\u82af\u7247&#xff08;Realtek\u3001Microchip\u3001\u88d5\u592a\u5fae\u8fd9\u4e9b&#xff09;<\/li>\n<\/ul>\n<h2>5. \u8d85\u7b80\u77ed\u603b\u7ed3&#xff08;\u65b9\u4fbf\u8bb0&#xff09;<\/h2>\n<ul>\n<li>MAC &#061; \u5185\u7f6e\u5728 MCU<\/li>\n<li>PHY &#061; \u5fc5\u987b\u5916\u63a5\u82af\u7247<\/li>\n<li>\u4ee5\u592a\u7f51 &#061; MAC &#043; PHY \u624d\u80fd\u5de5\u4f5c<\/li>\n<\/ul>\n<\/p>\n<hr \/>\n<p>\u201c\u914d\u7f6e\u597d MAC \u548c PHY \u901a\u4fe1\u201d \u53ea\u662f\u4ee5\u592a\u7f51\u5f00\u53d1\u7684\u57fa\u7840\u7b2c\u4e00\u6b65&#xff0c;\u5b8c\u6574\u7684\u4ee5\u592a\u7f51\u529f\u80fd\u5f00\u53d1\u8fd8\u9700\u8981\u8986\u76d6\u534f\u8bae\u6808\u3001\u6570\u636e\u6536\u53d1\u7b49\u73af\u8282\u3002\u6211\u7528\u65b0\u624b\u80fd\u542c\u61c2\u7684\u65b9\u5f0f&#xff0c;\u628a\u4ee3\u7801\u5f00\u53d1\u7684\u6838\u5fc3\u6b65\u9aa4\u62c6\u89e3\u6e05\u695a&#xff1a;<\/p>\n<h4>\u4e00\u3001\u5148\u660e\u786e\u6838\u5fc3\u7ed3\u8bba<\/h4>\n<p>\u4f60\u5199\u4ee3\u7801\u65f6&#xff0c;\u5fc5\u987b\u5148\u5b8c\u6210 MAC \u4e0e PHY \u7684\u901a\u4fe1\u914d\u7f6e&#xff08;\u8fd9\u662f\u4ee5\u592a\u7f51\u80fd\u5de5\u4f5c\u7684\u524d\u63d0&#xff09;&#xff0c;\u4f46\u4ec5\u8fd9\u4e00\u6b65\u8fd8\u4e0d\u591f&#xff0c;\u8fd8\u9700\u8981\u914d\u7f6e MAC \u672c\u8eab\u3001\u6302\u8f7d\u534f\u8bae\u6808\u3001\u5b9e\u73b0\u6570\u636e\u6536\u53d1\u903b\u8f91&#xff0c;\u624d\u80fd\u771f\u6b63\u7528\u4e0a\u7f51\u7ebf\u4f20\u8f93\u6570\u636e\u3002<\/p>\n<h4>\u4e8c\u3001\u4ee3\u7801\u5f00\u53d1\u7684\u5b8c\u6574\u6b65\u9aa4&#xff08;\u4ee5 STM32&#043;RTL8211E \u4e3a\u4f8b&#xff09;<\/h4>\n<h5>1. \u7b2c\u4e00\u6b65&#xff1a;\u6838\u5fc3\u524d\u63d0 \u2014\u2014 \u914d\u7f6e MAC \u4e0e PHY \u7684\u901a\u4fe1&#xff08;\u4f60\u5173\u6ce8\u7684\u91cd\u70b9&#xff09;<\/h5>\n<p>\u8fd9\u4e00\u6b65\u7684\u76ee\u6807\u662f\u8ba9 MCU \u5185\u7f6e\u7684 MAC \u80fd \u201c\u6307\u6325\u201d \u5916\u7f6e\u7684 PHY \u82af\u7247&#xff08;\u6bd4\u5982 RTL8211E&#xff09;&#xff0c;\u6838\u5fc3\u662f\u901a\u8fc7 MDIO\/MDC \u603b\u7ebf\u8bfb\u5199 PHY \u7684\u5bc4\u5b58\u5668&#xff1a;<\/p>\n<ul>\n<li>\u521d\u59cb\u5316 MDIO\/MDC \u5f15\u811a&#xff08;MAC \u548c PHY \u7684 \u201c\u63a7\u5236\u603b\u7ebf\u201d&#xff09;&#xff1b;<\/li>\n<li>\u8bfb\u53d6 PHY \u7684 ID \u5bc4\u5b58\u5668&#xff0c;\u9a8c\u8bc1 MAC \u80fd\u548c PHY \u901a\u4fe1&#xff08;\u6bd4\u5982 RTL8211E \u7684 ID \u662f 0x001CC916&#xff09;&#xff1b;<\/li>\n<li>\u914d\u7f6e PHY \u7684\u5de5\u4f5c\u6a21\u5f0f&#xff1a;\u6bd4\u5982\u5343\u5146\u5168\u53cc\u5de5\u3001\u81ea\u52a8\u534f\u5546\u3001\u4f7f\u80fd\u81ea\u534f\u5546\u3001\u5173\u95ed\u4f4e\u529f\u8017\u7b49&#xff1b;<\/li>\n<li>\u7b49\u5f85 PHY \u94fe\u8def\u72b6\u6001&#xff08;Link Up&#xff09;&#xff0c;\u786e\u8ba4\u7f51\u7ebf\u63d2\u597d\u4e14\u534f\u5546\u6210\u529f\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u4ee3\u7801\u7247\u6bb5&#xff08;STM32 HAL \u5e93&#xff09;&#xff1a;<\/p>\n<p>#include &#034;stm32f4xx_hal.h&#034;<br \/>\n#include &#034;lan8742.h&#034;  \/\/ \u901a\u7528PHY\u9a71\u52a8&#xff0c;\u9002\u914dRTL8211E<\/p>\n<p>\/\/ PHY\u5730\u5740&#xff08;RTL8211E\u9ed8\u8ba4\u662f0x01&#xff09;<br \/>\n#define PHY_ADDR 0x01<\/p>\n<p>\/\/ \u521d\u59cb\u5316MAC\u4e0ePHY\u901a\u4fe1<br \/>\nHAL_StatusTypeDef eth_phy_init(void)<br \/>\n{<br \/>\n  uint16_t phy_id &#061; 0;<\/p>\n<p>  \/\/ 1. \u521d\u59cb\u5316MDIO\/MDC\u603b\u7ebf&#xff08;MAC\u5e95\u5c42\u9a71\u52a8&#xff09;<br \/>\n  HAL_ETH_MDIO_Init(&amp;heth);<\/p>\n<p>  \/\/ 2. \u8bfb\u53d6PHY ID&#xff0c;\u9a8c\u8bc1\u901a\u4fe1\u662f\u5426\u6b63\u5e38<br \/>\n  phy_id &#061; ETH_ReadPHYRegister(&amp;heth, PHY_ADDR, PHY_REG_ID1);<br \/>\n  phy_id &#061; (phy_id &lt;&lt; 16) | ETH_ReadPHYRegister(&amp;heth, PHY_ADDR, PHY_REG_ID2);<\/p>\n<p>  \/\/ \u68c0\u67e5RTL8211E\u7684ID&#xff08;\u9ad8\u4f4d0x001C&#xff0c;\u4f4e\u4f4d0xC916&#xff09;<br \/>\n  if ((phy_id &amp; 0xFFFF0000) !&#061; 0x001C0000) {<br \/>\n    return HAL_ERROR; \/\/ MAC\u548cPHY\u901a\u4fe1\u5931\u8d25<br \/>\n  }<\/p>\n<p>  \/\/ 3. \u914d\u7f6ePHY&#xff1a;\u81ea\u52a8\u534f\u5546\u3001\u5343\u5146\u5168\u53cc\u5de5<br \/>\n  ETH_WritePHYRegister(&amp;heth, PHY_ADDR, PHY_REG_CTRL, PHY_CTRL_AUTONEG);<\/p>\n<p>  \/\/ 4. \u7b49\u5f85\u94fe\u8def\u5efa\u7acb&#xff08;Link Up&#xff09;<br \/>\n  uint32_t timeout &#061; 1000;<br \/>\n  while (timeout&#8211;) {<br \/>\n    if (ETH_ReadPHYRegister(&amp;heth, PHY_ADDR, PHY_REG_STATUS) &amp; PHY_STATUS_LINK) {<br \/>\n      return HAL_OK; \/\/ \u94fe\u8def\u6b63\u5e38<br \/>\n    }<br \/>\n    HAL_Delay(1);<br \/>\n  }<br \/>\n  return HAL_TIMEOUT; \/\/ \u94fe\u8def\u8d85\u65f6<br \/>\n}<\/p>\n<h5>2. \u7b2c\u4e8c\u6b65&#xff1a;\u914d\u7f6e MCU \u5185\u7f6e\u7684 MAC<\/h5>\n<p>PHY \u914d\u7f6e\u597d\u540e&#xff0c;\u9700\u8981\u521d\u59cb\u5316 MAC \u672c\u8eab\u7684\u5de5\u4f5c\u6a21\u5f0f&#xff1a;<\/p>\n<ul>\n<li>\u9009\u62e9 MAC \u7684\u63a5\u53e3\u7c7b\u578b&#xff08;\u6bd4\u5982 RGMII&#xff0c;RTL8211E \u5e38\u7528&#xff09;&#xff1b;<\/li>\n<li>\u914d\u7f6e MAC \u7684\u5de5\u4f5c\u6a21\u5f0f&#xff08;\u5168\u53cc\u5de5 \/ \u534a\u53cc\u5de5\u3001\u901f\u7387\u5339\u914d PHY \u534f\u5546\u7ed3\u679c&#xff09;&#xff1b;<\/li>\n<li>\u4f7f\u80fd MAC \u7684\u63a5\u6536 \/ \u53d1\u9001\u529f\u80fd&#xff1b;<\/li>\n<li>\u914d\u7f6e\u4e2d\u65ad&#xff08;\u6bd4\u5982\u63a5\u6536\u6570\u636e\u4e2d\u65ad\u3001\u94fe\u8def\u72b6\u6001\u53d8\u5316\u4e2d\u65ad&#xff09;\u3002<\/li>\n<\/ul>\n<h5>3. \u7b2c\u4e09\u6b65&#xff1a;\u6302\u8f7d\u7f51\u7edc\u534f\u8bae\u6808&#xff08;\u5173\u952e&#xff01;\u5426\u5219\u53ea\u80fd\u4f20\u88f8\u6570\u636e&#xff09;<\/h5>\n<p>\u5982\u679c\u53ea\u914d\u7f6e MAC \u548c PHY&#xff0c;\u53ea\u80fd\u6536\u53d1 \u201c\u88f8\u7684\u4ee5\u592a\u7f51\u5e27\u201d&#xff0c;\u65e0\u6cd5\u5b9e\u73b0 ping\u3001TCP\/UDP \u901a\u4fe1&#xff0c;\u5fc5\u987b\u6302\u8f7d\u534f\u8bae\u6808&#xff1a;<\/p>\n<ul>\n<li>\u8f7b\u91cf\u7ea7\u534f\u8bae\u6808&#xff1a;LWIP&#xff08;\u6700\u5e38\u7528&#xff0c;STM32 \u5b98\u65b9\u652f\u6301&#xff09;\u3001uIP&#xff1b;<\/li>\n<li>\u914d\u7f6e\u6b65\u9aa4&#xff1a;\u521d\u59cb\u5316 LWIP\u2192\u8bbe\u7f6e IP \/ \u5b50\u7f51\u63a9\u7801 \/ \u7f51\u5173\u2192\u521d\u59cb\u5316 ARP\/TCP\/UDP\u2192\u5f00\u542f\u534f\u8bae\u6808\u4efb\u52a1\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;LWIP \u521d\u59cb\u5316\u7247\u6bb5<\/p>\n<p>#include &#034;lwip\/netif.h&#034;<br \/>\n#include &#034;lwip\/tcpip.h&#034;<br \/>\n#include &#034;netif\/ethernetif.h&#034;<\/p>\n<p>struct netif gnetif; \/\/ \u7f51\u7edc\u63a5\u53e3\u7ed3\u6784\u4f53<\/p>\n<p>\/\/ \u521d\u59cb\u5316LWIP\u534f\u8bae\u6808<br \/>\nvoid lwip_init(void)<br \/>\n{<br \/>\n  ip4_addr_t ipaddr, netmask, gw;<\/p>\n<p>  \/\/ 1. \u8bbe\u7f6eIP\u5730\u5740&#xff08;\u6839\u636e\u4f60\u7684\u7f51\u6bb5\u6539&#xff09;<br \/>\n  IP4_ADDR(&amp;ipaddr, 192, 168, 1, 100);<br \/>\n  IP4_ADDR(&amp;netmask, 255, 255, 255, 0);<br \/>\n  IP4_ADDR(&amp;gw, 192, 168, 1, 1);<\/p>\n<p>  \/\/ 2. \u521d\u59cb\u5316TCP\/IP\u5185\u6838<br \/>\n  tcpip_init(NULL, NULL);<\/p>\n<p>  \/\/ 3. \u5c06MAC\/PHY\u7ed1\u5b9a\u5230LWIP\u7f51\u7edc\u63a5\u53e3<br \/>\n  netif_add(&amp;gnetif, &amp;ipaddr, &amp;netmask, &amp;gw, NULL, &amp;ethernetif_init, &amp;tcpip_input);<br \/>\n  netif_set_default(&amp;gnetif);<br \/>\n  netif_set_up(&amp;gnetif); \/\/ \u542f\u7528\u7f51\u7edc\u63a5\u53e3<br \/>\n}<\/p>\n<h5>4. \u7b2c\u56db\u6b65&#xff1a;\u5b9e\u73b0\u4e1a\u52a1\u903b\u8f91&#xff08;\u6536\u53d1\u6570\u636e&#xff09;<\/h5>\n<p>\u534f\u8bae\u6808\u914d\u7f6e\u597d\u540e&#xff0c;\u5c31\u53ef\u4ee5\u5199\u5177\u4f53\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\u5b9e\u73b0 ping \u54cd\u5e94&#xff08;LWIP \u81ea\u5e26&#xff0c;\u53ea\u9700\u5f00\u542f&#xff09;&#xff1b;<\/li>\n<li>\u5b9e\u73b0 TCP \u670d\u52a1\u5668 \/ \u5ba2\u6237\u7aef&#xff08;\u6bd4\u5982\u76d1\u542c\u7aef\u53e3\u3001\u6536\u53d1\u6570\u636e&#xff09;&#xff1b;<\/li>\n<li>\u5b9e\u73b0 UDP \u5e7f\u64ad \/ \u5355\u64ad&#xff1b;<\/li>\n<li>\u5904\u7406\u94fe\u8def\u4e2d\u65ad&#xff08;\u6bd4\u5982\u7f51\u7ebf\u65ad\u5f00\u65f6\u7684\u5f02\u5e38\u5904\u7406&#xff09;\u3002<\/li>\n<\/ul>\n<h2>\u4e09\u3001\u65b0\u624b\u6700\u5bb9\u6613\u8e29\u7684\u5751&#xff08;\u5b8c\u6574\u7248&#xff09;<\/h2>\n<p>\u8fd9\u4e9b\u90fd\u662f\u4f60\u5199 MAC &#043; PHY&#xff08;RTL8211E&#xff09; \u4ee3\u7801\u65f6&#xff0c;100% \u4f1a\u9047\u5230\u7684\u95ee\u9898&#xff1a;<\/p>\n<h3>1. MDIO\/MDC \u6ca1\u914d\u7f6e\u5bf9 \u2192 \u6839\u672c\u8bfb\u4e0d\u5230 PHY<\/h3>\n<ul>\n<li>\u73b0\u8c61&#xff1a;\u8bfb PHY ID \u8bfb\u4e0d\u51fa\u6765\u3001\u4e00\u76f4\u8d85\u65f6<\/li>\n<li>\u539f\u56e0&#xff1a;\n<ul>\n<li>GPIO \u6a21\u5f0f\u9519\u4e86&#xff08;\u5e94\u8be5\u5f00\u590d\u7528\u529f\u80fd \/ \u63a8\u633d&#xff09;<\/li>\n<li>MDC \u65f6\u949f\u592a\u5feb\u6216\u592a\u6162<\/li>\n<li>PHY \u5730\u5740\u9519\u4e86&#xff08;RTL8211E \u5e38\u7528 0 \u6216 1&#xff0c;\u770b\u786c\u4ef6\u8d70\u7ebf&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u7ed3\u679c&#xff1a;MAC \u6839\u672c\u7ba1\u4e0d\u4e86 PHY<\/li>\n<\/ul>\n<h3>2. \u53ea\u521d\u59cb\u5316 PHY&#xff0c;\u6ca1\u521d\u59cb\u5316 MAC<\/h3>\n<ul>\n<li>\u73b0\u8c61&#xff1a;PHY \u94fe\u8def UP \u4e86&#xff0c;\u4f46\u53d1\u4e0d\u51fa\u3001\u6536\u4e0d\u5230<\/li>\n<li>\u539f\u56e0&#xff1a;\n<ul>\n<li>MAC \u6ca1\u5f00\u53d1\u9001 \/ \u63a5\u6536<\/li>\n<li>MAC \u6ca1\u914d\u7f6e RGMII \/ RMII \u6a21\u5f0f<\/li>\n<li>\u6ca1\u914d\u7f6e\u901f\u7387\u3001\u53cc\u5de5&#xff08;\u8981\u548c PHY \u534f\u5546\u7ed3\u679c\u4e00\u81f4&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>3. MAC \u548c PHY \u63a5\u53e3\u6a21\u5f0f\u4e0d\u5339\u914d<\/h3>\n<ul>\n<li>RGMII \/ RMII \/ MII \u5fc5\u987b\u786c\u4ef6 &#043; \u8f6f\u4ef6\u4e00\u81f4<\/li>\n<li>\u4f60\u7528 RTL8211E \u4e00\u822c\u662f RGMII<\/li>\n<li>\u9519\u4e86\u76f4\u63a5\u4e0d\u901a<\/li>\n<\/ul>\n<h3>4. \u81ea\u534f\u5546\u5f00\u4e86&#xff0c;\u4f46\u8f6f\u4ef6\u6ca1\u8bfb\u534f\u5546\u7ed3\u679c<\/h3>\n<ul>\n<li>PHY \u81ea\u52a8\u534f\u5546\u51fa&#xff1a;1000M \u5168\u53cc\u5de5<\/li>\n<li>\u4f46\u4f60 MAC \u8fd8\u56fa\u5b9a\u5728&#xff1a;100M \u534a\u53cc\u5de5<\/li>\n<li>\u7ed3\u679c&#xff1a;\u80fd Link \u4f46\u4e0d\u901a \/ \u4e22\u5305\u4e25\u91cd<\/li>\n<\/ul>\n<p>\u6b63\u786e\u505a\u6cd5&#xff1a;<\/p>\n<li>\u7b49\u5f85 PHY \u94fe\u8def UP<\/li>\n<li>\u8bfb PHY \u5bc4\u5b58\u5668\u62ff\u5230 \u901f\u7387 &#043; \u53cc\u5de5<\/li>\n<li>\u628a\u7ed3\u679c\u5199\u56de MAC<\/li>\n<h3>5. LWIP \u5e95\u5c42\u63a5\u53e3\u6ca1\u5bf9\u63a5\u597d<\/h3>\n<ul>\n<li>\u4f60\u914d\u7f6e\u5b8c MAC&#043;PHY \u53ea\u662f\u786c\u4ef6\u901a\u4e86<\/li>\n<li>\u4f46 LWIP \u4e0d\u77e5\u9053\u600e\u4e48\u53d1\u3001\u600e\u4e48\u6536<\/li>\n<li>\u5fc5\u987b\u5b9e\u73b0\u4e24\u4e2a\u51fd\u6570&#xff1a;\n<ul>\n<li>low_level_output() \/\/ \u534f\u8bae\u6808 \u2192 MAC \u53d1\u5e27<\/li>\n<li>low_level_input() \/\/ MAC \u2192 \u534f\u8bae\u6808\u6536\u5e27<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>6. \u65f6\u5e8f \/ \u7535\u5e73\u95ee\u9898&#xff08;RGMII \u7279\u522b\u5e38\u89c1&#xff09;<\/h3>\n<ul>\n<li>RGMII \u9700\u8981 \u5185\u90e8\u5ef6\u8fdf\u6216\u5916\u90e8\u5ef6\u8fdf<\/li>\n<li>\u6709\u4e9b MCU \u8981\u5f00 MAC \u5185\u90e8\u5ef6\u8fdf<\/li>\n<li>\u6709\u4e9b\u9760 PCB \u4e0a\u7684\u7535\u963b \/ \u8d70\u7ebf\u8865\u507f<\/li>\n<li>\u9519\u4e86&#xff1a;\u5343\u5146\u4e0d\u901a&#xff0c;\u767e\u5146\u80fd\u901a<\/li>\n<\/ul>\n<h3>7. \u4e2d\u65ad\u6216 DMA \u6ca1\u5f00<\/h3>\n<ul>\n<li>\u4ee5\u592a\u7f51\u4e00\u822c\u7528 DMA &#043; \u63cf\u8ff0\u7b26<\/li>\n<li>\u4f60\u4e0d\u521d\u59cb\u5316\u63cf\u8ff0\u7b26\u3001\u4e0d\u5f00 DMA<\/li>\n<li>\u6570\u636e\u6839\u672c\u4e0d\u4f1a\u81ea\u52a8\u6536\u53d1<\/li>\n<\/ul>\n<h2>\u56db\u3001\u7ed9\u4f60\u4e00\u53e5\u6700\u5b9e\u7528\u7684\u603b\u7ed3<\/h2>\n<p>\u5199\u4ee5\u592a\u7f51\u4ee3\u7801 &#061; \u505a 3 \u4ef6\u4e8b<\/p>\n<li>\u7528 MDIO\/MDC \u628a PHY \u914d\u7f6e\u597d\u3001\u8bfb\u5230\u94fe\u8def\u72b6\u6001\u4e0e\u534f\u5546\u901f\u7387<\/li>\n<li>\u628a\u534f\u5546\u7ed3\u679c\u914d\u7f6e\u7ed9 MAC&#xff0c;\u6253\u5f00\u53d1\u9001\u3001\u63a5\u6536\u3001DMA<\/li>\n<li>\u5bf9\u63a5 LWIP \u5e95\u5c42\u6536\u53d1\u51fd\u6570&#xff0c;\u8ba9\u534f\u8bae\u6808\u80fd\u7528\u7f51\u53e3<\/li>\n<\/p>\n<hr \/>\n<p>\u534f\u8bae\u6808\u7684\u672c\u8d28\u5c31\u662f\u5e2e\u4f60\u5b8c\u6210 \u201c\u6570\u636e\u89e3\u6790 \/ \u6253\u5305\u201d \u7684\u6838\u5fc3\u5de5\u4f5c&#xff0c;\u4e0d\u7528\u4f60\u624b\u52a8\u5904\u7406\u590d\u6742\u7684\u7f51\u7edc\u534f\u8bae\u683c\u5f0f&#xff0c;\u6211\u518d\u628a\u8fd9\u4e2a\u8fc7\u7a0b\u62c6\u5f97\u66f4\u7ec6&#xff0c;\u8ba9\u4f60\u5199\u4ee3\u7801\u65f6\u5b8c\u5168\u6e05\u695a\u6bcf\u4e00\u6b65\u8be5\u505a\u4ec0\u4e48&#xff1a;<\/p>\n<h4>\u4e00\u3001\u5148\u786e\u8ba4\u4f60\u7684\u7406\u89e3&#xff08;\u5b8c\u5168\u6b63\u786e&#xff09;<\/h4>\n<p>\u534f\u8bae\u6808\u5bf9\u6570\u636e\u7684\u5904\u7406&#xff0c;\u6838\u5fc3\u5c31\u662f\u4e24\u4ef6\u4e8b&#xff1a;\u2705 \u53d1\u6570\u636e\u65f6&#xff1a;\u628a\u4f60\u8981\u53d1\u7ed9 MAC \u7684 \u201c\u88f8\u6570\u636e\u201d&#xff08;\u6bd4\u5982\u4e00\u4e32\u5b57\u7b26\u3001\u4f20\u611f\u5668\u6570\u503c&#xff09;&#xff0c;\u6309 TCP\/IP \u89c4\u5219\u6253\u5305\u6210\u4ee5\u592a\u7f51\u5e27&#xff0c;\u518d\u4ea4\u7ed9 MAC \u53d1\u9001&#xff1b;\u2705 \u6536\u6570\u636e\u65f6&#xff1a;\u628a MAC \u63a5\u6536\u5230\u7684 \u201c\u4ee5\u592a\u7f51\u5e27\u201d&#xff0c;\u6309 TCP\/IP \u89c4\u5219\u53cd\u5411\u89e3\u6790&#xff0c;\u8fd8\u539f\u6210\u4f60\u80fd\u76f4\u63a5\u7528\u7684 \u201c\u88f8\u6570\u636e\u201d\u3002<\/p>\n<p>\u4f60\u4e0d\u7528\u5173\u5fc3 \u201c\u4ee5\u592a\u7f51\u5e27\u683c\u5f0f\u201d\u201cIP \u5934\u600e\u4e48\u52a0\u201d\u201cUDP \u6821\u9a8c\u548c\u600e\u4e48\u7b97\u201d\u2014\u2014 \u8fd9\u4e9b\u5168\u7531\u534f\u8bae\u6808\u641e\u5b9a\u3002<\/p>\n<h4>\u4e8c\u3001\u7528\u5177\u4f53\u4f8b\u5b50\u770b\u534f\u8bae\u6808\u7684 \u201c\u6253\u5305 \/ \u89e3\u6790\u201d \u8fc7\u7a0b<\/h4>\n<p>\u5047\u8bbe\u4f60\u8981\u7ed9 192.168.1.200 \u53d1\u4e00\u4e32\u5b57\u7b26 &#034;hello&#034;&#xff08;UDP \u901a\u4fe1&#xff09;&#xff0c;\u5168\u7a0b\u4e0d\u7528\u4f60\u78b0\u5e95\u5c42\u683c\u5f0f&#xff1a;<\/p>\n<h5>1. \u4f60\u53ea\u9700\u8981\u5199\u7684\u4e1a\u52a1\u4ee3\u7801&#xff08;\u6781\u7b80&#xff09;<\/h5>\n<p>\/\/ 1. \u51c6\u5907\u8981\u53d1\u7684\u88f8\u6570\u636e<br \/>\nchar send_data[] &#061; &#034;hello&#034;;<br \/>\n\/\/ 2. \u8c03\u7528\u534f\u8bae\u6808 API \u53d1\u9001&#xff08;\u4e0d\u7528\u7ba1\u683c\u5f0f&#xff09;<br \/>\nudp_sendto(udp_pcb, send_data, strlen(send_data), &amp;dest_ip, dest_port);<\/p>\n<h5>2. \u534f\u8bae\u6808\u81ea\u52a8\u5b8c\u6210\u7684 \u201c\u6253\u5305\u201d \u5de5\u4f5c&#xff08;\u4f60\u4e0d\u7528\u5199&#xff09;<\/h5>\n<table>\n<tr>\u6b65\u9aa4\u534f\u8bae\u6808\u505a\u7684\u4e8b\u6700\u7ec8\u6570\u636e\u683c\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u628a &#034;hello&#034; \u5305\u88c5\u6210 UDP \u5305&#xff08;\u52a0 UDP \u5934&#xff1a;\u6e90\u7aef\u53e3\u3001\u76ee\u7684\u7aef\u53e3\u3001\u957f\u5ea6\u3001\u6821\u9a8c\u548c&#xff09;<\/td>\n<td>UDP \u6570\u636e\u5305<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u628a UDP \u5305\u5305\u88c5\u6210 IP \u5305&#xff08;\u52a0 IP \u5934&#xff1a;\u6e90 IP\u3001\u76ee\u7684 IP\u3001\u534f\u8bae\u7c7b\u578b\u3001TTL&#xff09;<\/td>\n<td>IP \u6570\u636e\u5305<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u628a IP \u5305\u5305\u88c5\u6210\u4ee5\u592a\u7f51\u5e27&#xff08;\u52a0\u4ee5\u592a\u7f51\u5934&#xff1a;\u6e90 MAC\u3001\u76ee\u7684 MAC\u3001\u5e27\u7c7b\u578b&#xff09;<\/td>\n<td>\u4ee5\u592a\u7f51\u5e27<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>3. \u4ea4\u7ed9 MAC\/PHY \u53d1\u9001&#xff08;\u4f60\u53ea\u9700\u5bf9\u63a5\u534f\u8bae\u6808\u548c MAC&#xff09;<\/h5>\n<p>\u534f\u8bae\u6808\u628a\u6253\u5305\u597d\u7684\u4ee5\u592a\u7f51\u5e27\u4f20\u7ed9 MAC&#xff0c;MAC \u518d\u901a\u8fc7 RGMII \u53d1\u7ed9 PHY&#xff0c;PHY \u8f6c\u6210\u7535\u4fe1\u53f7\u53d1\u51fa\u53bb\u3002<\/p>\n<h5>4. \u63a5\u6536\u6570\u636e\u65f6\u7684 \u201c\u89e3\u6790\u201d \u8fc7\u7a0b&#xff08;\u53cd\u5411&#xff09;<\/h5>\n<p>\u5f53 MAC \u4ece PHY \u6536\u5230\u4ee5\u592a\u7f51\u5e27\u540e&#xff1a;<\/p>\n<ul>\n<li>\u534f\u8bae\u6808\u5148\u89e3\u6790\u4ee5\u592a\u7f51\u5e27&#xff0c;\u53bb\u6389\u4ee5\u592a\u7f51\u5934&#xff0c;\u53d6\u51fa\u91cc\u9762\u7684 IP \u5305&#xff1b;<\/li>\n<li>\u518d\u89e3\u6790 IP \u5305&#xff0c;\u53bb\u6389 IP \u5934&#xff0c;\u53d6\u51fa\u91cc\u9762\u7684 UDP \u5305&#xff1b;<\/li>\n<li>\u6700\u540e\u89e3\u6790 UDP \u5305&#xff0c;\u53bb\u6389 UDP \u5934&#xff0c;\u8fd8\u539f\u51fa &#034;hello&#034; \u8fd9\u4e32\u88f8\u6570\u636e&#xff1b;<\/li>\n<li>\u8c03\u7528\u4f60\u5199\u7684\u56de\u8c03\u51fd\u6570&#xff0c;\u628a &#034;hello&#034; \u4f20\u7ed9\u4f60\u7684\u4e1a\u52a1\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<h4>\u4e09\u3001\u65b0\u624b\u5199\u4ee3\u7801\u65f6\u7684\u6838\u5fc3\u5de5\u4f5c&#xff08;\u4e0d\u7528\u78b0\u534f\u8bae\u7ec6\u8282&#xff09;<\/h4>\n<li>\u5bf9\u63a5\u534f\u8bae\u6808\u548c MAC&#xff1a;\u53ea\u9700\u8981\u5b9e\u73b0 2 \u4e2a\u7b80\u5355\u51fd\u6570&#xff08;\u4ee5 LWIP \u4e3a\u4f8b&#xff09;&#xff0c;\u544a\u8bc9\u534f\u8bae\u6808 \u201c\u600e\u4e48\u4ece MAC \u62ff\u6570\u636e\u201d\u201c\u600e\u4e48\u628a\u6570\u636e\u7ed9 MAC\u201d&#xff1a;\n<p>\/\/ \u51fd\u65701&#xff1a;\u534f\u8bae\u6808\u8981\u53d1\u6570\u636e\u65f6&#xff0c;\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u628a\u6570\u636e\u7ed9 MAC<br \/>\nstatic err_t low_level_output(struct netif *netif, struct pbuf *p)<br \/>\n{<br \/>\n  \/\/ \u628a\u534f\u8bae\u6808\u7684 pbuf \u6570\u636e\u4f20\u7ed9 MAC \u7684\u53d1\u9001\u7f13\u51b2\u533a<br \/>\n  HAL_ETH_Transmit(&amp;heth, p-&gt;payload, p-&gt;len);<br \/>\n  return ERR_OK;<br \/>\n}<\/p>\n<p>\/\/ \u51fd\u65702&#xff1a;MAC \u6536\u5230\u6570\u636e\u65f6&#xff0c;\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u628a\u6570\u636e\u7ed9\u534f\u8bae\u6808<br \/>\nstatic struct pbuf *low_level_input(struct netif *netif)<br \/>\n{<br \/>\n  uint8_t recv_buf[1500];<br \/>\n  uint32_t len &#061; HAL_ETH_Receive(&amp;heth, recv_buf, 1500);<br \/>\n  \/\/ \u628a MAC \u6536\u5230\u7684\u6570\u636e\u5c01\u88c5\u6210 pbuf&#xff0c;\u4f20\u7ed9\u534f\u8bae\u6808\u89e3\u6790<br \/>\n  struct pbuf *p &#061; pbuf_alloc(PBUF_RAW, len, PBUF_POOL);<br \/>\n  pbuf_take(p, recv_buf, len);<br \/>\n  return p;<br \/>\n}<\/p>\n<\/li>\n<li>\u8c03\u7528\u534f\u8bae\u6808 API \u505a\u4e1a\u52a1&#xff1a;\u6bd4\u5982\u521b\u5efa TCP \u670d\u52a1\u5668\u3001UDP \u5ba2\u6237\u7aef\u3001\u5904\u7406 ping \u54cd\u5e94&#xff0c;\u90fd\u662f\u8c03\u7528\u534f\u8bae\u6808\u5c01\u88c5\u597d\u7684 API&#xff0c;\u4e0d\u7528\u7ba1\u5e95\u5c42\u89e3\u6790 \/ \u6253\u5305\u3002<\/li>\n<h4>\u603b\u7ed3<\/h4>\n<li>\u534f\u8bae\u6808\u7684\u6838\u5fc3\u4ef7\u503c&#xff1a;\u5e2e\u4f60\u81ea\u52a8\u89e3\u6790 \/ \u6253\u5305\u7f51\u7edc\u6570\u636e&#xff0c;\u5c4f\u853d TCP\/IP\u3001\u4ee5\u592a\u7f51\u5e27\u7684\u590d\u6742\u683c\u5f0f&#xff1b;<\/li>\n<li>\u4f60\u7684\u6838\u5fc3\u5de5\u4f5c&#xff1a;\u2460 \u521d\u59cb\u5316 MAC\/PHY \u8ba9\u786c\u4ef6\u901a&#xff1b;\u2461 \u5bf9\u63a5\u534f\u8bae\u6808\u548c MAC \u7684\u6570\u636e\u6536\u53d1&#xff1b;\u2462 \u8c03\u7528\u534f\u8bae\u6808 API \u5b9e\u73b0\u4e1a\u52a1\u529f\u80fd&#xff1b;<\/li>\n<li>\u5173\u952e\u8ba4\u77e5&#xff1a;\u534f\u8bae\u6808\u662f\u8fd0\u884c\u5728 MCU \u91cc\u7684\u8f6f\u4ef6&#xff0c;MAC \u662f MCU \u5185\u7f6e\u786c\u4ef6&#xff0c;PHY \u662f\u5916\u90e8\u786c\u4ef6&#xff0c;\u4e09\u8005\u534f\u4f5c\u5b8c\u6210\u7f51\u7edc\u901a\u4fe1\u3002<\/li>\n<p>\u7b80\u5355\u8bf4&#xff1a;\u4f60\u7ba1 \u201c\u53d1\u4ec0\u4e48\u6570\u636e\u3001\u6536\u4e86\u6570\u636e\u505a\u4ec0\u4e48\u201d&#xff0c;\u534f\u8bae\u6808\u7ba1 \u201c\u6570\u636e\u600e\u4e48\u6253\u5305 \/ \u89e3\u6790\u201d&#xff0c;MAC\/PHY \u7ba1 \u201c\u6570\u636e\u600e\u4e48\u5728\u7f51\u7ebf\u4e0a\u4f20\u201d\u3002<\/p>\n<\/p>\n<hr \/>\n<h2>MDIO\/MDC \u662f\u4ec0\u4e48&#xff1f;<\/h2>\n<p>\u4e00\u53e5\u8bdd&#xff1a;MDIO\/MDC \u662f MAC \u7528\u6765 \u201c\u914d\u7f6e\u3001\u63a7\u5236\u3001\u770b\u72b6\u6001\u201d \u5916\u90e8 PHY \u82af\u7247\u7684\u4e24\u6839\u4e13\u7528\u7ebf\u3002<\/p>\n<h3>1. \u5148\u8bb0\u6b7b&#xff1a;\u53ea\u6709 2 \u6839\u7ebf<\/h3>\n<ul>\n<li>MDC&#xff1a;\u65f6\u949f\u7ebf&#xff08;MAC \u53d1 \u2192 PHY \u6536&#xff09;<\/li>\n<li>MDIO&#xff1a;\u6570\u636e\u7ebf&#xff08;\u53cc\u5411&#xff0c;MAC \u2194 PHY&#xff09;<\/li>\n<\/ul>\n<p>\u5b83\u4fe9\u53ea\u5e72\u4e00\u4ef6\u4e8b&#xff1a;\u8ba9 MAC \u8bfb\u5199 PHY \u5185\u90e8\u5bc4\u5b58\u5668\u3002<\/p>\n<h3>2. \u5f62\u8c61\u6bd4\u55bb&#xff08;\u4f60\u9a6c\u4e0a\u61c2&#xff09;<\/h3>\n<ul>\n<li>MAC &#061; \u8001\u677f&#xff08;\u5728 MCU \u91cc&#xff09;<\/li>\n<li>PHY &#061; \u5458\u5de5&#xff08;\u5916\u9762\u72ec\u7acb\u82af\u7247&#xff09;<\/li>\n<li>RGMII\/RMII &#061; \u5458\u5de5\u5e72\u6d3b\u7684\u901a\u9053&#xff08;\u4f20\u5927\u6570\u636e&#xff09;<\/li>\n<li>MDIO\/MDC &#061; \u8001\u677f\u7ed9\u5458\u5de5\u4e0b\u547d\u4ee4\u7684\u5bf9\u8bb2\u673a<\/li>\n<\/ul>\n<p>\u8001\u677f&#xff08;MAC&#xff09;\u8981\u77e5\u9053&#xff1a;<\/p>\n<ul>\n<li>\u7f51\u7ebf\u63d2\u6ca1\u63d2&#xff1f;<\/li>\n<li>\u73b0\u5728\u662f\u5343\u5146\u8fd8\u662f\u767e\u5146&#xff1f;<\/li>\n<li>\u5168\u53cc\u5de5\u8fd8\u662f\u534a\u53cc\u5de5&#xff1f;<\/li>\n<\/ul>\n<p>\u5c31\u901a\u8fc7 MDIO\/MDC \u95ee PHY\u3002<\/p>\n<h3>3. \u5b83\u5230\u5e95\u7528\u6765\u5e72\u561b&#xff1f;&#xff08;\u4f60\u5199\u4ee3\u7801\u4e00\u5b9a\u4f1a\u7528\u5230&#xff09;<\/h3>\n<p>\u901a\u8fc7 MDIO\/MDC&#xff0c;MAC \u53ef\u4ee5\u5bf9 PHY \u505a 4 \u4ef6\u4e8b&#xff1a;<\/p>\n<li>\u8bfb PHY ID\u786e\u8ba4\u786c\u4ef6\u662f\u4e0d\u662f RTL8211E&#xff0c;\u901a\u4fe1\u901a\u4e0d\u901a\u3002<\/li>\n<li>\u590d\u4f4d PHY<\/li>\n<li>\u914d\u7f6e PHY\u5f00\u81ea\u534f\u5546\u3001\u5343\u5146\u3001\u5168\u53cc\u5de5\u3001\u4f4e\u529f\u8017\u2026<\/li>\n<li>\u8bfb\u72b6\u6001\u7f51\u7ebf\u6709\u6ca1\u6709\u63d2\u4e0a&#xff08;Link Up\/Down&#xff09;\u534f\u5546\u51fa\u6765\u7684\u901f\u7387\u662f\u591a\u5c11<\/li>\n<h3>4. \u548c RGMII \u7684\u533a\u522b&#xff08;\u8d85\u7ea7\u91cd\u8981&#xff09;<\/h3>\n<ul>\n<li>RGMII\/RX\/TX \u90a3\u4e00\u7ec4\u7ebf&#xff1a;\u4f20\u4ee5\u592a\u7f51\u6570\u636e&#xff08;\u5927\u5305&#xff09;<\/li>\n<li>MDIO\/MDC&#xff1a;\u4f20\u914d\u7f6e\u547d\u4ee4&#xff08;\u5c0f\u5305&#xff09;<\/li>\n<\/ul>\n<p>\u6ca1\u6709 MDIO\/MDC \u2192 PHY \u4e0d\u4f1a\u5de5\u4f5c\u3002\u6ca1\u6709 RGMII \u2192 \u4e0d\u80fd\u4f20\u7f51\u7edc\u6570\u636e\u3002<\/p>\n<h3>5. \u4f60\u5199\u4ee3\u7801\u65f6\u770b\u5230\u7684\u5c31\u662f\u8fd9\u4e2a<\/h3>\n<p>\/\/ \u901a\u8fc7 MDIO\/MDC \u8bfb PHY \u5bc4\u5b58\u5668<br \/>\nHAL_ETH_ReadPHYRegister(&#8230;)<\/p>\n<p>\/\/ \u901a\u8fc7 MDIO\/MDC \u5199 PHY \u5bc4\u5b58\u5668<br \/>\nHAL_ETH_WritePHYRegister(&#8230;)<\/p>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570&#xff0c;\u5e95\u5c42\u5c31\u662f\u5728\u7ffb\u8f6c MDC \u548c MDIO\u3002<\/p>\n<h2>\u6700\u7ec8\u6781\u7b80\u603b\u7ed3<\/h2>\n<p>MDIO\/MDC &#061; MAC \u5bf9 PHY \u7684\u7ba1\u7406\u603b\u7ebf\u3002\u53ea\u8d1f\u8d23\u914d\u7f6e &#043; \u770b\u72b6\u6001&#xff0c;\u4e0d\u8d1f\u8d23\u4f20\u7528\u6237\u6570\u636e\u3002<\/p>\n<p>\u4f60\u73b0\u5728\u8fd9\u4e2a\u7406\u89e3\u5c42\u7ea7&#xff0c;\u5df2\u7ecf\u5b8c\u5168\u80fd\u4e0a\u624b\u5199\u4ee5\u592a\u7f51\u9a71\u52a8\u4e86\u3002<\/p>\n<p>MCU \/ CPU \u2192 MAC \u2192 MII\/RMII\/RGMII \u2192 PHY \u2192 \u7f51\u53e3\u53d8\u538b\u5668 \u2192 \u7f51\u7ebf<\/p>\n<h4>\u4e3e\u4f8b\u5b50&#xff1a;GD32F407VET6\u5355\u7247\u673a\u4ee5\u592a\u7f51\u5185\u90e8\u7ed3\u6784<\/h4>\n<p><img decoding=\"async\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260304040947-69a7b08b2f62c.png\" \/><\/p>\n<\/p>\n<hr \/>\n<h2>\u4e00\u3001\u5b8c\u6574\u4ee5\u592a\u7f51\u94fe\u8def\u603b\u56fe&#xff08;\u4ece\u4e0a\u5230\u4e0b\u5c31\u662f\u771f\u5b9e\u786c\u4ef6\u4f4d\u7f6e&#xff09;<\/h2>\n<p>\u3010MCU \u82af\u7247\u3011<br \/>\n   \u251c\u2500 CPU \/ \u5185\u6838<br \/>\n   \u251c\u2500 Flash \/ RAM<br \/>\n   \u2514\u2500 \u3010MAC \u6a21\u5757\u3011&#xff08;\u4ee5\u592a\u7f51\u63a7\u5236\u5668&#xff0c;\u96c6\u6210\u5728 MCU \u5185\u90e8&#xff09;<br \/>\n         \u251c\u2500 \u2460 MDIO \/ MDC  &#xff08;2 \u6839\u7ebf&#xff1a;\u7ba1\u7406\u603b\u7ebf&#xff09;<br \/>\n         \u2502      \u2193<br \/>\n         \u2514\u2500 \u2461 RGMII \/ RMII \/ MII  &#xff08;4~16 \u6839\u7ebf&#xff1a;\u6570\u636e\u603b\u7ebf&#xff09;<br \/>\n                \u2193<br \/>\n\u3010\u5916\u90e8 PHY \u82af\u7247\u3011&#xff08;\u4f8b\u5982 RTL8211E&#xff09;<br \/>\n         \u251c\u2500 \u63a5\u6536 MDIO\/MDC&#xff1a;\u914d\u7f6e\u3001\u8bfb\u72b6\u6001<br \/>\n         \u251c\u2500 \u63a5\u6536 RGMII\/RMII&#xff1a;\u6570\u636e\u5305<br \/>\n         \u2514\u2500 \u628a\u6570\u5b57\u4fe1\u53f7 \u2192 \u8f6c\u4e3a\u7f51\u53e3\u5dee\u5206\u4fe1\u53f7<br \/>\n                \u2193<br \/>\n\u3010\u7f51\u53e3\u53d8\u538b\u5668\u3011&#xff08;\u9694\u79bb\u3001\u9632\u96f7\u3001\u6ee4\u6ce2&#xff09;<br \/>\n                \u2193<br \/>\n\u3010RJ45 \u7f51\u53e3\u3011&#xff08;\u63d2\u7f51\u7ebf\u7684\u63a5\u53e3&#xff09;<br \/>\n                \u2193<br \/>\n\u3010\u7f51\u7ebf\u3011\u2192 \u7535\u8111 \/ \u4ea4\u6362\u673a \/ \u8def\u7531\u5668<\/p>\n<h2>\u4e8c\u3001\u6bcf\u4e2a\u90e8\u5206\u5728\u54ea\u91cc &#043; \u5e72\u4ec0\u4e48 &#043; \u5173\u7cfb<\/h2>\n<h3>1. MCU \u82af\u7247<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;\u4f60\u677f\u5b50\u4e0a\u7684\u4e3b\u63a7\u82af\u7247<\/li>\n<li>\u5185\u90e8\u5305\u542b&#xff1a;\n<ul>\n<li>CPU&#xff1a;\u8fd0\u884c\u4ee3\u7801<\/li>\n<li>MAC&#xff1a;\u4ee5\u592a\u7f51\u6570\u636e\u5e27\u5904\u7406\u6a21\u5757<\/li>\n<\/ul>\n<\/li>\n<li>\u91cd\u8981&#xff1a;MAC \u5728 MCU \u5185\u90e8&#xff0c;\u4e0d\u662f\u72ec\u7acb\u82af\u7247&#xff01;<\/li>\n<\/ul>\n<h3>2. MAC&#xff08;\u4ecb\u8d28\u8bbf\u95ee\u63a7\u5236&#xff09;<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;MCU \u5185\u90e8\u786c\u4ef6\u6a21\u5757<\/li>\n<li>\u4f5c\u7528&#xff1a;\n<ul>\n<li>\u6253\u5305 \/ \u89e3\u6790\u4ee5\u592a\u7f51\u5e27<\/li>\n<li>\u63a7\u5236\u53d1\u9001\u3001\u63a5\u6536<\/li>\n<\/ul>\n<\/li>\n<li>\u5bf9\u5916\u6709\u4e24\u7ec4\u63a5\u53e3&#xff1a;\n<li>MDIO\/MDC&#xff08;\u7ba1\u7406\u53e3&#xff09;<\/li>\n<li>RGMII\/RMII\/MII&#xff08;\u6570\u636e\u53e3&#xff09;<\/li>\n<\/li>\n<\/ul>\n<h3>3. MDIO \/ MDC&#xff08;\u4f60\u91cd\u70b9\u95ee\u7684&#xff09;<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;MCU \u4e24\u4e2a\u5f15\u811a \u2192 PHY \u4e24\u4e2a\u5f15\u811a<\/li>\n<li>\u7ebf\u6570&#xff1a;2 \u6839<\/li>\n<li>\u65b9\u5411&#xff1a;\n<ul>\n<li>MDC&#xff1a;\u65f6\u949f&#xff0c;MCU \u2192 PHY<\/li>\n<li>MDIO&#xff1a;\u6570\u636e&#xff0c;\u53cc\u5411<\/li>\n<\/ul>\n<\/li>\n<li>\u4f5c\u7528&#xff1a;\n<ul>\n<li>\u914d\u7f6e PHY&#xff08;\u901f\u7387\u3001\u81ea\u534f\u5546\u3001\u590d\u4f4d&#xff09;<\/li>\n<li>\u8bfb PHY \u72b6\u6001&#xff08;\u7f51\u7ebf\u662f\u5426\u63d2\u5165\u3001link \u72b6\u6001&#xff09;<\/li>\n<li>\u8bfb PHY \u578b\u53f7 ID&#xff08;\u8bc6\u522b RTL8211E&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3&#xff1a;\u7ba1\u7406\u603b\u7ebf &#061; \u914d\u7f6e\u3001\u770b\u72b6\u6001&#xff0c;\u4e0d\u4f20\u7528\u6237\u6570\u636e<\/li>\n<\/ul>\n<h3>4. RGMII \/ RMII \/ MII<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;MCU \u5f15\u811a \u2192 PHY \u5f15\u811a\u7684\u4e00\u7ec4\u9ad8\u901f\u7ebf<\/li>\n<li>\u4f5c\u7528&#xff1a;\u4e13\u95e8\u4f20\u4ee5\u592a\u7f51\u6570\u636e\u5305<\/li>\n<li>\u533a\u522b&#xff1a;\n<ul>\n<li>MII&#xff1a;\u8001\u6b3e\u3001\u7ebf\u591a\u3001\u767e\u5146<\/li>\n<li>RMII&#xff1a;\u7b80\u5316\u7248\u3001\u7ebf\u5c11\u3001\u767e\u5146<\/li>\n<li>RGMII&#xff1a;\u5343\u5146\u3001\u7ebf\u5c11\u3001\u4f60\u73b0\u5728\u7528\u7684\u5c31\u662f\u8fd9\u4e2a<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3&#xff1a;\u6570\u636e\u603b\u7ebf &#061; \u4f20\u771f\u6b63\u7684\u7f51\u7edc\u6570\u636e<\/li>\n<\/ul>\n<h3>5. PHY \u82af\u7247&#xff08;\u4f8b\u5982 RTL8211E&#xff09;<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;MCU \u5916\u90e8&#xff0c;\u72ec\u7acb\u82af\u7247<\/li>\n<li>\u4f5c\u7528&#xff1a;\n<ul>\n<li>\u628a MAC \u53d1\u6765\u7684\u6570\u5b57\u4fe1\u53f7<\/li>\n<li>\u8f6c\u6210\u7f51\u53e3\u80fd\u7528\u7684\u7535\u4fe1\u53f7<\/li>\n<\/ul>\n<\/li>\n<li>\u5fc5\u987b\u540c\u65f6\u63a5&#xff1a;\n<ul>\n<li>MDIO\/MDC&#xff08;\u914d\u7f6e&#xff09;<\/li>\n<li>RGMII\/RMII&#xff08;\u6570\u636e&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>6. \u7f51\u53e3\u53d8\u538b\u5668<\/h3>\n<ul>\n<li>\u4f4d\u7f6e&#xff1a;PHY \u548c RJ45 \u4e4b\u95f4<\/li>\n<li>\u4f5c\u7528&#xff1a;\u9694\u79bb\u3001\u9632\u96f7\u3001\u9632\u70e7\u3001\u4fe1\u53f7\u6574\u5f62<\/li>\n<\/ul>\n<h3>7. RJ45 \u7f51\u53e3 \u2192 \u7f51\u7ebf<\/h3>\n<ul>\n<li>\u6700\u7ec8\u4fe1\u53f7\u901a\u8fc7\u7f51\u7ebf\u51fa\u53bb<\/li>\n<\/ul>\n<h2>\u4e09\u3001\u6700\u7cbe\u7b80\u4e00\u53e5\u8bdd\u603b\u5173\u7cfb<\/h2>\n<ul>\n<li>MAC \u5728 MCU \u91cc<\/li>\n<li>PHY \u662f\u5916\u90e8\u72ec\u7acb\u82af\u7247<\/li>\n<li>MDIO\/MDC&#xff1a;2 \u6839\u7ebf&#xff0c;\u7528\u6765\u914d\u7f6e PHY<\/li>\n<li>RGMII\/RMII&#xff1a;\u4e00\u7ec4\u9ad8\u901f\u7ebf&#xff0c;\u7528\u6765\u4f20\u6570\u636e<\/li>\n<li>\u4e24\u6761\u8def\u5fc5\u987b\u540c\u65f6\u6709&#xff0c;\u4ee5\u592a\u7f51\u624d\u80fd\u5de5\u4f5c<\/li>\n<\/ul>\n<hr \/>\n<p>\u4f60\u95ee\u7684\u8fd9\u4e2a\u95ee\u9898\u7279\u522b\u5173\u952e&#xff0c;\u80fd\u5e2e\u4f60\u8df3\u51fa \u201c\u53ea\u80fd\u7528 LWIP\u201d \u7684\u56fa\u5b9a\u601d\u7ef4&#xff01;\u5148\u7ed9\u6838\u5fc3\u7ed3\u8bba&#xff0c;\u518d\u8bb2\u6e05\u695a\u4e0d\u540c\u573a\u666f\u8be5\u9009\u4ec0\u4e48&#xff1a;<\/p>\n<h4>\u4e00\u3001\u6838\u5fc3\u7ed3\u8bba<\/h4>\n<p>LWIP \u4e0d\u662f\u5fc5\u987b\u7684&#xff01;\u5b83\u53ea\u662f\u5d4c\u5165\u5f0f\u9886\u57df\u6700\u5e38\u7528\u7684\u9009\u62e9&#xff0c;\u662f\u5426\u7528\u5b83\u3001\u7528\u4ec0\u4e48\u66ff\u4ee3&#xff0c;\u5b8c\u5168\u53d6\u51b3\u4e8e\u4f60\u7684\u529f\u80fd\u9700\u6c42\u548cMCU \u8d44\u6e90&#xff1a;<\/p>\n<ul>\n<li>\u82e5\u9700\u8981 TCP\/UDP\/IP\/ICMP&#xff08;ping\u3001\u8054\u7f51\u901a\u4fe1&#xff09;\u2192 \u5fc5\u987b\u7528\u534f\u8bae\u6808&#xff08;LWIP \u6216\u5176\u4ed6&#xff09;&#xff1b;<\/li>\n<li>\u82e5\u53ea\u9700\u8981 \u201c\u88f8\u4ee5\u592a\u7f51\u5e27\u6536\u53d1\u201d&#xff08;\u6bd4\u5982\u81ea\u5b9a\u4e49\u534f\u8bae\u3001\u7b80\u5355\u6570\u636e\u4f20\u8f93&#xff09;\u2192 \u53ef\u4ee5\u4e0d\u7528\u4efb\u4f55\u534f\u8bae\u6808&#xff0c;\u76f4\u63a5\u64cd\u4f5c MAC\/PHY\u3002<\/li>\n<\/ul>\n<h4>\u4e8c\u3001\u4ec0\u4e48\u65f6\u5019\u53ef\u4ee5\u4e0d\u7528 LWIP&#xff08;\u4e0d\u7528\u4efb\u4f55\u534f\u8bae\u6808&#xff09;<\/h4>\n<p>\u5982\u679c\u4f60\u7684\u9700\u6c42\u53ea\u662f \u201c\u628a\u6570\u636e\u4ece MCU \u53d1\u5230\u53e6\u4e00\u53f0\u8bbe\u5907&#xff0c;\u4e14\u4e24\u53f0\u8bbe\u5907\u90fd\u7531\u4f60\u63a7\u5236\u201d&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<ul>\n<li>\u4ec5\u9700\u8981\u6536\u53d1\u81ea\u5b9a\u4e49\u683c\u5f0f\u7684\u4ee5\u592a\u7f51\u5e27&#xff1b;<\/li>\n<li>\u4e0d\u9700\u8981\u8054\u7f51\u3001\u4e0d\u9700\u8981 ping\u3001\u4e0d\u9700\u8981\u548c\u7535\u8111 \/ \u670d\u52a1\u5668\u901a\u4fe1&#xff1b;<\/li>\n<li>\u8ffd\u6c42\u6781\u81f4\u7cbe\u7b80&#xff08;MCU \u8d44\u6e90\u6781\u5c11&#xff0c;\u6bd4\u5982\u53ea\u6709\u51e0 KB RAM&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u2705 \u505a\u6cd5&#xff1a;\u76f4\u63a5\u64cd\u4f5c MAC \u786c\u4ef6&#xff0c;\u6536\u53d1 \u201c\u88f8\u4ee5\u592a\u7f51\u5e27\u201d&#xff0c;\u793a\u4f8b\u4ee3\u7801&#xff08;STM32&#xff09;&#xff1a;<\/p>\n<p>\/\/ \u53d1\u9001\u88f8\u4ee5\u592a\u7f51\u5e27&#xff08;\u4e0d\u7528\u534f\u8bae\u6808&#xff09;<br \/>\nvoid send_raw_eth_frame(uint8_t *data, uint16_t len)<br \/>\n{<br \/>\n    uint8_t eth_frame[1500];<br \/>\n    \/\/ \u624b\u52a8\u586b\u5145\u4ee5\u592a\u7f51\u5e27\u5934&#xff08;\u76ee\u7684MAC\u3001\u6e90MAC\u3001\u5e27\u7c7b\u578b&#xff09;<br \/>\n    eth_frame[0] &#061; 0x00; eth_frame[1] &#061; 0x11; eth_frame[2] &#061; 0x22; \/\/ \u76ee\u7684MAC\u524d3\u5b57\u8282<br \/>\n    eth_frame[3] &#061; 0x33; eth_frame[4] &#061; 0x44; eth_frame[5] &#061; 0x55; \/\/ \u76ee\u7684MAC\u540e3\u5b57\u8282<br \/>\n    eth_frame[6] &#061; 0xAA; eth_frame[7] &#061; 0xBB; eth_frame[8] &#061; 0xCC; \/\/ \u6e90MAC\u524d3\u5b57\u8282<br \/>\n    eth_frame[9] &#061; 0xDD; eth_frame[10] &#061; 0xEE; eth_frame[11] &#061; 0xFF; \/\/ \u6e90MAC\u540e3\u5b57\u8282<br \/>\n    eth_frame[12] &#061; 0x08; eth_frame[13] &#061; 0x00; \/\/ \u5e27\u7c7b\u578b&#xff08;0x0800&#061;IP&#xff0c;\u81ea\u5b9a\u4e49\u5219\u75280x88B5\u7b49&#xff09;<\/p>\n<p>    \/\/ \u586b\u5145\u4e1a\u52a1\u6570\u636e<br \/>\n    memcpy(&amp;eth_frame[14], data, len);<\/p>\n<p>    \/\/ \u76f4\u63a5\u901a\u8fc7MAC\u53d1\u9001<br \/>\n    HAL_ETH_Transmit(&amp;heth, eth_frame, 14 &#043; len);<br \/>\n}<\/p>\n<p>\/\/ \u63a5\u6536\u88f8\u4ee5\u592a\u7f51\u5e27&#xff08;\u4e0d\u7528\u534f\u8bae\u6808&#xff09;<br \/>\nvoid recv_raw_eth_frame(void)<br \/>\n{<br \/>\n    uint8_t recv_buf[1500];<br \/>\n    uint32_t len &#061; HAL_ETH_Receive(&amp;heth, recv_buf, 1500);<br \/>\n    if (len &gt; 14)<br \/>\n    {<br \/>\n        \/\/ recv_buf[14:] \u5c31\u662f\u88f8\u6570\u636e&#xff0c;\u81ea\u5df1\u89e3\u6790\u5373\u53ef<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u4e09\u3001\u9664\u4e86 LWIP&#xff0c;\u8fd8\u6709\u54ea\u4e9b\u534f\u8bae\u6808\u53ef\u9009<\/h4>\n<p>\u5982\u679c\u9700\u8981 TCP\/IP \u529f\u80fd&#xff08;\u5fc5\u987b\u7528\u534f\u8bae\u6808&#xff09;&#xff0c;\u9664\u4e86 LWIP&#xff0c;\u8fd8\u6709\u8fd9\u4e9b\u4e3b\u6d41\u9009\u62e9&#xff0c;\u6309 \u201c\u6613\u7528\u6027 \/ \u8d44\u6e90\u5360\u7528\u201d \u5206\u7c7b&#xff1a;<\/p>\n<table>\n<tr>\u534f\u8bae\u6808\u7279\u70b9\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>LWIP<\/td>\n<td>\u8f7b\u91cf&#xff08;\u51e0\u5341 KB RAM&#xff09;\u3001\u5f00\u6e90\u3001\u9002\u914d\u6027\u5f3a<\/td>\n<td>90% \u5d4c\u5165\u5f0f\u573a\u666f&#xff08;STM32\/MCU\/ \u65e0 OS&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>uIP<\/td>\n<td>\u8d85\u8f7b\u91cf&#xff08;\u51e0 KB RAM&#xff09;\u3001\u6781\u7b80<\/td>\n<td>\u8d44\u6e90\u6781\u7701\u7684 MCU&#xff08;\u5982 51\/STM32F103&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>FreeRTOS&#043;TCP<\/td>\n<td>\u548c FreeRTOS \u6df1\u5ea6\u96c6\u6210\u3001\u7a33\u5b9a<\/td>\n<td>\u7528 FreeRTOS \u7684\u9879\u76ee<\/td>\n<\/tr>\n<tr>\n<td>NetX\/NetX Duo<\/td>\n<td>\u5546\u7528\u3001\u9ad8\u53ef\u9760\u3001\u652f\u6301 IPv6<\/td>\n<td>\u5de5\u4e1a \/ \u8f66\u8f7d&#xff08;\u9700\u8981\u8ba4\u8bc1\u3001\u7a33\u5b9a\u6027\u4f18\u5148&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Zephyr Net<\/td>\n<td>\u5d4c\u5165\u5f0f OS Zephyr \u5185\u7f6e\u3001\u6a21\u5757\u5316<\/td>\n<td>\u57fa\u4e8e Zephyr \u7684\u7269\u8054\u7f51\u9879\u76ee<\/td>\n<\/tr>\n<tr>\n<td>uC\/IP<\/td>\n<td>\u548c uC\/OS-II\/III \u914d\u5957\u3001\u5546\u7528<\/td>\n<td>\u7528 uC\/OS \u7684\u5de5\u4e1a\u9879\u76ee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>\u91cd\u70b9\u5bf9\u6bd4&#xff08;\u65b0\u624b\u5173\u6ce8&#xff09;&#xff1a;<\/h5>\n<li>\n<p>LWIP vs uIP&#xff1a;<\/p>\n<ul>\n<li>LWIP&#xff1a;\u529f\u80fd\u5168&#xff08;TCP\/UDP\/IP\/DHCP\/DNS&#xff09;\u3001\u6613\u79fb\u690d&#xff0c;\u9002\u5408\u5927\u591a\u6570\u573a\u666f&#xff1b;<\/li>\n<li>uIP&#xff1a;\u53ea\u6709\u6838\u5fc3 TCP\/IP&#xff0c;\u4ee3\u7801\u91cf\u6781\u5c0f&#xff0c;\u4f46\u529f\u80fd\u5f31&#xff08;\u65e0 DHCP\u3001\u65e0\u591a\u8fde\u63a5&#xff09;&#xff0c;\u9002\u5408\u6781\u4f4e\u7aef MCU\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>LWIP vs FreeRTOS&#043;TCP&#xff1a;<\/p>\n<ul>\n<li>\u82e5\u4f60\u7684\u9879\u76ee\u5df2\u7ecf\u7528 FreeRTOS&#xff0c;\u4f18\u5148\u9009 FreeRTOS&#043;TCP&#xff08;\u65e0\u7f1d\u96c6\u6210&#xff09;&#xff1b;<\/li>\n<li>\u82e5\u4e0d\u7528 RTOS&#xff08;\u88f8\u673a&#xff09;&#xff0c;\u4f18\u5148\u9009 LWIP\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>\u56db\u3001\u65b0\u624b\u9009\u578b\u5efa\u8bae&#xff08;\u4e0d\u7528\u7ea0\u7ed3&#xff09;<\/h4>\n<li>99% \u7684\u573a\u666f&#xff1a;\u9009 LWIP&#xff08;\u8d44\u6599\u591a\u3001\u9002\u914d\u5168\u3001\u6613\u4e0a\u624b&#xff09;&#xff1b;<\/li>\n<li>MCU RAM &lt; 10KB&#xff1a;\u9009 uIP&#xff1b;<\/li>\n<li>\u7528 FreeRTOS&#xff1a;\u9009 FreeRTOS&#043;TCP&#xff1b;<\/li>\n<li>\u5de5\u4e1a \/ \u8f66\u8f7d&#xff08;\u8981\u7a33\u5b9a\u6027 \/ \u8ba4\u8bc1&#xff09;&#xff1a;\u9009 NetX Duo&#xff1b;<\/li>\n<li>\u4ec5\u88f8\u5e27\u6536\u53d1&#xff1a;\u4e0d\u7528\u4efb\u4f55\u534f\u8bae\u6808&#xff0c;\u76f4\u63a5\u64cd\u4f5c MAC\u3002<\/li>\n<h4>\u603b\u7ed3<\/h4>\n<li>LWIP \u4e0d\u662f\u5fc5\u987b\u7684&#xff0c;\u4ec5\u5f53\u9700\u8981 TCP\/IP \u529f\u80fd\u65f6\u624d\u9700\u8981\u534f\u8bae\u6808&#xff1b;<\/li>\n<li>\u65e0 TCP\/IP \u9700\u6c42 \u2192 \u76f4\u63a5\u64cd\u4f5c MAC \u6536\u53d1\u88f8\u5e27&#xff0c;\u4e0d\u7528\u4efb\u4f55\u534f\u8bae\u6808&#xff1b;<\/li>\n<li>\u6709 TCP\/IP \u9700\u6c42 \u2192 \u4f18\u5148\u9009 LWIP&#xff0c;\u7279\u6b8a\u573a\u666f\u53ef\u6362 uIP\/FreeRTOS&#043;TCP \u7b49&#xff1b;<\/li>\n<li>\u6838\u5fc3\u539f\u5219&#xff1a;\u6309 \u201c\u529f\u80fd\u9700\u6c42 &#043; MCU \u8d44\u6e90\u201d \u9009&#xff0c;\u4e0d\u7528\u8ffd\u6c42 \u201c\u8d8a\u590d\u6742\u8d8a\u597d\u201d\u3002<\/li>\n<p>\u7b80\u5355\u8bf4&#xff1a;\u80fd\u88f8\u5e27\u89e3\u51b3\u7684\u5c31\u4e0d\u7528\u534f\u8bae\u6808&#xff0c;\u8981\u7528\u534f\u8bae\u6808\u7684\u8bdd&#xff0c;\u65b0\u624b\u76f4\u63a5\u9009 LWIP \u51c6\u6ca1\u9519\u3002<\/p>\n<\/p>\n<hr \/>\n<p>\u4f60\u60f3\u77e5\u9053\u529f\u80fd\u5b8c\u6574\u7684 LWIP \u534f\u8bae\u6808\u5b9e\u9645\u5de5\u7a0b\u91cc\u957f\u4ec0\u4e48\u6837&#xff0c;\u6211\u76f4\u63a5\u7ed9\u4f60\u5c55\u793a \u201c\u6807\u51c6 LWIP \u5de5\u7a0b\u7ed3\u6784 &#043; \u6838\u5fc3\u914d\u7f6e \/ \u4ee3\u7801\u793a\u4f8b\u201d&#xff0c;\u65b0\u624b\u4e00\u770b\u5c31\u61c2&#xff0c;\u8fd8\u80fd\u76f4\u63a5\u53c2\u8003\u79fb\u690d&#xff1a;<\/p>\n<h4>\u4e00\u3001\u5148\u770b LWIP \u5728\u5de5\u7a0b\u91cc\u7684 \u201c\u7269\u7406\u5f62\u6001\u201d&#xff08;\u6587\u4ef6\u7ed3\u6784&#xff09;<\/h4>\n<p>\u8fd9\u662f STM32 &#043; LWIP \u5de5\u7a0b\u4e2d&#xff0c;LWIP \u76f8\u5173\u7684\u6838\u5fc3\u6587\u4ef6\u5e03\u5c40&#xff08;\u529f\u80fd\u5168\u7248\u672c&#xff09;&#xff0c;\u4f60\u79fb\u690d\u65f6\u53ea\u9700\u8981\u628a\u8fd9\u4e9b\u6587\u4ef6\u52a0\u5165\u5de5\u7a0b&#xff0c;\u518d\u914d\u7f6e\u5c11\u91cf\u53c2\u6570\u5373\u53ef&#xff1a;<\/p>\n<p>\u4f60\u7684\u5de5\u7a0b\/<br \/>\n\u251c\u2500 LWIP\/                  \/\/ LWIP \u6838\u5fc3\u76ee\u5f55&#xff08;\u4e0d\u7528\u6539&#xff09;<br \/>\n\u2502  \u251c\u2500 src\/<br \/>\n\u2502  \u2502  \u251c\u2500 core\/            \/\/ TCP\/IP \u6838\u5fc3&#xff08;IP\/TCP\/UDP\/ICMP \u7b49&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 ip.c\/ip.h     \/\/ IP \u534f\u8bae&#xff08;\u5730\u5740\u3001\u8def\u7531\u3001\u5206\u7247&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 tcp.c\/tcp.h   \/\/ TCP \u534f\u8bae&#xff08;\u8fde\u63a5\u3001\u91cd\u4f20\u3001\u62e5\u585e\u63a7\u5236&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 udp.c\/udp.h   \/\/ UDP \u534f\u8bae&#xff08;\u65e0\u8fde\u63a5\u4f20\u8f93&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 icmp.c\/icmp.h \/\/ ICMP&#xff08;ping \u54cd\u5e94&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u2514\u2500 netif\/        \/\/ \u7f51\u7edc\u63a5\u53e3&#xff08;\u5bf9\u63a5 MAC\/PHY&#xff09;<br \/>\n\u2502  \u2502  \u251c\u2500 apps\/            \/\/ \u4e0a\u5c42\u5e94\u7528&#xff08;\u53ef\u9009&#xff0c;\u529f\u80fd\u5168\u65f6\u52a0&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 dhcp.c\/dhcp.h \/\/ DHCP&#xff08;\u81ea\u52a8\u83b7\u53d6 IP&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u251c\u2500 dns.c\/dns.h   \/\/ DNS&#xff08;\u57df\u540d\u89e3\u6790&#xff0c;\u6bd4\u5982\u89e3\u6790 www.baidu.com&#xff09;<br \/>\n\u2502  \u2502  \u2502  \u2514\u2500 httpd.c       \/\/ \u8f7b\u91cf HTTP \u670d\u52a1\u5668&#xff08;\u53ef\u9009&#xff09;<br \/>\n\u2502  \u2502  \u2514\u2500 include\/         \/\/ \u6240\u6709\u5934\u6587\u4ef6&#xff08;\u4e0d\u7528\u6539&#xff09;<br \/>\n\u2502  \u2514\u2500 lwipopts.h          \/\/ LWIP \u6838\u5fc3\u914d\u7f6e\u6587\u4ef6&#xff08;\u4f60\u9700\u8981\u6539\u7684\u552f\u4e00\u6838\u5fc3\u6587\u4ef6&#xff09;<br \/>\n\u251c\u2500 Drivers\/<br \/>\n\u2502  \u2514\u2500 ethernetif.c\/ethernetif.h \/\/ \u4f60\u9700\u8981\u5199\u7684&#xff1a;LWIP \u2194 MAC \u5bf9\u63a5\u4ee3\u7801<br \/>\n\u2514\u2500 User\/<br \/>\n   \u2514\u2500 lwip_app.c          \/\/ \u4f60\u7684\u4e1a\u52a1\u4ee3\u7801&#xff08;\u914d\u7f6e IP\u3001\u5199 TCP\/UDP \u903b\u8f91&#xff09;<\/p>\n<h4>\u4e8c\u3001\u6838\u5fc3\u914d\u7f6e\u6587\u4ef6 lwipopts.h&#xff08;\u529f\u80fd\u5168\u7248\u672c\u793a\u4f8b&#xff09;<\/h4>\n<p>\u8fd9\u662f \u201c\u5f00\u542f TCP\/UDP\/IP\/DHCP\/DNS\u201d \u7684\u6807\u51c6\u914d\u7f6e&#xff0c;\u65b0\u624b\u53ea\u9700\u6539\u5185\u5b58\u5927\u5c0f\u3001\u5f00\u5173\u529f\u80fd&#xff0c;\u4e0d\u7528\u6539\u6838\u5fc3\u903b\u8f91&#xff1a;<\/p>\n<p>#ifndef LWIPOPTS_H<br \/>\n#define LWIPOPTS_H<\/p>\n<p>\/\/ 1. \u57fa\u7840\u914d\u7f6e&#xff08;\u9002\u914d MCU \u8d44\u6e90&#xff09;<br \/>\n#define MEM_SIZE             32*1024  \/\/ \u5185\u5b58\u6c60\u5927\u5c0f&#xff08;STM32F4 \u914d 32KB \u8db3\u591f&#xff09;<br \/>\n#define MEMP_NUM_TCP_PCB     8        \/\/ \u6700\u5927 TCP \u8fde\u63a5\u6570&#xff08;\u6bd4\u5982\u652f\u6301 8 \u4e2a\u5ba2\u6237\u7aef&#xff09;<br \/>\n#define MEMP_NUM_UDP_PCB     4        \/\/ \u6700\u5927 UDP \u8fde\u63a5\u6570<br \/>\n#define PBUF_POOL_SIZE       16       \/\/ \u6570\u636e\u5305\u7f13\u51b2\u533a\u6570\u91cf<\/p>\n<p>\/\/ 2. \u5f00\u542f\u6838\u5fc3\u534f\u8bae&#xff08;\u529f\u80fd\u5168&#xff09;<br \/>\n#define LWIP_IPV4            1        \/\/ \u542f\u7528 IPv4<br \/>\n#define LWIP_TCP             1        \/\/ \u542f\u7528 TCP<br \/>\n#define LWIP_UDP             1        \/\/ \u542f\u7528 UDP<br \/>\n#define LWIP_ICMP            1        \/\/ \u542f\u7528 ICMP&#xff08;ping&#xff09;<br \/>\n#define LWIP_DHCP            1        \/\/ \u542f\u7528 DHCP&#xff08;\u81ea\u52a8\u83b7\u53d6 IP&#xff09;<br \/>\n#define LWIP_DNS             1        \/\/ \u542f\u7528 DNS&#xff08;\u57df\u540d\u89e3\u6790&#xff09;<br \/>\n#define LWIP_NETIF_LINK_CALLBACK 1    \/\/ \u94fe\u8def\u72b6\u6001\u56de\u8c03&#xff08;\u7f51\u7ebf\u63d2\u62d4\u68c0\u6d4b&#xff09;<\/p>\n<p>\/\/ 3. \u4f18\u5316\u914d\u7f6e&#xff08;\u65b0\u624b\u4e0d\u7528\u6539&#xff09;<br \/>\n#define LWIP_TCP_KEEPALIVE   1        \/\/ TCP \u4fdd\u6d3b&#xff08;\u9632\u6b62\u8fde\u63a5\u65ad\u5f00&#xff09;<br \/>\n#define LWIP_TCP_TIMESTAMPS  1        \/\/ TCP \u65f6\u95f4\u6233&#xff08;\u4f18\u5316\u91cd\u4f20&#xff09;<br \/>\n#define LWIP_ARP             1        \/\/ \u542f\u7528 ARP&#xff08;MAC\/IP \u6620\u5c04&#xff09;<br \/>\n#define LWIP_IGMP            0        \/\/ \u4e0d\u7528\u7ec4\u64ad\u5c31\u5173\u4e86<br \/>\n#define LWIP_STATS           0        \/\/ \u5173\u95ed\u7edf\u8ba1&#xff08;\u8282\u7701\u8d44\u6e90&#xff09;<\/p>\n<p>\/\/ 4. \u64cd\u4f5c\u7cfb\u7edf\u9002\u914d&#xff08;\u88f8\u673a\/RTOS \u53ef\u9009&#xff09;<br \/>\n#define NO_SYS               0        \/\/ 0&#061;\u7528 RTOS&#xff08;FreeRTOS&#xff09;&#xff0c;1&#061;\u88f8\u673a<br \/>\n#define SYS_LIGHTWEIGHT_PROT 1        \/\/ \u8f7b\u91cf\u7ea7\u4fdd\u62a4<\/p>\n<p>#endif \/* LWIPOPTS_H *\/<\/p>\n<h4>\u4e09\u3001\u529f\u80fd\u5168\u7684\u4e1a\u52a1\u4ee3\u7801\u793a\u4f8b&#xff08;TCP&#043;UDP&#043;DHCP&#043;DNS&#xff09;<\/h4>\n<p>\u8fd9\u662f\u57fa\u4e8e LWIP \u5b9e\u73b0 \u201c\u81ea\u52a8\u83b7\u53d6 IP &#043; TCP \u670d\u52a1\u5668 &#043; UDP \u5ba2\u6237\u7aef &#043; \u57df\u540d\u89e3\u6790\u201d \u7684\u6838\u5fc3\u4ee3\u7801&#xff0c;\u76f4\u63a5\u4f53\u73b0 LWIP \u7684 \u201c\u529f\u80fd\u5168\u201d&#xff1a;<\/p>\n<p>#include &#034;lwip\/netif.h&#034;<br \/>\n#include &#034;lwip\/tcpip.h&#034;<br \/>\n#include &#034;lwip\/dhcp.h&#034;<br \/>\n#include &#034;lwip\/dns.h&#034;<br \/>\n#include &#034;lwip\/tcp.h&#034;<br \/>\n#include &#034;lwip\/udp.h&#034;<\/p>\n<p>struct netif gnetif;<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 1. \u521d\u59cb\u5316 LWIP \u6838\u5fc3 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nvoid lwip_init_all(void)<br \/>\n{<br \/>\n    \/\/ \u521d\u59cb\u5316 TCP\/IP \u5185\u6838<br \/>\n    tcpip_init(NULL, NULL);<\/p>\n<p>    \/\/ \u6dfb\u52a0\u7f51\u7edc\u63a5\u53e3&#xff08;\u7ed1\u5b9a MAC\/PHY&#xff09;<br \/>\n    netif_add(&amp;gnetif, NULL, NULL, NULL, NULL, &amp;ethernetif_init, &amp;tcpip_input);<br \/>\n    netif_set_default(&amp;gnetif);<br \/>\n    netif_set_up(&amp;gnetif);<\/p>\n<p>    \/\/ \u5f00\u542f DHCP&#xff08;\u81ea\u52a8\u83b7\u53d6 IP&#xff0c;\u66ff\u4ee3\u9759\u6001 IP&#xff09;<br \/>\n    dhcp_start(&amp;gnetif);<\/p>\n<p>    \/\/ \u521d\u59cb\u5316 TCP \u670d\u52a1\u5668 &#043; UDP \u5ba2\u6237\u7aef<br \/>\n    tcp_server_init(8080);  \/\/ TCP \u76d1\u542c 8080 \u7aef\u53e3<br \/>\n    udp_client_init();      \/\/ UDP \u5ba2\u6237\u7aef\u521d\u59cb\u5316<br \/>\n}<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 2. TCP \u670d\u52a1\u5668&#xff08;\u76d1\u542c 8080 \u7aef\u53e3&#xff09; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nerr_t tcp_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)<br \/>\n{<br \/>\n    if (p !&#061; NULL)<br \/>\n    {<br \/>\n        \/\/ \u6536\u5230 TCP \u6570\u636e&#xff1a;p-&gt;payload \u662f\u6570\u636e\u5185\u5bb9&#xff0c;p-&gt;len \u662f\u957f\u5ea6<br \/>\n        tcp_write(pcb, &#034;\u6536\u5230\u6570\u636e&#034;, 6, TCP_WRITE_FLAG_COPY); \/\/ \u56de\u590d\u5ba2\u6237\u7aef<br \/>\n        tcp_output(pcb);<br \/>\n        pbuf_free(p);<br \/>\n    }<br \/>\n    return ERR_OK;<br \/>\n}<\/p>\n<p>void tcp_server_init(uint16_t port)<br \/>\n{<br \/>\n    struct tcp_pcb *pcb &#061; tcp_new();<br \/>\n    tcp_bind(pcb, IP_ADDR_ANY, port);<br \/>\n    pcb &#061; tcp_listen(pcb);<br \/>\n    tcp_accept(pcb, tcp_accept_cb); \/\/ \u6ce8\u518c\u8fde\u63a5\u56de\u8c03<br \/>\n}<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 3. UDP \u5ba2\u6237\u7aef&#xff08;\u53d1\u6570\u636e\u5230 192.168.1.10&#xff09; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nvoid udp_client_init(void)<br \/>\n{<br \/>\n    struct udp_pcb *pcb &#061; udp_new();<br \/>\n    ip4_addr_t dest_ip;<br \/>\n    IP4_ADDR(&amp;dest_ip, 192, 168, 1, 10); \/\/ \u76ee\u6807 IP<br \/>\n    udp_connect(pcb, &amp;dest_ip, 9090);    \/\/ \u76ee\u6807\u7aef\u53e3 9090<br \/>\n    udp_send(pcb, &#034;UDP \u6d4b\u8bd5\u6570\u636e&#034;, 8);    \/\/ \u53d1\u9001 UDP \u6570\u636e<br \/>\n}<\/p>\n<p>\/\/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 4. DNS \u57df\u540d\u89e3\u6790&#xff08;\u89e3\u6790\u767e\u5ea6&#xff09; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\nvoid dns_test(void)<br \/>\n{<br \/>\n    ip4_addr_t ipaddr;<br \/>\n    \/\/ \u89e3\u6790 www.baidu.com&#xff0c;\u56de\u8c03\u51fd\u6570\u83b7\u53d6 IP<br \/>\n    dns_gethostbyname(&#034;www.baidu.com&#034;, &amp;ipaddr, dns_found_cb, NULL);<br \/>\n}<\/p>\n<p>\/\/ DNS \u89e3\u6790\u5b8c\u6210\u56de\u8c03<br \/>\nvoid dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *arg)<br \/>\n{<br \/>\n    if (ipaddr !&#061; NULL)<br \/>\n    {<br \/>\n        \/\/ ipaddr \u5c31\u662f\u767e\u5ea6\u7684 IP \u5730\u5740&#xff0c;\u53ef\u7528\u4e8e TCP\/UDP \u8fde\u63a5<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u56db\u3001LWIP \u201c\u6613\u79fb\u690d\u201d \u7684\u6838\u5fc3\u4f53\u73b0<\/h4>\n<li>\u8de8 MCU \u517c\u5bb9&#xff1a;\u4e0a\u8ff0\u4ee3\u7801\u51e0\u4e4e\u4e0d\u7528\u6539&#xff0c;\u5c31\u80fd\u4ece STM32F4 \u79fb\u690d\u5230 STM32H7\u3001GD32\u3001IMX6UL \u7b49 MCU&#xff1b;<\/li>\n<li>\u5bf9\u63a5\u7b80\u5355&#xff1a;\u53ea\u9700\u5b9e\u73b0 ethernetif.c \u91cc\u7684 2 \u4e2a\u51fd\u6570&#xff08;low_level_input\/output&#xff09;&#xff0c;\u5c31\u80fd\u5bf9\u63a5\u4efb\u4f55 MCU \u7684 MAC \u786c\u4ef6&#xff1b;<\/li>\n<li>\u5f00\u5173\u53ef\u63a7&#xff1a;\u60f3\u8981\u4ec0\u4e48\u529f\u80fd\u5c31\u5f00\u4ec0\u4e48\u5b8f&#xff08;\u6bd4\u5982\u4e0d\u7528 DHCP \u5c31\u628a LWIP_DHCP \u8bbe\u4e3a 0&#xff09;&#xff0c;\u8d44\u6e90\u5360\u7528\u53ef\u7075\u6d3b\u8c03\u6574\u3002<\/li>\n<h4>\u603b\u7ed3<\/h4>\n<li>LWIP \u7684 \u201c\u529f\u80fd\u5168\u201d \u4f53\u73b0\u5728&#xff1a;\u901a\u8fc7\u7b80\u5355\u914d\u7f6e\u5c31\u80fd\u5f00\u542f TCP\/UDP\/IP\/DHCP\/DNS\/ICMP \u7b49\u6838\u5fc3\u7f51\u7edc\u529f\u80fd&#xff0c;\u6ee1\u8db3\u7edd\u5927\u591a\u6570\u5d4c\u5165\u5f0f\u8054\u7f51\u9700\u6c42&#xff1b;<\/li>\n<li>LWIP \u7684 \u201c\u6613\u79fb\u690d\u201d \u4f53\u73b0\u5728&#xff1a;\u6838\u5fc3\u4ee3\u7801\u65e0\u9700\u4fee\u6539&#xff0c;\u4ec5\u9700\u914d\u7f6e lwipopts.h &#043; \u5b9e\u73b0 MAC \u5bf9\u63a5\u51fd\u6570&#xff0c;\u5c31\u80fd\u9002\u914d\u4e0d\u540c MCU&#xff1b;<\/li>\n<li>\u5b9e\u9645\u5de5\u7a0b\u4e2d&#xff0c;\u4f60\u53ea\u9700\u628a LWIP \u6e90\u7801\u52a0\u5165\u5de5\u7a0b&#xff0c;\u6539\u914d\u7f6e\u6587\u4ef6&#xff0c;\u5199\u5bf9\u63a5\u51fd\u6570\u548c\u4e1a\u52a1\u4ee3\u7801&#xff0c;\u5c31\u80fd\u5feb\u901f\u7528\u4e0a\u5b8c\u6574\u7684\u7f51\u7edc\u529f\u80fd\u3002<\/li>\n<p>\u7b80\u5355\u8bf4&#xff1a;LWIP \u628a\u590d\u6742\u7684 TCP\/IP \u534f\u8bae\u5c01\u88c5\u6210\u4e86\u7b80\u5355\u7684 API&#xff0c;\u4f60\u4e0d\u7528\u61c2\u534f\u8bae\u7ec6\u8282&#xff0c;\u8c03\u7528\u63a5\u53e3\u5c31\u80fd\u5b9e\u73b0\u8054\u7f51\u3001\u901a\u4fe1\u3001\u57df\u540d\u89e3\u6790\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/p>\n<hr \/>\n<p>\u4f60\u95ee\u7684\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u662f\u4ece \u201c\u5b9e\u64cd\u5c42\u201d \u6df1\u5165\u5230\u4e86 \u201c\u534f\u8bae\u539f\u7406\u5c42\u201d&#xff0c;\u6211\u5148\u7ed9\u6838\u5fc3\u7ed3\u8bba&#xff0c;\u518d\u7528\u65b0\u624b\u80fd\u61c2\u7684\u65b9\u5f0f\u8bb2\u900f&#xff1a;<\/p>\n<h4>\u4e00\u3001\u6838\u5fc3\u7ed3\u8bba<\/h4>\n<p>\u2705 3 \u6b21\u63e1\u624b\u30014 \u6b21\u6325\u624b\u662f TCP \u534f\u8bae\u7684\u6838\u5fc3\u673a\u5236&#xff08;UDP \u6ca1\u6709&#xff09;&#xff1b;\u2705 \u8fd9\u4e9b\u673a\u5236\u4e0d\u662f\u4f60\u5199\u4ee3\u7801\u5b9e\u73b0&#xff0c;\u800c\u662fLWIP \u534f\u8bae\u6808\u5185\u90e8\u5df2\u7ecf\u5c01\u88c5\u597d\u7684&#xff0c;\u4f60\u8c03\u7528 LWIP \u7684 TCP API \u65f6&#xff0c;\u5b83\u4f1a\u81ea\u52a8\u5b8c\u6210\u3002<\/p>\n<p>\u7b80\u5355\u8bf4&#xff1a;\u4f60\u53ea\u9700\u8981\u8c03\u7528 tcp_connect()\/tcp_listen() \u7b49 API&#xff0c;LWIP \u4f1a\u5728\u5e95\u5c42\u81ea\u52a8\u5904\u7406 3 \u6b21\u63e1\u624b\u5efa\u7acb\u8fde\u63a5\u30014 \u6b21\u6325\u624b\u65ad\u5f00\u8fde\u63a5&#xff0c;\u4f60\u5b8c\u5168\u4e0d\u7528\u7ba1\u7ec6\u8282\u3002<\/p>\n<h4>\u4e8c\u3001\u5148\u641e\u61c2&#xff1a;3 \u6b21\u63e1\u624b \/ 4 \u6b21\u6325\u624b\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>\u7528 \u201c\u6253\u7535\u8bdd\u201d \u7684\u6bd4\u55bb&#xff0c;\u8ba9\u4f60\u4e00\u773c\u770b\u61c2&#xff08;TCP \u662f \u201c\u9762\u5411\u8fde\u63a5\u201d \u7684\u901a\u4fe1&#xff0c;\u50cf\u6253\u7535\u8bdd&#xff1b;UDP \u662f \u201c\u53d1\u77ed\u4fe1\u201d&#xff0c;\u65e0\u8fde\u63a5&#xff09;&#xff1a;<\/p>\n<h5>1. 3 \u6b21\u63e1\u624b&#xff08;\u5efa\u7acb TCP \u8fde\u63a5&#xff09;<\/h5>\n<p>\u76ee\u7684&#xff1a;\u786e\u4fdd\u53cc\u65b9\u90fd\u80fd \u201c\u542c\u5f97\u5230\u3001\u8bf4\u5f97\u51fa\u201d&#xff0c;\u5efa\u7acb\u53ef\u9760\u7684\u901a\u4fe1\u901a\u9053\u3002<\/p>\n<p>\u4f60&#xff08;\u5ba2\u6237\u7aef&#xff09;                \u670d\u52a1\u5668<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502  \u201c\u5582&#xff0c;\u80fd\u542c\u5230\u5417&#xff1f;\u201d&#xff08;SYN&#xff09;\u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt;\u2502<br \/>\n  \u2502                         \u2502  \u201c\u80fd\u542c\u5230&#xff01;\u4f60\u80fd\u542c\u5230\u6211\u5417&#xff1f;\u201d&#xff08;SYN&#043;ACK&#xff09;<br \/>\n  \u2502&lt;\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502  \u201c\u80fd\u542c\u5230&#xff01;\u5f00\u59cb\u804a\u5427\u201d&#xff08;ACK&#xff09;\u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt;\u2502<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502          \u8fde\u63a5\u5efa\u7acb&#xff0c;\u5f00\u59cb\u4f20\u6570\u636e          \u2502<\/p>\n<h5>2. 4 \u6b21\u6325\u624b&#xff08;\u65ad\u5f00 TCP \u8fde\u63a5&#xff09;<\/h5>\n<p>\u76ee\u7684&#xff1a;\u786e\u4fdd\u53cc\u65b9\u90fd\u628a\u6570\u636e\u53d1\u5b8c&#xff0c;\u4f18\u96c5\u65ad\u5f00\u8fde\u63a5&#xff08;TCP \u8981\u4fdd\u8bc1\u6570\u636e\u4e0d\u4e22&#xff09;\u3002<\/p>\n<p>\u4f60&#xff08;\u5ba2\u6237\u7aef&#xff09;                \u670d\u52a1\u5668<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502  \u201c\u6211\u8bf4\u5b8c\u4e86&#xff0c;\u8981\u6302\u4e86\u201d&#xff08;FIN&#xff09;\u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt;\u2502<br \/>\n  \u2502                         \u2502  \u201c\u597d&#xff0c;\u6211\u77e5\u9053\u4e86\u201d&#xff08;ACK&#xff09;<br \/>\n  \u2502&lt;\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502                         \u2502 &#xff08;\u670d\u52a1\u5668\u628a\u5269\u4e0b\u7684\u6570\u636e\u53d1\u5b8c&#xff09;<br \/>\n  \u2502                         \u2502  \u201c\u6211\u4e5f\u8bf4\u5b8c\u4e86&#xff0c;\u4f60\u6302\u5427\u201d&#xff08;FIN&#xff09;<br \/>\n  \u2502&lt;\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502  \u201c\u597d&#xff0c;\u90a3\u6211\u6302\u4e86\u201d&#xff08;ACK&#xff09;\u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500&gt;\u2502<br \/>\n  \u2502                         \u2502<br \/>\n  \u2502          \u8fde\u63a5\u65ad\u5f00          \u2502<\/p>\n<h4>\u4e09\u3001\u548c LWIP \u7684\u5173\u7cfb&#xff1a;\u4f60\u4e0d\u7528\u5199&#xff0c;LWIP \u5e2e\u4f60\u505a<\/h4>\n<p>LWIP \u7684 tcp.c \u6e90\u7801\u91cc&#xff0c;\u5df2\u7ecf\u5185\u7f6e\u4e86 3 \u6b21\u63e1\u624b \/ 4 \u6b21\u6325\u624b\u7684\u5b8c\u6574\u903b\u8f91&#xff0c;\u4f60\u5199\u4ee3\u7801\u65f6\u53ea\u9700\u8981\u8c03\u7528 API&#xff0c;\u5269\u4e0b\u7684\u5168\u7531 LWIP \u5904\u7406&#xff1a;<\/p>\n<h5>1. \u4f60\u5199\u7684\u4ee3\u7801&#xff08;\u6781\u7b80&#xff09;<\/h5>\n<p>\/\/ \u5ba2\u6237\u7aef\u5efa\u7acb TCP \u8fde\u63a5&#xff08;\u4f60\u53ea\u9700\u8981\u5199\u8fd9\u4e00\u884c&#xff09;<br \/>\ntcp_connect(pcb, &amp;dest_ip, 8080, tcp_connect_cb);<\/p>\n<p>\/\/ \u670d\u52a1\u5668\u65ad\u5f00\u8fde\u63a5&#xff08;\u4f60\u53ea\u9700\u8981\u5199\u8fd9\u4e00\u884c&#xff09;<br \/>\ntcp_close(pcb);<\/p>\n<h5>2. LWIP \u5e95\u5c42\u81ea\u52a8\u505a\u7684\u4e8b&#xff08;\u4f60\u5b8c\u5168\u4e0d\u7528\u7ba1&#xff09;<\/h5>\n<ul>\n<li>\u8c03\u7528 tcp_connect() \u540e&#xff1a;LWIP \u81ea\u52a8\u53d1\u9001 SYN \u5305 \u2192 \u7b49\u5f85\u670d\u52a1\u5668\u7684 SYN&#043;ACK \u2192 \u53d1\u9001 ACK&#xff0c;\u5b8c\u6210 3 \u6b21\u63e1\u624b&#xff1b;<\/li>\n<li>\u8c03\u7528 tcp_close() \u540e&#xff1a;LWIP \u81ea\u52a8\u53d1\u9001 FIN \u5305 \u2192 \u7b49\u5f85\u670d\u52a1\u5668\u7684 ACK \u2192 \u63a5\u6536\u670d\u52a1\u5668\u7684 FIN \u2192 \u53d1\u9001 ACK&#xff0c;\u5b8c\u6210 4 \u6b21\u6325\u624b&#xff1b;<\/li>\n<li>\u751a\u81f3\u8fde \u201c\u91cd\u4f20\u3001\u8d85\u65f6\u3001\u62e5\u585e\u63a7\u5236\u201d \u8fd9\u4e9b\u7ec6\u8282&#xff0c;LWIP \u4e5f\u4f1a\u81ea\u52a8\u5904\u7406\u3002<\/li>\n<\/ul>\n<h5>3. \u770b LWIP \u6e90\u7801\u91cc\u7684\u6838\u5fc3\u903b\u8f91&#xff08;\u4e0d\u7528\u6539&#xff0c;\u4e86\u89e3\u5373\u53ef&#xff09;<\/h5>\n<p>\u5728 LWIP \u7684 tcp.c \u4e2d&#xff0c;\u6709\u4e13\u95e8\u7684\u72b6\u6001\u673a\u5904\u7406\u63e1\u624b \/ \u6325\u624b&#xff1a;<\/p>\n<p>\/\/ LWIP \u5185\u90e8 TCP \u72b6\u6001\u673a&#xff08;\u7b80\u5316\u7248&#xff09;<br \/>\nswitch (pcb-&gt;state) {<br \/>\n  case CLOSED:<br \/>\n    \/\/ \u521d\u59cb\u72b6\u6001<br \/>\n    break;<br \/>\n  case SYN_SENT:<br \/>\n    \/\/ \u53d1\u9001 SYN \u540e&#xff0c;\u7b49\u5f85 SYN&#043;ACK&#xff08;\u63e1\u624b\u7b2c\u4e8c\u6b65&#xff09;<br \/>\n    break;<br \/>\n  case ESTABLISHED:<br \/>\n    \/\/ \u8fde\u63a5\u5df2\u5efa\u7acb&#xff0c;\u53ef\u6536\u53d1\u6570\u636e<br \/>\n    break;<br \/>\n  case FIN_WAIT_1:<br \/>\n    \/\/ \u53d1\u9001 FIN \u540e&#xff0c;\u7b49\u5f85 ACK&#xff08;\u6325\u624b\u7b2c\u4e00\u6b65&#xff09;<br \/>\n    break;<br \/>\n  \/\/ \u5176\u4ed6\u72b6\u6001&#8230;<br \/>\n}<\/p>\n<h4>\u56db\u3001\u65b0\u624b\u5173\u952e\u8ba4\u77e5<\/h4>\n<li>3 \u6b21\u63e1\u624b \/ 4 \u6b21\u6325\u624b\u662f TCP \u534f\u8bae\u7684\u6807\u51c6\u89c4\u5219&#xff0c;\u4e0d\u662f LWIP \u72ec\u521b\u7684&#xff0c;\u6240\u6709 TCP \u901a\u4fe1\u90fd\u5fc5\u987b\u9075\u5b88&#xff1b;<\/li>\n<li>LWIP \u4f5c\u4e3a TCP\/IP \u534f\u8bae\u6808&#xff0c;\u5df2\u7ecf\u628a\u8fd9\u4e9b\u89c4\u5219\u5c01\u88c5\u6210\u4e86\u5e95\u5c42\u903b\u8f91&#xff0c;\u4f60\u8c03\u7528 API \u5c31\u4f1a\u81ea\u52a8\u89e6\u53d1&#xff1b;<\/li>\n<li>\u4f60\u552f\u4e00\u9700\u8981\u5173\u6ce8\u7684&#xff1a;\u8c03\u7528 tcp_connect() \u540e&#xff0c;\u901a\u8fc7\u56de\u8c03\u51fd\u6570\u786e\u8ba4 \u201c\u8fde\u63a5\u662f\u5426\u5efa\u7acb\u6210\u529f\u201d&#xff1b;\u8c03\u7528 tcp_close() \u540e&#xff0c;\u786e\u8ba4 \u201c\u8fde\u63a5\u662f\u5426\u65ad\u5f00\u201d\u3002<\/li>\n<h4>\u603b\u7ed3<\/h4>\n<li>3 \u6b21\u63e1\u624b\u662f TCP \u5efa\u7acb\u8fde\u63a5\u7684\u6807\u51c6\u6d41\u7a0b&#xff0c;4 \u6b21\u6325\u624b\u662f TCP \u65ad\u5f00\u8fde\u63a5\u7684\u6807\u51c6\u6d41\u7a0b&#xff1b;<\/li>\n<li>\u8fd9\u4e9b\u6d41\u7a0b\u5c5e\u4e8e TCP \u534f\u8bae\u672c\u8eab&#xff0c;LWIP \u5b9e\u73b0\u4e86\u8fd9\u5957\u903b\u8f91&#xff0c;\u4f60\u8c03\u7528 LWIP \u7684 TCP API \u65f6\u4f1a\u81ea\u52a8\u6267\u884c&#xff1b;<\/li>\n<li>\u4f60\u5199\u4ee3\u7801\u65f6&#xff0c;\u53ea\u9700\u8981\u5173\u6ce8 \u201c\u8fde\u63a5\u6210\u529f \/ \u65ad\u5f00\u201d \u7684\u7ed3\u679c&#xff0c;\u4e0d\u7528\u5199\u4efb\u4f55\u63e1\u624b \/ \u6325\u624b\u7684\u5e95\u5c42\u4ee3\u7801\u3002<\/li>\n<p>\u7b80\u5355\u8bf4&#xff1a;3 \u6b21\u63e1\u624b \/ 4 \u6b21\u6325\u624b\u662f TCP \u7684 \u201c\u89c4\u77e9\u201d&#xff0c;LWIP \u662f\u5e2e\u4f60\u6309\u89c4\u77e9\u529e\u4e8b\u7684 \u201c\u52a9\u624b\u201d&#xff0c;\u4f60\u53ea\u9700\u8981\u544a\u8bc9\u52a9\u624b \u201c\u6211\u8981\u8fde\u8c01\u201d\u201c\u6211\u8981\u65ad\u5f00\u201d&#xff0c;\u5269\u4e0b\u7684\u89c4\u77e9\u5b83\u6765\u5b88\u3002<\/p>\n<\/p>\n<hr \/>\n<p>\u4f60\u8fd9\u4e2a\u95ee\u9898\u6b63\u597d\u80fd\u5e2e\u4f60\u6253\u901a \u201c\u7f51\u7edc\u534f\u8bae\u5206\u5c42\u201d \u7684\u6838\u5fc3\u903b\u8f91&#xff0c;\u5f7b\u5e95\u641e\u61c2 TCP \u6240\u5904\u7684\u4f4d\u7f6e\u548c\u6574\u4e2a\u7f51\u7edc\u534f\u8bae\u7684\u4f53\u7cfb&#xff01;\u5148\u7ed9\u6838\u5fc3\u7ed3\u8bba&#xff1a;<\/p>\n<h4>\u4e00\u3001\u6838\u5fc3\u7ed3\u8bba<\/h4>\n<p>\u2705 TCP \u7edd\u5bf9\u4e0d\u662f\u6700\u5e95\u5c42&#xff01;\u5b83\u5c5e\u4e8e \u201c\u4f20\u8f93\u5c42\u201d&#xff0c;\u5728\u6574\u4e2a\u7f51\u7edc\u534f\u8bae\u6808\u4e2d\u5904\u4e8e\u4e2d\u95f4\u5c42&#xff1b;\u2705 \u9664\u4e86 TCP&#xff0c;\u8fd8\u6709 UDP&#xff08;\u540c\u5c5e\u4f20\u8f93\u5c42&#xff09;&#xff0c;\u4ee5\u53ca\u66f4\u5e95\u5c42\u7684 IP\u3001\u4ee5\u592a\u7f51\u5e27\u3001\u7269\u7406\u5c42&#xff0c;\u548c\u66f4\u4e0a\u5c42\u7684 HTTP\u3001MQTT \u7b49\u5e94\u7528\u5c42\u534f\u8bae\u3002<\/p>\n<h4>\u4e8c\u3001\u7528 \u201c\u5feb\u9012\u201d \u6bd4\u55bb&#xff0c;\u770b\u61c2\u5b8c\u6574\u534f\u8bae\u5206\u5c42&#xff08;\u4ece\u4e0a\u5c42\u5230\u4e0b\u5c42&#xff09;<\/h4>\n<p>\u5d4c\u5165\u5f0f\u4ee5\u592a\u7f51\u5e38\u7528\u7684\u662f TCP\/IP \u4e94\u5c42\u6a21\u578b&#xff08;\u6bd4\u4e03\u5c42\u6a21\u578b\u66f4\u6613\u7406\u89e3&#xff09;&#xff0c;TCP \u53ea\u5728\u5176\u4e2d\u4e00\u5c42&#xff0c;\u6bcf\u4e00\u5c42\u90fd\u6709\u660e\u786e\u5206\u5de5&#xff1a;<\/p>\n<table>\n<tr>\u534f\u8bae\u5c42\u6838\u5fc3\u534f\u8bae \/ \u5185\u5bb9\u7c7b\u6bd4&#xff08;\u5feb\u9012&#xff09;\u5bf9\u5e94 LWIP \u6a21\u5757<\/tr>\n<tbody>\n<tr>\n<td>\u5e94\u7528\u5c42<\/td>\n<td>HTTP\u3001MQTT\u3001Modbus-TCP\u3001\u81ea\u5b9a\u4e49\u534f\u8bae<\/td>\n<td>\u4f60\u8981\u5bc4\u7684 \u201c\u8d27\u7269\u201d&#xff08;\u4e1a\u52a1\u6570\u636e&#xff09;<\/td>\n<td>LWIP\/apps&#xff08;\u53ef\u9009&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4f20\u8f93\u5c42<\/td>\n<td>TCP\u3001UDP<\/td>\n<td>\u5feb\u9012\u5355&#xff08;\u6807\u6ce8\u6536\u4ef6\u4eba\u3001\u4fdd\u4ef7\u7b49&#xff09;<\/td>\n<td>LWIP\/src\/core\/tcp.c\/udp.c<\/td>\n<\/tr>\n<tr>\n<td>\u7f51\u7edc\u5c42<\/td>\n<td>IP\u3001ICMP&#xff08;ping&#xff09;<\/td>\n<td>\u7269\u6d41\u8def\u7ebf&#xff08;\u4ece\u5317\u4eac\u5230\u4e0a\u6d77&#xff09;<\/td>\n<td>LWIP\/src\/core\/ip.c\/icmp.c<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u94fe\u8def\u5c42<\/td>\n<td>\u4ee5\u592a\u7f51\u5e27&#xff08;MAC \u5730\u5740&#xff09;<\/td>\n<td>\u5feb\u9012\u8d27\u8f66&#xff08;\u540c\u57ce\u8fd0\u8f93&#xff09;<\/td>\n<td>MCU \u5185\u7f6e MAC \u786c\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>\u7269\u7406\u5c42<\/td>\n<td>\u7535\u4fe1\u53f7 \/ \u5149\u4fe1\u53f7&#xff08;\u7f51\u7ebf \/ \u5149\u7ea4&#xff09;<\/td>\n<td>\u516c\u8def \/ \u5149\u7ea4\u7ebf\u8def<\/td>\n<td>PHY \u82af\u7247 &#043; \u7f51\u7ebf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>\u5173\u952e\u8bf4\u660e&#xff1a;<\/h5>\n<li>TCP \u5c5e\u4e8e\u4f20\u8f93\u5c42&#xff1a;\u8d1f\u8d23 \u201c\u53ef\u9760\u4f20\u8f93\u201d&#xff08;\u6570\u636e\u4e0d\u4e22\u3001\u6709\u5e8f&#xff09;&#xff0c;\u6bd4\u5982\u4f60\u53d1 1,2,3&#xff0c;\u5bf9\u65b9\u4e00\u5b9a\u6536\u5230 1,2,3&#xff0c;\u4e22\u5305\u4f1a\u91cd\u4f20&#xff1b;<\/li>\n<li>UDP \u4e5f\u5c5e\u4e8e\u4f20\u8f93\u5c42&#xff1a;\u8d1f\u8d23 \u201c\u65e0\u8fde\u63a5\u4f20\u8f93\u201d&#xff08;\u4e0d\u53ef\u9760\u3001\u901f\u5ea6\u5feb&#xff09;&#xff0c;\u6bd4\u5982\u53d1 1,2,3&#xff0c;\u5bf9\u65b9\u53ef\u80fd\u6536\u5230 1,3 \u6216\u6536\u4e0d\u5230&#xff0c;\u9002\u5408\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u7684\u573a\u666f&#xff08;\u5982\u4f20\u611f\u5668\u6570\u636e\u3001\u97f3\u89c6\u9891&#xff09;&#xff1b;<\/li>\n<li>\u6700\u5e95\u5c42\u662f\u7269\u7406\u5c42&#xff1a;\u5c31\u662f\u7f51\u7ebf\u91cc\u7684\u7535\u4fe1\u53f7\u3001PHY \u82af\u7247\u8f6c\u6362\u7684\u4fe1\u53f7&#xff0c;\u5b8c\u5168\u662f\u786c\u4ef6\u5c42\u9762&#xff1b;<\/li>\n<li>TCP \u4f9d\u8d56\u66f4\u4f4e\u5c42\u7684\u534f\u8bae&#xff1a;TCP \u6570\u636e\u5305\u5fc5\u987b\u6253\u5305\u8fdb IP \u5305&#xff0c;IP \u5305\u518d\u6253\u5305\u8fdb\u4ee5\u592a\u7f51\u5e27&#xff0c;\u6700\u7ec8\u901a\u8fc7\u7269\u7406\u5c42\u4f20\u8f93 \u2014\u2014 \u6ca1\u6709\u5e95\u5c42\u7684 IP\u3001\u4ee5\u592a\u7f51\u3001\u7269\u7406\u5c42&#xff0c;TCP \u5c31\u662f \u201c\u7a7a\u4e2d\u697c\u9601\u201d\u3002<\/li>\n<h4>\u4e09\u3001\u5b8c\u6574\u6570\u636e\u6253\u5305 \/ \u89e3\u6790\u6d41\u7a0b&#xff08;\u4ee5 TCP \u53d1\u9001 \u201chello\u201d \u4e3a\u4f8b&#xff09;<\/h4>\n<p>\u4f60\u5199\u7684\u4e1a\u52a1\u6570\u636e\u4f1a\u4ece\u4e0a\u5c42\u5230\u4e0b\u5c42\u9010\u5c42\u6253\u5305&#xff0c;\u63a5\u6536\u65b9\u518d\u53cd\u5411\u89e3\u6790&#xff0c;TCP \u53ea\u8d1f\u8d23\u5176\u4e2d\u4e00\u6b65&#xff1a;<\/p>\n<p>\u4f60\u7684\u4e1a\u52a1\u4ee3\u7801&#xff1a;&#034;hello&#034;&#xff08;\u5e94\u7528\u5c42&#xff09;<br \/>\n    \u2193<br \/>\nTCP \u5c42&#xff1a;\u7ed9&#034;hello&#034;\u52a0 TCP \u5934&#xff08;\u6e90\u7aef\u53e3\u3001\u76ee\u7684\u7aef\u53e3\u3001\u5e8f\u5217\u53f7&#xff09;\u2192 TCP \u5305<br \/>\n    \u2193<br \/>\nIP \u5c42&#xff1a;\u7ed9 TCP \u5305\u52a0 IP \u5934&#xff08;\u6e90 IP\u3001\u76ee\u7684 IP&#xff09;\u2192 IP \u5305<br \/>\n    \u2193<br \/>\n\u6570\u636e\u94fe\u8def\u5c42&#xff08;MAC&#xff09;&#xff1a;\u7ed9 IP \u5305\u52a0\u4ee5\u592a\u7f51\u5e27\u5934&#xff08;\u6e90 MAC\u3001\u76ee\u7684 MAC&#xff09;\u2192 \u4ee5\u592a\u7f51\u5e27<br \/>\n    \u2193<br \/>\n\u7269\u7406\u5c42&#xff08;PHY&#xff09;&#xff1a;\u628a\u4ee5\u592a\u7f51\u5e27\u8f6c\u6362\u6210\u7f51\u7ebf\u4e0a\u7684\u7535\u4fe1\u53f7 \u2192 \u53d1\u9001<\/p>\n<h4>\u56db\u3001\u9664\u4e86 TCP&#xff0c;\u5e38\u7528\u7684\u7f51\u7edc\u534f\u8bae&#xff08;\u6309\u5206\u5c42\u6574\u7406&#xff09;<\/h4>\n<h5>1. \u540c\u5c42&#xff08;\u4f20\u8f93\u5c42&#xff09;&#xff1a;UDP<\/h5>\n<ul>\n<li>\u7279\u70b9&#xff1a;\u65e0\u8fde\u63a5\u3001\u4e0d\u53ef\u9760\u3001\u901f\u5ea6\u5feb\u3001\u5f00\u9500\u5c0f&#xff1b;<\/li>\n<li>\u9002\u7528\u573a\u666f&#xff1a;\u4f20\u611f\u5668\u6570\u636e\u4e0a\u62a5\u3001\u5e7f\u64ad \/ \u7ec4\u64ad\u3001\u5b9e\u65f6\u63a7\u5236&#xff08;\u5982\u673a\u5668\u4eba\u9065\u63a7&#xff09;&#xff1b;<\/li>\n<li>LWIP \u652f\u6301&#xff1a;\u53ea\u9700\u5728 lwipopts.h \u4e2d\u5f00 LWIP_UDP&#061;1 \u5373\u53ef\u8c03\u7528 API\u3002<\/li>\n<\/ul>\n<h5>2. \u4e0b\u5c42&#xff08;\u7f51\u7edc\u5c42&#xff09;&#xff1a;IP\u3001ICMP<\/h5>\n<ul>\n<li>IP&#xff1a;\u6240\u6709 TCP\/UDP \u6570\u636e\u90fd\u5fc5\u987b\u901a\u8fc7 IP \u4f20\u8f93&#xff0c;\u8d1f\u8d23 \u201c\u8de8\u7f51\u6bb5\u5bfb\u5740\u201d&#xff08;\u6bd4\u5982\u4ece 192.168.1.100 \u5230 192.168.2.200&#xff09;&#xff1b;<\/li>\n<li>ICMP&#xff1a;ping \u57fa\u4e8e ICMP&#xff0c;\u7528\u4e8e\u68c0\u6d4b\u7f51\u7edc\u8fde\u901a\u6027&#xff0c;LWIP \u5f00 LWIP_ICMP&#061;1 \u5c31\u80fd\u54cd\u5e94 ping\u3002<\/li>\n<\/ul>\n<h5>3. \u4e0b\u5c42&#xff08;\u6570\u636e\u94fe\u8def\u5c42&#xff09;&#xff1a;ARP<\/h5>\n<ul>\n<li>\u4f5c\u7528&#xff1a;\u628a IP \u5730\u5740\u8f6c\u6362\u6210 MAC \u5730\u5740&#xff08;\u6bd4\u5982\u77e5\u9053 192.168.1.1 \u7684 IP&#xff0c;\u901a\u8fc7 ARP \u67e5\u5b83\u7684 MAC \u5730\u5740&#xff09;&#xff1b;<\/li>\n<li>LWIP \u81ea\u52a8\u5904\u7406&#xff1a;\u4f60\u4e0d\u7528\u5199\u4ee3\u7801&#xff0c;LWIP \u4f1a\u7ef4\u62a4 ARP \u7f13\u5b58\u8868\u3002<\/li>\n<\/ul>\n<h5>4. \u4e0a\u5c42&#xff08;\u5e94\u7528\u5c42&#xff09;&#xff1a;\u5e38\u7528\u534f\u8bae&#xff08;\u57fa\u4e8e TCP\/UDP&#xff09;<\/h5>\n<table>\n<tr>\u534f\u8bae\u57fa\u4e8e\u9002\u7528\u573a\u666f\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>HTTP<\/td>\n<td>TCP<\/td>\n<td>\u7f51\u9875\u8bbf\u95ee\u3001\u7269\u8054\u7f51\u8bbe\u5907\u914d\u7f51<\/td>\n<td>\u5355\u7247\u673a\u505a HTTP \u670d\u52a1\u5668&#xff0c;\u624b\u673a\u8bbf\u95ee<\/td>\n<\/tr>\n<tr>\n<td>MQTT<\/td>\n<td>TCP<\/td>\n<td>\u7269\u8054\u7f51\u6570\u636e\u4e0a\u62a5&#xff08;\u4f4e\u529f\u8017&#xff09;<\/td>\n<td>\u4f20\u611f\u5668\u6570\u636e\u53d1\u963f\u91cc\u4e91 \/ \u817e\u8baf\u4e91<\/td>\n<\/tr>\n<tr>\n<td>Modbus-TCP<\/td>\n<td>TCP<\/td>\n<td>\u5de5\u4e1a\u63a7\u5236&#xff08;PLC \/ \u4eea\u8868\u901a\u4fe1&#xff09;<\/td>\n<td>\u8bfb\u53d6\u53d8\u9891\u5668\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>DNS<\/td>\n<td>UDP<\/td>\n<td>\u57df\u540d\u89e3\u6790&#xff08;\u6bd4\u5982\u89e3\u6790\u767e\u5ea6 IP&#xff09;<\/td>\n<td>LWIP \u5f00 LWIP_DNS&#061;1 \u5373\u53ef\u7528<\/td>\n<\/tr>\n<tr>\n<td>DHCP<\/td>\n<td>UDP<\/td>\n<td>\u81ea\u52a8\u83b7\u53d6 IP \u5730\u5740<\/td>\n<td>\u4e0d\u7528\u624b\u52a8\u914d IP&#xff0c;\u63d2\u4e0a\u7f51\u7ebf\u81ea\u52a8\u83b7\u53d6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4e94\u3001\u65b0\u624b\u5173\u952e\u8ba4\u77e5<\/h4>\n<li>TCP \u4e0d\u662f\u5e95\u5c42&#xff1a;\u6700\u5e95\u5c42\u662f\u7269\u7406\u5c42&#xff08;\u7535\u4fe1\u53f7 \/ \u7f51\u7ebf&#xff09;&#xff0c;TCP \u4f9d\u8d56 IP\u3001\u4ee5\u592a\u7f51\u3001\u7269\u7406\u5c42\u624d\u80fd\u4f20\u8f93&#xff1b;<\/li>\n<li>TCP vs UDP \u600e\u4e48\u9009&#xff1a;\n<ul>\n<li>\u8981\u53ef\u9760&#xff08;\u6570\u636e\u4e0d\u4e22\u3001\u6709\u5e8f&#xff09;\u2192 \u9009 TCP&#xff08;\u5982\u6587\u4ef6\u4f20\u8f93\u3001\u63a7\u5236\u6307\u4ee4&#xff09;&#xff1b;<\/li>\n<li>\u8981\u5feb \/ \u5b9e\u65f6&#xff08;\u5141\u8bb8\u5c11\u91cf\u4e22\u5305&#xff09;\u2192 \u9009 UDP&#xff08;\u5982\u4f20\u611f\u5668\u6570\u636e\u3001\u97f3\u89c6\u9891&#xff09;&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>LWIP \u8986\u76d6\u7684\u8303\u56f4&#xff1a;LWIP \u4e3b\u8981\u5b9e\u73b0 \u201c\u4f20\u8f93\u5c42&#xff08;TCP\/UDP&#xff09;&#043; \u7f51\u7edc\u5c42&#xff08;IP\/ICMP&#xff09;\u201d&#xff0c;\u5e94\u7528\u5c42\u534f\u8bae&#xff08;HTTP\/MQTT&#xff09;\u53ef\u57fa\u4e8e LWIP \u6269\u5c55&#xff0c;\u7269\u7406\u5c42 \/ \u6570\u636e\u94fe\u8def\u5c42\u7531 MAC\/PHY \u786c\u4ef6\u5b9e\u73b0\u3002<\/li>\n<h4>\u603b\u7ed3<\/h4>\n<li>TCP \u5c5e\u4e8e\u4f20\u8f93\u5c42&#xff0c;\u4e0d\u662f\u6700\u5e95\u5c42&#xff0c;\u6700\u5e95\u5c42\u662f\u7269\u7406\u5c42&#xff08;\u7f51\u7ebf \/ PHY \u7535\u4fe1\u53f7&#xff09;&#xff1b;<\/li>\n<li>\u9664\u4e86 TCP&#xff0c;\u6838\u5fc3\u534f\u8bae\u8fd8\u5305\u62ec UDP&#xff08;\u4f20\u8f93\u5c42&#xff09;\u3001IP\/ICMP&#xff08;\u7f51\u7edc\u5c42&#xff09;\u3001ARP \/ \u4ee5\u592a\u7f51\u5e27&#xff08;\u6570\u636e\u94fe\u8def\u5c42&#xff09;&#xff0c;\u4ee5\u53ca HTTP\/MQTT \u7b49\u5e94\u7528\u5c42\u534f\u8bae&#xff1b;<\/li>\n<li>\u5d4c\u5165\u5f0f\u5f00\u53d1\u4e2d&#xff0c;LWIP \u5e2e\u4f60\u641e\u5b9a TCP\/UDP\/IP \u6838\u5fc3\u903b\u8f91&#xff0c;\u4f60\u53ea\u9700\u5173\u6ce8\u5e94\u7528\u5c42\u7684\u4e1a\u52a1\u534f\u8bae&#xff08;\u6bd4\u5982\u81ea\u5b9a\u4e49\u4f20\u611f\u5668\u6570\u636e\u683c\u5f0f&#xff0c;\u6216\u7528 MQTT \u4e0a\u62a5\u6570\u636e&#xff09;\u3002<\/li>\n<p>\u7b80\u5355\u8bf4&#xff1a;TCP \u662f \u201c\u53ef\u9760\u5feb\u9012\u5458\u201d&#xff0c;UDP \u662f \u201c\u5feb\u901f\u5feb\u9012\u5458\u201d&#xff0c;IP \u662f \u201c\u7269\u6d41\u89c4\u5212\u5e08\u201d&#xff0c;MAC\/PHY \u662f \u201c\u8d27\u8f66\u548c\u516c\u8def\u201d&#xff0c;\u4f60\u53ea\u9700\u8981\u544a\u8bc9 \u201c\u5feb\u9012\u5458\u201d \u8981\u5bc4\u4ec0\u4e48\u8d27&#xff08;\u5e94\u7528\u5c42\u6570\u636e&#xff09;&#xff0c;\u5269\u4e0b\u7684\u8fd0\u8f93\u73af\u8282\u7531\u5e95\u5c42\u534f\u8bae \/ \u786c\u4ef6\u641e\u5b9a\u3002<\/p>\n<\/p>\n<p>\u7ed9\u4f60\u4e00\u5f20\u6781\u7b80\u6e05\u6670\u8868\u683c&#xff0c;\u4e00\u773c\u770b\u61c2\u5b83\u4eec\u7684\u5173\u7cfb\u3001\u7528\u9014\u3001\u5e95\u5c42\u534f\u8bae&#xff1a;<\/p>\n<table>\n<tr>\u534f\u8bae\u4f5c\u7528\u573a\u666f\u57fa\u4e8e\u4ec0\u4e48\u5c5e\u4e8e\u54ea\u5c42<\/tr>\n<tbody>\n<tr>\n<td>HTTP<\/td>\n<td>\u7f51\u9875 \/ \u63a5\u53e3\u901a\u4fe1&#xff0c;\u4e00\u95ee\u4e00\u7b54<\/td>\n<td>\u6d4f\u89c8\u5668\u3001APP\u3001\u8bbe\u5907\u914d\u7f51\u3001\u7f51\u9875\u63a7\u5236<\/td>\n<td>TCP<\/td>\n<td>\u5e94\u7528\u5c42<\/td>\n<\/tr>\n<tr>\n<td>MQTT<\/td>\n<td>\u7269\u8054\u7f51\u4f4e\u529f\u8017\u6570\u636e\u4e0a\u62a5&#xff08;\u53d1\u5e03 \/ \u8ba2\u9605&#xff09;<\/td>\n<td>\u4f20\u611f\u5668\u4e0a\u4e91\u3001\u8fdc\u7a0b\u63a7\u5236<\/td>\n<td>TCP<\/td>\n<td>\u5e94\u7528\u5c42<\/td>\n<\/tr>\n<tr>\n<td>Modbus-TCP<\/td>\n<td>\u5de5\u4e1a\u8bbe\u5907\u901a\u4fe1&#xff08;PLC\u3001\u4eea\u8868\u3001\u53d8\u9891\u5668&#xff09;<\/td>\n<td>\u5de5\u4e1a\u63a7\u5236\u3001\u5355\u7247\u673a\u8fde PLC<\/td>\n<td>TCP<\/td>\n<td>\u5e94\u7528\u5c42<\/td>\n<\/tr>\n<tr>\n<td>DNS<\/td>\n<td>\u57df\u540d \u2192 IP \u89e3\u6790<\/td>\n<td>\u8f93\u5165\u7f51\u5740\u81ea\u52a8\u627e\u5230 IP<\/td>\n<td>UDP\/TCP<\/td>\n<td>\u5e94\u7528\u5c42<\/td>\n<\/tr>\n<tr>\n<td>DHCP<\/td>\n<td>\u81ea\u52a8\u83b7\u53d6 IP \u5730\u5740<\/td>\n<td>\u63d2\u4e0a\u7f51\u7ebf\u81ea\u52a8\u6709 IP<\/td>\n<td>UDP<\/td>\n<td>\u5e94\u7528\u5c42<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4e00\u53e5\u8bdd\u603b\u5173\u7cfb<\/h4>\n<p>HTTP \/ MQTT \/ Modbus-TCP \/ DNS \/ DHCP\u90fd\u5c5e\u4e8e\u5e94\u7528\u5c42&#xff0c;\u90fd\u8dd1\u5728 TCP\/UDP \u4e4b\u4e0a&#xff0c;\u90fd\u7531 LWIP \u652f\u6301\u3002<\/p>\n<\/p>\n<\/p>\n<\/p>\n<hr \/>\n<h2>\u6700\u7ec8\u5305\u542b\u5173\u7cfb&#xff08;\u4ece\u4e0a\u5230\u4e0b&#xff1a;\u5927 \u2192 \u5c0f&#xff09;<\/h2>\n<p>\u30101. \u6574\u4e2a\u7f51\u7edc\u901a\u4fe1\u3011<br \/>\n    \u2193 \u5305\u542b<br \/>\n\u30102. TCP\/IP \u534f\u8bae\u6808\u3011&#xff08;LWIP \u5c31\u662f\u5b9e\u73b0\u5b83&#xff09;<br \/>\n    \u2193 \u5305\u542b<br \/>\n\u30103. TCP \u534f\u8bae\u3011&#xff08;\u53ef\u9760\u4f20\u8f93\u30013\u6b21\u63e1\u624b\/4\u6b21\u6325\u624b&#xff09;<br \/>\n    \u2193 \u4f9d\u8d56&#xff08;\u4e0d\u662f\u5305\u542b&#xff09;<br \/>\n\u30104. IP \u534f\u8bae\u3011&#xff08;\u8d1f\u8d23\u627e\u8bbe\u5907&#xff1a;IP \u5730\u5740&#xff09;<br \/>\n    \u2193 \u4f9d\u8d56&#xff08;\u4e0d\u662f\u5305\u542b&#xff09;<br \/>\n\u30105. \u4ee5\u592a\u7f51\u3011&#xff08;\u6700\u5e95\u5c42\u786c\u4ef6\u901a\u8def&#xff09;<br \/>\n        \u5305\u542b&#xff1a;MAC\u3001PHY\u3001RGMII\u3001MDIO\/MDC\u3001\u7f51\u7ebf\u3001\u7f51\u53e3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHY \u662f\u7269\u7406\u5c42\u82af\u7247&#xff0c;MAC \u662f\u4ecb\u8d28\u8bbf\u95ee\u63a7\u5236\u5c42&#xff0c;\u4e24\u8005\u4e0d\u662f\u4e00\u56de\u4e8b\u30021. \u4e00\u53e5\u8bdd\u5206\u6e05&#xff1a;MAC vs PHYMAC&#xff1a;\u7ba1 \u201c\u6570\u636e\u600e\u4e48\u6253\u5305\u3001\u53d1\u7ed9\u8c01\u201d&#xff08;\u6570\u5b57\u903b\u8f91&#xff0c;\u7eaf\u6570\u5b57\u7535\u8def&#xff09;PHY&#xff1a;\u7ba1 \u201c\u600e\u4e48\u628a\u6570\u636e\u53d8\u6210\u7f51\u7ebf\u4e0a\u7684\u7535\u4fe1\u53f7\u201d&#xff08;\u6a21\u62df  \u6570\u5b57&#xff0c;\u5fc5\u987b\u5916\u63a5\u82af\u7247&#xff09;\u5b83\u4eec\u7684\u5173\u7cfb&#xff1a;MCU \/ CPU \u2192 MAC \u2192 MII\/RMII\/RGMII<\/p>\n","protected":false},"author":2,"featured_media":80120,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4811,970,4281,270,269],"topic":[],"class_list":["post-80121","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-diy","tag-tcp","tag-4281","tag-270","tag-269"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/80121.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"PHY \u662f\u7269\u7406\u5c42\u82af\u7247&#xff0c;MAC \u662f\u4ecb\u8d28\u8bbf\u95ee\u63a7\u5236\u5c42&#xff0c;\u4e24\u8005\u4e0d\u662f\u4e00\u56de\u4e8b\u30021. \u4e00\u53e5\u8bdd\u5206\u6e05&#xff1a;MAC vs PHYMAC&#xff1a;\u7ba1 \u201c\u6570\u636e\u600e\u4e48\u6253\u5305\u3001\u53d1\u7ed9\u8c01\u201d&#xff08;\u6570\u5b57\u903b\u8f91&#xff0c;\u7eaf\u6570\u5b57\u7535\u8def&#xff09;PHY&#xff1a;\u7ba1 \u201c\u600e\u4e48\u628a\u6570\u636e\u53d8\u6210\u7f51\u7ebf\u4e0a\u7684\u7535\u4fe1\u53f7\u201d&#xff08;\u6a21\u62df \u6570\u5b57&#xff0c;\u5fc5\u987b\u5916\u63a5\u82af\u7247&#xff09;\u5b83\u4eec\u7684\u5173\u7cfb&#xff1a;MCU \/ CPU \u2192 MAC \u2192 MII\/RMII\/RGMII\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/80121.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-04T04:09:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260304040947-69a7b08b2f62c.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80121.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/80121.html\",\"name\":\"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-04T04:09:48+00:00\",\"dateModified\":\"2026-03-04T04:09:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/80121.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/80121.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80121.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/80121.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"PHY \u662f\u7269\u7406\u5c42\u82af\u7247&#xff0c;MAC \u662f\u4ecb\u8d28\u8bbf\u95ee\u63a7\u5236\u5c42&#xff0c;\u4e24\u8005\u4e0d\u662f\u4e00\u56de\u4e8b\u30021. \u4e00\u53e5\u8bdd\u5206\u6e05&#xff1a;MAC vs PHYMAC&#xff1a;\u7ba1 \u201c\u6570\u636e\u600e\u4e48\u6253\u5305\u3001\u53d1\u7ed9\u8c01\u201d&#xff08;\u6570\u5b57\u903b\u8f91&#xff0c;\u7eaf\u6570\u5b57\u7535\u8def&#xff09;PHY&#xff1a;\u7ba1 \u201c\u600e\u4e48\u628a\u6570\u636e\u53d8\u6210\u7f51\u7ebf\u4e0a\u7684\u7535\u4fe1\u53f7\u201d&#xff08;\u6a21\u62df \u6570\u5b57&#xff0c;\u5fc5\u987b\u5916\u63a5\u82af\u7247&#xff09;\u5b83\u4eec\u7684\u5173\u7cfb&#xff1a;MCU \/ CPU \u2192 MAC \u2192 MII\/RMII\/RGMII","og_url":"https:\/\/www.wsisp.com\/helps\/80121.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-04T04:09:48+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/03\/20260304040947-69a7b08b2f62c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"15 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/80121.html","url":"https:\/\/www.wsisp.com\/helps\/80121.html","name":"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-04T04:09:48+00:00","dateModified":"2026-03-04T04:09:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/80121.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/80121.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/80121.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b80\u5355\u7406\u89e3\uff1aMAC\u662f\u4ec0\u4e48\uff1f\u5355\u7247\u673a\u4ee5\u592a\u7f51\u901a\u4fe1\u5168\u94fe\u8def\u662f\u600e\u4e48\u6837\u7684\uff1fTCP\u3001MQTT\u3001HTTP\u4ed6\u4eec\u4e4b\u95f4\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/80121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=80121"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/80121\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/80120"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=80121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=80121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=80121"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=80121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}