P4语言——qos

使用P4实现IP网络的区别服务QoS
本教程介绍了如何通过P4编程扩展基本的L3转发,实现基于Diffserv的QoS策略。拓扑包括多个主机和交换机,P4程序处理IP包头,设置不同服务类别的Diffserv字段,以实现不同优先级的流量管理。此外,还提供了发送UDP和TCP数据包的Python脚本,用于测试QoS配置。

练习:qos

本教程的目的是扩展基本的L3转发 ,使用区别服务实现服务质量(QOS)。 Diffserv简单且可扩展。 它对网络流量进行分类和管理,并在现代IP网络上提供QOS。
在这里插入图片描述

拓扑图代码

{
   
   
    "hosts": {
   
   
        "h1": {
   
   "ip": "10.0.1.1/31", "mac": "08:00:00:00:01:01",
               "commands":["route add default gw 10.0.1.0 dev eth0",
                           "arp -i eth0 -s 10.0.1.0 08:00:00:00:01:00"]},
        "h11": {
   
   "ip": "10.0.1.11/31", "mac": "08:00:00:00:01:11",
                "commands":["route add default gw 10.0.1.10 dev eth0",
                            "arp -i eth0 -s 10.0.1.10 08:00:00:00:01:00"]},
        "h2": {
   
   "ip": "10.0.2.2/31", "mac": "08:00:00:00:02:02",
               "commands":["route add default gw 10.0.2.3 dev eth0",
                           "arp -i eth0 -s 10.0.2.3 08:00:00:00:02:00"]},
        "h22": {
   
   "ip": "10.0.2.22/31", "mac": "08:00:00:00:02:22",
                "commands":["route add default gw 10.0.2.23 dev eth0",
                            "arp -i eth0 -s 10.0.2.23 08:00:00:00:02:00"]},
        "h3": {
   
   "ip": "10.0.3.3/31", "mac": "08:00:00:00:03:03",
               "commands":["route add default gw 10.0.3.2 dev eth0",
                           "arp -i eth0 -s 10.0.3.2 08:00:00:00:03:00"]}
    },
    "switches": {
   
   
        "s1": {
   
    "runtime_json" : "s1-runtime.json" },
        "s2": {
   
    "runtime_json" : "s2-runtime.json" },
        "s3": {
   
    "runtime_json" : "s3-runtime.json" }
    },
    "links": [
        ["h1", "s1-p2"], ["h11", "s1-p1"], ["s1-p3", "s2-p3"], ["s1-p4", "s3-p2"],
        ["s3-p3", "s2-p4"], ["h2", "s2-p2"], ["h22", "s2-p1"], ["h3", "s3-p1"]
    ]
}

P4文件代码

/* -*- P4_16 -*- */
#include <core.p4>
#include <v1model.p4>

const bit<16> TYPE_IPV4 = 0x800;

/* IP protocols */
const bit<8> IP_PROTOCOLS_ICMP       =   1;
const bit<8> IP_PROTOCOLS_IGMP       =   2;
const bit<8> IP_PROTOCOLS_IPV4       =   4;
const bit<8> IP_PROTOCOLS_TCP        =   6;
const bit<8> IP_PROTOCOLS_UDP        =  17;
const bit<8> IP_PROTOCOLS_IPV6       =  41;
const bit<8> IP_PROTOCOLS_GRE        =  47;
const bit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值