用户态协议栈03-icmp实现

news2024/11/27 17:59:33

icmp协议

ICMP(Internet Control Message Protocol)Internet控制报文协议。它是TCP/IP协议簇的一个子协议,用于在IP主机、路由器之间传递控制消息。控制消息是指网络通不通、主机是否可达、路由是否可用等网络本身的消息。这些控制消息虽然并不传输用户数据,但是对于用户数据的传递起着重要的作用。 [1]

ICMP使用IP的基本支持,就像它是一个更高级别的协议,但是,ICMP实际上是IP的一个组成部分,必须由每个IP模块实现。

icmp报文结构

打包icmp

打包其实都是一个原理,直接放代码了:

static void dpdk_encode_icmp_pkt(uint8_t* msg, uint8_t* dst_mac, uint32_t sip, uint32_t dip, uint16_t id, uint16_t seq) {
    struct rte_ether_hdr* eth = (struct rte_ether_hdr*)msg;
    rte_memcpy(eth->s_addr.addr_bytes, gSrcMac, RTE_ETHER_ADDR_LEN);
    rte_memcpy(eth->d_addr.addr_bytes, dst_mac, RTE_ETHER_ADDR_LEN);
    eth->ether_type = htons(RTE_ETHER_TYPE_IPV4);

    struct rte_ipv4_hdr* ip = (struct rte_ipv4_hdr*)(eth + 1);
    ip->version_ihl = 0x45;
    ip->type_of_service = 0;
    ip->total_length = htons(sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_icmp_hdr));
    ip->packet_id = 0;
    ip->fragment_offset = 0;
    ip->time_to_live = 64;
    ip->next_proto_id = IPPROTO_ICMP;
    ip->dst_addr = dip;
    ip->src_addr = sip;
    ip->hdr_checksum = 0;
    ip->hdr_checksum = rte_ipv4_cksum(ip);

    struct rte_icmp_hdr* icmp = (struct rte_icmp_hdr*)(ip + 1);
    icmp->icmp_type = RTE_IP_ICMP_ECHO_REPLY;
    icmp->icmp_code = 0;
    icmp->icmp_ident = id;
    icmp->icmp_seq_nb = seq;
    icmp->icmp_cksum = 0;
    icmp->icmp_cksum = rte_icmp_cksum((uint16_t*)icmp, sizeof(struct rte_icmp_hdr));
}

static struct rte_mbuf* dpdk_send_icmp(struct rte_mempool* mbuf_pool, uint8_t* dst_mac, uint32_t sip,  uint32_t dip, uint16_t id, uint16_t seq) {
    struct rte_mbuf* mbuf = rte_pktmbuf_alloc(mbuf_pool);
    if(!mbuf) {
        rte_exit(EXIT_FAILURE, "rte_pktmbuf_alloc\n");
    }
    uint16_t total_len = sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_icmp_hdr);
    mbuf->pkt_len = total_len;
    mbuf->data_len = total_len;
    uint8_t* pkt = rte_pktmbuf_mtod(mbuf, uint8_t*);
    dpdk_encode_icmp_pkt(pkt, dst_mac, sip, dip, id, seq);
    return mbuf;
}

这里我们依然是做的基础的回复包,效果是使用物理机进行ping操作的时候,可以收到数据返回,所以我们只是打了一个RTE_IP_ICMP_ECHO_REPLY的包。

icmp校验

由于DPDK中好像没有专门的ICMP校验接口,这里我们参考文档自己写一个,文档我会放在最后:

static uint16_t rte_icmp_cksum(uint16_t* addr, int count) {
    long sum = 0;
    while (count > 1)
    {
        sum += *(unsigned short*)addr++;
        count -= 2;
    }
    if(count > 0)
        sum += *(unsigned char*)addr;
    while(sum >> 16)
        sum = (sum & 0xffff) + (sum >> 16);
    return ~sum;
}

完整代码

#include <rte_eal.h>
#include <rte_ethdev.h>
#include <stdio.h>
#include <arpa/inet.h>

#define MBUF_LEN    (4096-1)
#define MBUF_SIZE   64
static const int gDpdkPortId = 0;
#define MAKE_IPV4_ADDR(a, b, c, d)  (a + (b<<8) + (c<<16) + (d<<24))
uint32_t gLocalIp = MAKE_IPV4_ADDR(192, 168, 1, 185);

uint32_t gSrcIp;
uint32_t gDstIp;
uint8_t gSrcMac[RTE_ETHER_ADDR_LEN];
uint8_t gDstMac[RTE_ETHER_ADDR_LEN];
uint16_t gSrcPort;
uint16_t gDstPort;

struct rte_eth_conf default_port_info = {
    .rxmode = {.max_rx_pkt_len = RTE_ETHER_MAX_LEN},
};

static void dpdk_port_init(struct rte_mempool* mbuf_pool) {
    uint16_t sys_port_count = rte_eth_dev_count_avail();
    if(sys_port_count == 0)
        rte_exit(EXIT_FAILURE, "Could not support port\n");
    
    struct rte_eth_dev_info dev_info;
    rte_eth_dev_info_get(gDpdkPortId, &dev_info);
    const unsigned nb_rx_queue = 1;
    const unsigned nb_tx_queue = 1;
    struct rte_eth_conf port_conf = default_port_info;
    rte_eth_dev_configure(gDpdkPortId, nb_rx_queue, nb_tx_queue, &port_conf);
    if(rte_eth_rx_queue_setup(gDpdkPortId, 0, 128, rte_eth_dev_socket_id(gDpdkPortId), NULL, mbuf_pool) < 0)
        rte_exit(EXIT_FAILURE, "Could not setup RX queue\n");
    struct rte_eth_txconf txconf = dev_info.default_txconf;
    txconf.offloads = default_port_info.rxmode.offloads;
    if(rte_eth_tx_queue_setup(gDpdkPortId, 0, 512, rte_eth_dev_socket_id(gDpdkPortId), &txconf) < 0)
        rte_exit(EXIT_FAILURE, "Could not setup TX queue\n");
    if(rte_eth_dev_start(gDpdkPortId) < 0)
        rte_exit(EXIT_FAILURE, "Could not start\n");
}

static void dpdk_encode_udp_pkt(uint8_t* msg, uint8_t* data, uint16_t total_len) {
    struct rte_ether_hdr* eth = (struct rte_ether_hdr*)msg;
    rte_memcpy(eth->d_addr.addr_bytes, gDstMac, RTE_ETHER_ADDR_LEN);
    rte_memcpy(eth->s_addr.addr_bytes, gSrcMac, RTE_ETHER_ADDR_LEN);
    eth->ether_type = htons(RTE_ETHER_TYPE_IPV4);

    struct rte_ipv4_hdr* ip = (struct rte_ipv4_hdr*)(eth + 1);
    ip->version_ihl = 0x45;
    ip->type_of_service = 0;
    ip->total_length = htons(total_len - sizeof(struct rte_ether_hdr));
    ip->packet_id = 0;
    ip->fragment_offset = 0;
    ip->time_to_live = 64;
    ip->next_proto_id = IPPROTO_UDP;
    ip->dst_addr = gDstIp;
    ip->src_addr = gSrcIp;
    ip->hdr_checksum = 0;
    ip->hdr_checksum = rte_ipv4_cksum(ip);
    
    struct rte_udp_hdr* udp = (struct rte_udp_hdr*)(ip + 1);
    uint16_t length = total_len - sizeof(struct rte_ether_hdr) - sizeof(struct rte_ipv4_hdr);
    udp->dst_port = gDstPort;
    udp->src_port = gSrcIp;
    udp->dgram_len = htons(length);
    rte_memcpy((uint8_t*)(udp + 1), data, length);
    udp->dgram_cksum = 0;
    udp->dgram_cksum = rte_ipv4_udptcp_cksum(ip, udp);
}

static  struct rte_mbuf* dpdk_send_udp(struct rte_mempool* mbuf_pool, uint8_t* data, uint16_t length) {
    struct rte_mbuf* mbuf = rte_pktmbuf_alloc(mbuf_pool);
    if(!mbuf)
        rte_exit(EXIT_FAILURE, "rte_pktmbuf_alloc\n");
    uint16_t total_len = length + 42;
    mbuf->pkt_len = total_len;
    mbuf->data_len = total_len;
    uint8_t* pkt = rte_pktmbuf_mtod(mbuf, uint8_t*);
    dpdk_encode_udp_pkt(pkt, data, length);
    return mbuf;
}

static void dpdk_encode_arp_pkt(uint8_t* msg, uint8_t* dst_mac, uint32_t sip, uint32_t dip) {
    struct rte_ether_hdr* eth = (struct rte_ether_hdr*)(msg);
    rte_memcpy(eth->s_addr.addr_bytes, gSrcMac, RTE_ETHER_ADDR_LEN);
    rte_memcpy(eth->d_addr.addr_bytes, dst_mac, RTE_ETHER_ADDR_LEN);
    eth->ether_type = htons(RTE_ETHER_TYPE_ARP);
    struct rte_arp_hdr* arp = (struct rte_arp_hdr*)(eth + 1);
    arp->arp_hardware = htons(1);
    arp->arp_protocol = htons(RTE_ETHER_TYPE_IPV4);
    arp->arp_plen = sizeof(uint32_t);
    arp->arp_hlen = RTE_ETHER_ADDR_LEN;
    arp->arp_opcode = htons(2);
    arp->arp_data.arp_sip = sip;
    arp->arp_data.arp_tip = dip;
    rte_memcpy(arp->arp_data.arp_sha.addr_bytes, gSrcMac, RTE_ETHER_ADDR_LEN);
    rte_memcpy(arp->arp_data.arp_tha.addr_bytes, dst_mac, RTE_ETHER_ADDR_LEN);
}

static  struct rte_mbuf* dpdk_send_arp(struct rte_mempool* mbuf_pool, uint8_t* dst_mac, uint32_t sip, uint32_t dip) {
    struct rte_mbuf* mbuf = rte_pktmbuf_alloc(mbuf_pool);
    if(!mbuf)
        rte_exit(EXIT_FAILURE, "rte_pktmbuf_alloc\n");
    uint16_t total_len = sizeof(struct rte_ether_hdr) + sizeof(struct rte_arp_hdr);
    mbuf->pkt_len = total_len;
    mbuf->data_len = total_len;
    uint8_t* pkt = rte_pktmbuf_mtod(mbuf, uint8_t*);
    dpdk_encode_arp_pkt(pkt, dst_mac, sip, dip);
    return mbuf;
}

static uint16_t rte_icmp_cksum(uint16_t* addr, int count) {
    long sum = 0;
    while (count > 1)
    {
        sum += *(unsigned short*)addr++;
        count -= 2;
    }
    if(count > 0)
        sum += *(unsigned char*)addr;
    while(sum >> 16)
        sum = (sum & 0xffff) + (sum >> 16);
    return ~sum;
}

static void dpdk_encode_icmp_pkt(uint8_t* msg, uint8_t* dst_mac, uint32_t sip, uint32_t dip, uint16_t id, uint16_t seq) {
    struct rte_ether_hdr* eth = (struct rte_ether_hdr*)msg;
    rte_memcpy(eth->s_addr.addr_bytes, gSrcMac, RTE_ETHER_ADDR_LEN);
    rte_memcpy(eth->d_addr.addr_bytes, dst_mac, RTE_ETHER_ADDR_LEN);
    eth->ether_type = htons(RTE_ETHER_TYPE_IPV4);

    struct rte_ipv4_hdr* ip = (struct rte_ipv4_hdr*)(eth + 1);
    ip->version_ihl = 0x45;
    ip->type_of_service = 0;
    ip->total_length = htons(sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_icmp_hdr));
    ip->packet_id = 0;
    ip->fragment_offset = 0;
    ip->time_to_live = 64;
    ip->next_proto_id = IPPROTO_ICMP;
    ip->dst_addr = dip;
    ip->src_addr = sip;
    ip->hdr_checksum = 0;
    ip->hdr_checksum = rte_ipv4_cksum(ip);

    struct rte_icmp_hdr* icmp = (struct rte_icmp_hdr*)(ip + 1);
    icmp->icmp_type = RTE_IP_ICMP_ECHO_REPLY;
    icmp->icmp_code = 0;
    icmp->icmp_ident = id;
    icmp->icmp_seq_nb = seq;
    icmp->icmp_cksum = 0;
    icmp->icmp_cksum = rte_icmp_cksum((uint16_t*)icmp, sizeof(struct rte_icmp_hdr));
}

static struct rte_mbuf* dpdk_send_icmp(struct rte_mempool* mbuf_pool, uint8_t* dst_mac, uint32_t sip,  uint32_t dip, uint16_t id, uint16_t seq) {
    struct rte_mbuf* mbuf = rte_pktmbuf_alloc(mbuf_pool);
    if(!mbuf) {
        rte_exit(EXIT_FAILURE, "rte_pktmbuf_alloc\n");
    }
    uint16_t total_len = sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_icmp_hdr);
    mbuf->pkt_len = total_len;
    mbuf->data_len = total_len;
    uint8_t* pkt = rte_pktmbuf_mtod(mbuf, uint8_t*);
    dpdk_encode_icmp_pkt(pkt, dst_mac, sip, dip, id, seq);
    return mbuf;
}


int main(int argc, char* argv[]) {
    if(rte_eal_init(argc, argv) < 0)
        rte_exit(EXIT_FAILURE, "Error with eal init\n");

    struct rte_mempool* mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", MBUF_LEN, 0, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
    if(!mbuf_pool)
        rte_exit(EXIT_FAILURE, "Error with mempool create\n");
    dpdk_port_init(mbuf_pool);
    rte_eth_macaddr_get(gDpdkPortId, (struct rte_ether_addr*)gSrcMac);
    while(1) {
        struct rte_mbuf* mbufs[MBUF_SIZE];
        int nb_pkt = rte_eth_rx_burst(gDpdkPortId, 0, mbufs, MBUF_SIZE);
        if(nb_pkt > MBUF_SIZE)
            rte_exit(EXIT_FAILURE, "Error withs pkt num\n");
        int i;
        for(i = 0; i < nb_pkt; i++) {
            struct rte_ether_hdr* eth = rte_pktmbuf_mtod(mbufs[i], struct rte_ether_hdr*);
            if(eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP)) {
                struct rte_arp_hdr* arp = rte_pktmbuf_mtod_offset(mbufs[i], struct rte_arp_hdr*, sizeof(struct rte_ether_hdr));
                struct in_addr addr;
                    addr.s_addr = arp->arp_data.arp_sip;
                    printf("arp-->src: %s ", inet_ntoa(addr));
                    addr.s_addr = arp->arp_data.arp_tip;
                    printf("dst: %s\n", inet_ntoa(addr));
                if(arp->arp_data.arp_tip == gLocalIp) {
                    struct rte_mbuf* txbuf = dpdk_send_arp(mbuf_pool, arp->arp_data.arp_sha.addr_bytes, gLocalIp, arp->arp_data.arp_sip);
                    rte_eth_tx_burst(gDpdkPortId, 0, &txbuf, 1);
                    rte_pktmbuf_free(txbuf);
                    rte_pktmbuf_free(mbufs[i]);
                    txbuf = NULL;
                    mbufs[i] = NULL;
                }
                continue;
            }
            if(eth->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4)) {
                rte_pktmbuf_free(mbufs[i]);
                mbufs[i] = NULL;
                continue;
            }
            struct rte_ipv4_hdr* ip = rte_pktmbuf_mtod_offset(mbufs[i], struct rte_ipv4_hdr*, sizeof(struct rte_ether_hdr));
            if(ip->next_proto_id == IPPROTO_UDP) {
                struct rte_udp_hdr* udp = (struct rte_udp_hdr*)(ip + 1);
                rte_memcpy(gDstMac, eth->s_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
                rte_memcpy(&gSrcIp, &ip->dst_addr, sizeof(uint32_t));
                rte_memcpy(&gDstIp, &ip->src_addr, sizeof(uint32_t));
                rte_memcpy(&gSrcPort, &udp->dst_port, sizeof(uint16_t));
                rte_memcpy(&gDstPort, &udp->src_port, sizeof(uint16_t));
                uint16_t len = ntohs(udp->dgram_len);
                *((char*)udp + len) = '\0';
                struct in_addr addr;
                addr.s_addr = ip->src_addr;
                printf("udp-->src: %s:%d ", inet_ntoa(addr), ntohs(udp->src_port));
                addr.s_addr = ip->dst_addr;
                printf("dst: %s:%d %s\n", inet_ntoa(addr), udp->dst_port, (char*)(udp + 1));
                struct rte_mbuf* txbuf = dpdk_send_udp(mbuf_pool, (uint8_t*)(udp + 1), len);
                rte_eth_tx_burst(gDpdkPortId, 0, &txbuf, 1);
                rte_pktmbuf_free(txbuf);
                rte_pktmbuf_free(mbufs[i]);
                txbuf = NULL;
                mbufs[i] = NULL;
            }

            if(ip->next_proto_id == IPPROTO_ICMP) {
                struct rte_icmp_hdr* icmp = (struct rte_icmp_hdr*)(ip + 1);
                struct in_addr addr;
                addr.s_addr = ip->src_addr;
                printf("icmp-->src: %s ", inet_ntoa(addr));
                if(icmp->icmp_type == RTE_IP_ICMP_ECHO_REQUEST) {
                    addr.s_addr = ip->dst_addr;
                    printf("local:%s, type: %d\n", inet_ntoa(addr), icmp->icmp_type);
                    struct rte_mbuf* txbuf = dpdk_send_icmp(mbuf_pool, eth->s_addr.addr_bytes, 
                        ip->dst_addr, ip->src_addr, icmp->icmp_ident, icmp->icmp_seq_nb);
                    rte_eth_tx_burst(gDpdkPortId, 0, &txbuf, 1);
                    rte_pktmbuf_free(txbuf);
                    rte_pktmbuf_free(mbufs[i]);
                }
            }
        }
    }

    return 0;
}

文档

RFC参考文档

在参考文档中找到cksum相关的就可以了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1845116.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Linux字节对齐小程序

#include <stdio.h> // 默认对齐 struct DefaultAligned { char c; int i; }; // 按1字节对齐 #pragma pack(push, 1) struct OneByteAligned { char c; int i; }; #pragma pack(pop) // 恢复之前的对齐设置 int mai…

1964springboot VUE小程序在线学习管理系统开发mysql数据库uniapp开发java编程计算机网页源码maven项目

一、源码特点 springboot VUE uniapp 小程序 在线学习管理系统是一套完善的完整信息管理类型系统&#xff0c;结合springboot框架uniapp和VUE完成本系统&#xff0c;对理解vue java编程开发语言有帮助系统采用springboot框架&#xff08;MVC模式开发&#xff09;&#xff0c;…

Shiro721 反序列化漏洞(CVE-2019-12422)

目录 Shiro550和Shiro721的区别 判断是否存在漏洞 漏洞环境搭建 漏洞利用 利用Shiro检测工具 利用Shiro综综合利用工具 这一篇还是参考别的师傅的好文章学习Shiro的反序列化漏洞 上一篇也是Shiro的反序列化漏洞&#xff0c;不同的是一个是550一个是721&#xff0c;那么这…

《Windows API每日一练》5.2 按键消息

上一节中我们得知&#xff0c;Windows系统的按键消息有很多类型&#xff0c;大部分按键消息都是由Windows系统的默认窗口过程处理的&#xff0c;我们自己只需要处理少数几个按键消息。这一节我们将详细讲述Windows系统的所有按键消息及其处理方式。 本节必须掌握的知识点&…

厚膜电阻电路丝网印刷

厚膜丝网印刷 该技术用于需要长寿命、热耐久性、机械强度、导热性、高密度电气互连、低介电损耗等的苛刻应用 特征&#xff1a; 陶瓷标准工艺从前到后的通孔连接 正面和背面的丝网印刷电阻器是标准工艺 金导体可以用金线和/或氧化铝线进行线键合 可焊接金属化&#xff0c;…

《梦醒蝶飞:释放Excel函数与公式的力量》3.5常用数学函数max

3.5 MAX函数 教案主题&#xff1a;Excel中MAX函数的应用 一、定理定义 MAX函数是Excel中的一个内置函数&#xff0c;用于返回一组数值中的最大值。它可以应用于数据集&#xff0c;帮助用户快速识别最大数值&#xff0c;从而进行数据分析和决策。 二、语法结构 MAX函数的基…

国外开源字典集(wordlists)

Assetnote Wordlists Wordlists that are up to date and effective against the most popular technologies on the internet.https://wordlists.assetnote.io/

LInux驱动开发笔记(十)SPI子系统及其驱动

文章目录 前言一、SPI驱动框架二、总线驱动2.1 SPI总线的运行机制2.2 重要数据结构2.2.1 spi_controller2.2.2 spi_driver2.2.3 spi_device2.2.4 spi_transfer2.2.5 spi_message 三、设备驱动的编写3.1 设备树的修改3.2 相关API函数3.2.1 spi_setup( )3.2.2 spi_message_init( …

Docker定位具体占用大量存储的容器

监控告警生产环境的服务器磁盘分区使用率大于90%&#xff0c;进入服务器查看Docker 的 overlay2 存储驱动目录中占用很大&#xff0c;很可能是某个容器一直在打印日志&#xff0c;所以需要定位到是哪个容器&#xff0c;然后进行进一步排查。 然后进入到overlay2中查看是哪个目录…

Python日志管理利器:如何高效管理平台日志

一、为什么需要日志管理&#xff1f; 日志是应用程序的重要组成部分&#xff0c;它记录了应用程序的运行状态、错误信息以及用户交互等关键信息。良好的日志管理可以帮助开发人员及时发现和解决问题&#xff0c;提高应用程序的稳定性和可靠性。 项目在本地开发调试时&#xf…

第一百一十六节 Java 面向对象设计 - Java 终止块

Java 面向对象设计 - Java 终止块 ​try ​块也可以有零个或一个​ finally​ 块。 ​finally ​块总是与 ​try ​块一起使用。 语法 使用 ​finally​ 块的语法是 finally {// Code for finally block }​finally​ 块以关键字 ​finally​ 开始&#xff0c;后面紧跟一对…

qemu 安装ubuntu -纯命令行-可ssh-带网络-可gdb linux kernel

1&#xff0c;预备系统盘数据 1.1 下载光盘 注意需要 liver-server $ wget https://releases.ubuntu.com/22.04.4/ubuntu-22.04.4-live-server-amd64.iso 1.2 挂载并拷贝 $ sudo mkdir /mnt/iso_ubuntu-22.04.4-live-server-amd64 $ sudo mount ubuntu-22.04.4-live-ser…

Linux系统安装Dify结合内网穿透实现远程访问本地LLM开发平台

文章目录 前言1. Docker部署Dify2. 本地访问Dify3. Ubuntu安装Cpolar4. 配置公网地址5. 远程访问6. 固定Cpolar公网地址7. 固定地址访问 前言 本文主要介绍如何在Linux Ubuntu系统使用Docker快速部署大语言模型应用开发平台Dify,并结合cpolar内网穿透工具实现公网环境远程访问…

差分总结(一维+二维)

差分&#xff0c;可以视作前缀和的逆运算。 前缀和用于去求一个区间段的和 差分用于改变一个区间的值&#xff08;比如说某个区间都加上或者减去一个数&#xff09; P2367 语文成绩 #include<bits/stdc.h> using namespace std; #define int long long int n,p; int a…

问题解决:Problem exceeding maximum token in azure openai (with java)

问题背景&#xff1a; Im doing a chat that returns queries based on the question you ask it in reference to a specific database. For this I use azure openai and Java in Spring Boot. 我正在开发一个聊天功能&#xff0c;该功能根据您针对特定数据库的提问返回查询…

模型预测控制MPC详解(附带案例实现)

模型预测控制MPC详解&#xff08;附带案例实现&#xff09; 文章目录 模型预测控制MPC详解&#xff08;附带案例实现&#xff09;1. 最优控制问题2. 什么是MPC3. 二次规划Quadratic Programming4. MPC为什么可以转换成QP问题&#xff08;推导过程&#xff09;5. MPC总结5.1 MPC…

HTML静态网页成品作业(HTML+CSS+JS)——家乡莆田介绍网页(5个页面)

&#x1f389;不定期分享源码&#xff0c;关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码 五、源码获取 一、作品介绍 &#x1f3f7;️本套采用HTMLCSS&#xff0c;使用Javacsript代码实现图片轮播&#xff0c;共有5个页面。 二、作品…

卓越的 App UI 风格引领潮流

卓越的 App UI 风格引领潮流

QT基础 - 常见图表绘制

目录 零. 前言 一. 添加模块 折线图 三. 树状图 四. 饼图 五. 堆叠柱状图 六. 百分比柱状图 七. 散点图和光滑曲线图 散点图 光滑曲线图 零. 前言 Qt Charts 是 Qt 框架的一个模块&#xff0c;用于创建各种类型的图表和数据可视化。它为开发者提供了一套功能强大的工…

【面试干货】Java的基础类型和字节大小

【面试干货】Java的基础类型和字节大小 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 在Java编程语言中&#xff0c;有八种基本数据类型&#xff0c;它们分别是&#xff1a;布尔型&#xff08;boolean&#xff09;、字节型&#xff08;byt…