测试网络报文,wireshark导出来的格式不大符合要求,写一个自己用。

#include <stdio.h>
#include <string.h>
typedef unsigned short INT16U;
typedef unsigned char  INT8U;

#define FRAME_LEN    178
INT8U array[FRAME_LEN];
INT8U frame[FRAME_LEN];
void hex_to_array(void);

int main()
{
    hex_to_array();
   
    return 0;
}
void hex_to_array(void)
{
    INT8U *p;
    INT16U i = 0;
    INT8U ch;
    do
    {
        scanf("%02x",&frame[i++]);    
    }while(i < FRAME_LEN);
    i = 0;
    printf("frame[FRAME_LEN] = \n");
    printf("{\n");
    for(p = frame;p < (frame + sizeof(frame)/sizeof(INT8U));p++)
    {        
        if(i % 16 == 0)
        {
            printf("\n");
        }
        i++;
        printf("0x%02x",*p);
        if(i != sizeof(frame)/sizeof(INT8U))
        {
            printf(",");            
        }
    }
    printf("\n}");
}

wireshark中报文,复制成hex stream

效果如图:

输入十六进制,转成数组

 

相关文章:

  • 2021-08-29
  • 2021-11-17
  • 2022-12-23
  • 2021-11-21
  • 2021-12-14
  • 2021-12-27
  • 2022-12-23
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
相关资源
相似解决方案