微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > udp包格式问题

udp包格式问题

时间:10-02 整理:3721RD 点击:
大家好,我在利用verilog做以太网通信,封装UDP包时,不理解什么意思,下面是其中一段程序:
ethernet_data_process : process(c3_rst0,clk_50mhz)
begin
Tx_mac_BE <= "00";

-- UDP packet
eth_array(0) <= dst_mac_addr(47 downto 16);--要发送的目的MAC地址高4个字节
eth_array(1) <= dst_mac_addr(15 downto 0) & mac_addr(47 downto 32);--要发送的目的MAC地址低2个字节&源MAC地址
eth_array(2) <= mac_addr(31 downto 0);--源MAC低4个字节
--  ethernet type    | Version / Header length | diff Services
eth_array(3) <= x"0800"          & "0100" & "0101"         & "00000000"    ;
-- total length        |  identification
eth_array(4) <= "00000000"&"00100010" & x"0000";
-- Flags , Fragment Offeset  | time to live | protocol
eth_array(5) <= "0100000000000000"          &  "01000000"  & "00010001";
-- header checksum |  Source IP:
eth_array(6) <= calc_checksum     &  own_ip_addr(31 downto 16);
--         
     |  Destin IP:
eth_array(7) <= own_ip_addr(15 downto 0) &  dst_ip_addr(31 downto 16);
--            
| source port
eth_array(8) <= dst_ip_addr(15 downto 0)  &  source_port ;
-- dest port | length
eth_array(9) <= dest_port   & "00000000" & "00001110" ;
-- checksum  |  data
eth_array(10) <= x"0000"    &  x"4865";
-- data
eth_array(11) <= x"6c6c6f20";

问题:首先发送6个字节的目的MAC地址及6个字节的源MAC地址,接着x"0800" 是IP协议类型,后面的"0100" & "0101"  & "00000000" 是什么意思呢,它上面一行倒是解释了好像是
Version / Header length | diff Services,但是我没找有关UDP包格式是这样的,接着下面一行的-- Flags , Fragment Offeset  | time to live | protocol,又是什么意思呢,没见过UDP格式的包是这种格式的,能不能提供一下UDP详细的包的格式,谢谢

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top