floweraa 发表于 2020-3-11 19:03:07

UDP包格式問题

    eth_array(1)<=dst_mac_addr(15downto0问题:首先发送6个字节的目的MAC地址及6个字节的源MAC地址,接着x"Version/Headerlength|diffServices,但是



大家好,我在利用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详细的包的格式,謝谢

页: [1]
查看完整版本: UDP包格式問题