IP Protocol Number

本文详细介绍了IPv4和IPv6中用于标识上层协议的字段,列举了常见的协议及其对应的协议号,包括TCP、UDP、ICMP等,并提供了完整的协议号列表。

In the Internet Protocol version 4 (IPv4) [RFC791] there is a field, called "Protocol", to identify the next level protocol. This is an 8 bit field. In Internet Protocol version 6 (IPv6) [RFC1883] this field is called the "Next Header" field.

作为Common Sense,首先应知道几个常用协议的protocol num:

ICMP:1

TCP:6

UDP:17

OSPF:89

IPinIP:4

GRE:47

RSVP/RSVP-TE:46

 

其他的完整列表为:

Assigned Internet Protocol Numbers

Decimal    Keyword     Protocol                         References
-------    -------     --------                         ----------
     0     HOPOPT      IPv6 Hop-by-Hop Option            [RFC1883]
     1     ICMP        Internet Control Message           [RFC792]
     2     IGMP        Internet Group Management         [RFC1112]
     3     GGP         Gateway-to-Gateway                 [RFC823]
     4     IP          IP in IP (encapsulation)          [RFC2003]
     5     ST          Stream                    [RFC1190,RFC1819]
     6     TCP         Transmission Control               [RFC793]
     7     CBT         CBT                             [Ballardie]
     8     EGP         Exterior Gateway Protocol     [RFC888,DLM1]
     9     IGP         any private interior gateway         [IANA]
                       (used by Cisco for their IGRP)
    10     BBN-RCC-MON BBN RCC Monitoring                    [SGC]
    11     NVP-II      Network Voice Protocol         [RFC741,SC3]
    12     PUP         PUP                             [PUP,XEROX]
    13     ARGUS       ARGUS                                [RWS4]
    14     EMCON       EMCON                                 [BN7]
    15     XNET        Cross Net Debugger            [IEN158,JFH2]
    16     CHAOS       Chaos                                 [NC3]
    17     UDP         User Datagram                  [RFC768,JBP]
    18     MUX         Multiplexing                    [IEN90,JBP]
    19     DCN-MEAS    DCN Measurement Subsystems           [DLM1]
    20     HMP         Host Monitoring                [RFC869,RH6]
    21     PRM         Packet Radio Measurement              [ZSU]
    22     XNS-IDP     XEROX NS IDP               [ETHERNET,XEROX]
    23     TRUNK-1     Trunk-1                              [BWB6]
    24     TRUNK-2     Trunk-2                              [BWB6]
    25     LEAF-1      Leaf-1                               [BWB6]
    26     LEAF-2      Leaf-2                               [BWB6]
    27     RDP         Reliable Data Protocol         [RFC908,RH6]
    28     IRTP        Internet Reliable Transaction  [RFC938,TXM]
    29     ISO-TP4     ISO Transport Protocol Class 4 [RFC905,RC77]
    30     NETBLT      Bulk Data Transfer Protocol    [RFC969,DDC1]
    31     MFE-NSP     MFE Network Services Protocol  [MFENET,BCH2]
    32     MERIT-INP   MERIT Internodal Protocol             [HWB]
    33     DCCP        Datagram Congestion Control Protocol  [RFC-ietf-dccp-spec-11.txt]
    34     3PC         Third Party Connect Protocol         [SAF3]
    35     IDPR        Inter-Domain Policy Routing Protocol [MXS1]
    36     XTP         XTP                                   [GXC]
    37     DDP         Datagram Delivery Protocol            [WXC]
    38     IDPR-CMTP   IDPR Control Message Transport Proto [MXS1]
    39     TP++        TP++ Transport Protocol               [DXF]
    40     IL          IL Transport Protocol            [Presotto]
    41     IPv6        Ipv6                              [Deering]   
    42     SDRP        Source Demand Routing Protocol       [DXE1]
    43     IPv6-Route  Routing Header for IPv6           [Deering]
    44     IPv6-Frag   Fragment Header for IPv6          [Deering]
    45     IDRP        Inter-Domain Routing Protocol   [Sue Hares]
    46     RSVP        Reservation Protocol           [Bob Braden]
    47     GRE         General Routing Encapsulation     [Tony Li]
    48     MHRP        Mobile Host Routing Protocol[David Johnson]
    49     BNA         BNA                          [Gary Salamon]
    50     ESP         Encap Security Payload            [RFC2406]
    51     AH          Authentication Header             [RFC2402]
    52     I-NLSP      Integrated Net Layer Security  TUBA [GLENN]
    53     SWIPE       IP with Encryption                    [JI6]
    54     NARP        NBMA Address Resolution Protocol  [RFC1735]
    55     MOBILE      IP Mobility                       [Perkins]
    56     TLSP        Transport Layer Security Protocol   [Oberg]
                       using Kryptonet key management
    57     SKIP        SKIP                              [Markson]
    58     IPv6-ICMP   ICMP for IPv6                     [RFC1883]
    59     IPv6-NoNxt  No Next Header for IPv6           [RFC1883]
    60     IPv6-Opts   Destination Options for IPv6      [RFC1883]
    61                 any host internal protocol           [IANA]
    62     CFTP        CFTP                            [CFTP,HCF2]
    63                 any local network                    [IANA]
    64     SAT-EXPAK   SATNET and Backroom EXPAK             [SHB]
    65     KRYPTOLAN   Kryptolan                            [PXL1]
    66     RVD         MIT Remote Virtual Disk Protocol      [MBG]
    67     IPPC        Internet Pluribus Packet Core         [SHB]
    68                 any distributed file system          [IANA]
    69     SAT-MON     SATNET Monitoring                     [SHB]
    70     VISA        VISA Protocol                        [GXT1]
    71     IPCV        Internet Packet Core Utility          [SHB]
    72     CPNX        Computer Protocol Network Executive  [DXM2]
    73     CPHB        Computer Protocol Heart Beat         [DXM2]
    74     WSN         Wang Span Network                     [VXD]
    75     PVP         Packet Video Protocol                 [SC3]
    76     BR-SAT-MON  Backroom SATNET Monitoring            [SHB]
    77     SUN-ND      SUN ND PROTOCOL-Temporary             [WM3]
    78     WB-MON      WIDEBAND Monitoring                   [SHB]
    79     WB-EXPAK    WIDEBAND EXPAK                        [SHB]
    80     ISO-IP      ISO Internet Protocol                 [MTR]
    81     VMTP        VMTP                                 [DRC3]
    82     SECURE-VMTP SECURE-VMTP                          [DRC3]
    83     VINES       VINES                                 [BXH]
    84     TTP         TTP                                   [JXS]
    85     NSFNET-IGP  NSFNET-IGP                            [HWB]
    86     DGP         Dissimilar Gateway Protocol     [DGP,ML109]
    87     TCF         TCF                                  [GAL5]
    88     EIGRP       EIGRP                           [CISCO,GXS]
    89     OSPFIGP     OSPFIGP                      [RFC1583,JTM4]
    90     Sprite-RPC  Sprite RPC Protocol            [SPRITE,BXW]
    91     LARP        Locus Address Resolution Protocol     [BXH]
    92     MTP         Multicast Transport Protocol          [SXA]
    93     AX.25       AX.25 Frames                         [BK29]        
    94     IPIP        IP-within-IP Encapsulation Protocol   [JI6]
    95     MICP        Mobile Internetworking Control Pro.   [JI6]
    96     SCC-SP      Semaphore Communications Sec. Pro.    [HXH]    
    97     ETHERIP     Ethernet-within-IP Encapsulation  [RFC3378]
    98     ENCAP       Encapsulation Header         [RFC1241,RXB3]
    99                 any private encryption scheme        [IANA]
   100     GMTP        GMTP                                 [RXB5]
   101     IFMP        Ipsilon Flow Management Protocol   [Hinden]
   102     PNNI        PNNI over IP                       [Callon]
   103     PIM         Protocol Independent Multicast  [Farinacci]
   104     ARIS        ARIS                              [Feldman]
   105     SCPS        SCPS                                [Durst]
   106    QNX        QNX                                [Hunter]
   107    A/N        Active Networks                    [Braden]
   108    IPComp      IP Payload Compression Protocol   [RFC2393]
   109    SNP        Sitara Networks Protocol          [Sridhar]
   110    Compaq-Peer Compaq Peer Protocol                [Volpe]
   111    IPX-in-IP   IPX in IP                             [Lee]
   112     VRRP       Virtual Router Redundancy Protocol [RFC3768]
   113     PGM         PGM Reliable Transport Protocol  [Speakman]
   114                 any 0-hop protocol                   [IANA]
   115    L2TP        Layer Two Tunneling Protocol        [Aboba]
   116     DDX        D-II Data Exchange (DDX)           [Worley]
   117    IATP      Interactive Agent Transfer Protocol  [Murphy]
   118     STP         Schedule Transfer Protocol            [JMP]
   119     SRP        SpectraLink Radio Protocol       [Hamilton]
   120     UTI      UTI                                 [Lothberg]
   121     SMP      Simple Message Protocol               [Ekblad]
   122    SM       SM                                 [Crowcroft]
   123    PTP      Performance Transparency Protocol      [Welzl]
   124     ISIS over IPv4                             [Przygienda]
   125     FIRE                                        [Partridge]
   126    CRTP     Combat Radio Transport Protocol      [Sautter]
   127    CRUDP    Combat Radio User Datagram           [Sautter]
   128     SSCOPMCE                                        [Waber]
   129     IPLT                                         [Hollbach]
   130     SPS    Secure Packet Shield                  [McIntosh]
   131     PIPE   Private IP Encapsulation within IP       [Petri]
   132     SCTP   Stream Control Transmission Protocol   [Stewart]
   133     FC     Fibre Channel                        [Rajagopal]
   134     RSVP-E2E-IGNORE                               [RFC3175]
   135     Mobility Header                               [RFC3775]
   136     UDPLite                                       [RFC3828]
   137     MPLS-in-IP                                    [RFC4023]
   138-252 Unassigned                                       [IANA]
   253     Use for experimentation and testing           [RFC3692]
   254     Use for experimentation and testing           [RFC3692]
   255                 Reserved                             [IANA]

/* * Per-connection data structure. */ struct sfe_ipv4_connection { struct sfe_ipv4_connection *next; /* Pointer to the next entry in a hash chain */ struct sfe_ipv4_connection *prev; /* Pointer to the previous entry in a hash chain */ int protocol; /* IP protocol number */ __be32 src_ip; /* Source IP address */ __be32 src_ip_xlate; /* NAT-translated source IP address */ __be32 dest_ip; /* Destination IP address */ __be32 dest_ip_xlate; /* NAT-translated destination IP address */ __be16 src_port; /* Source port */ __be16 src_port_xlate; /* NAT-translated source port */ __be16 dest_port; /* Destination port */ __be16 dest_port_xlate; /* NAT-translated destination port */ struct sfe_ipv4_connection_match *original_match; /* Original direction matching structure */ struct net_device *original_dev; /* Original direction source device */ struct sfe_ipv4_connection_match *reply_match; /* Reply direction matching structure */ struct net_device *reply_dev; /* Reply direction source device */ uint64_t last_sync_jiffies; /* Jiffies count for the last sync */ struct sfe_ipv4_connection *all_connections_next; /* Pointer to the next entry in the list of all connections */ struct sfe_ipv4_connection *all_connections_prev; /* Pointer to the previous entry in the list of all connections */ uint32_t mark; /* mark for outgoing packet */ #if defined(CONFIG_NF_CONNTRACK_EXTMARK) uint32_t extmark; /* extmark for outgoing packet */ #endif uint32_t debug_read_seq; /* sequence number for debug dump */ struct nf_conntrack *nfct; #ifdef TPLINK_FRAGMENT_OUTPUT struct dst_entry *dst; struct dst_entry *reply_dst; #endif int sfe_proto; unsigned long slowpath_jiffies; /* sfe heartbeat timer for HWNAT. */ };解释每个变量的含义
最新发布
01-07
这是一个用于管理 IPv4 连接的结构体 `struct sfe_ipv4_connection`,常用于 Linux 内核中的网络加速模块(如 SFE - Shortcut Forwarding Engine),用于高效转发和管理网络连接。下面是对结构体中每个字段的详细解释和注释: --- ### 1. **连接链表管理** ```c struct sfe_ipv4_connection *next; struct sfe_ipv4_connection *prev; ``` - **含义**:用于将该连接插入到哈希链表中。 - **用途**:便于根据五元组快速查找连接。 ```c struct sfe_ipv4_connection *all_connections_next; struct sfe_ipv4_connection *all_connections_prev; ``` - **含义**:用于将该连接插入到全局连接链表中。 - **用途**:系统可以遍历所有当前存在的连接。 --- ### 2. **连接基本信息** ```c int protocol; ``` - **含义**:IP 协议号(如 IPPROTO_TCP=6,IPPROTO_UDP=17)。 - **用途**:标识该连接使用的传输层协议。 ```c __be32 src_ip; __be32 dest_ip; ``` - **含义**:源 IP 和目的 IP 地址(大端格式)。 - **用途**:标识连接的两端 IP。 ```c __be32 src_ip_xlate; __be32 dest_ip_xlate; ``` - **含义**:经过 NAT 转换后的源和目的 IP 地址。 - **用途**:实现地址转换(SNAT/DNAT)。 ```c __be16 src_port; __be16 dest_port; ``` - **含义**:源端口和目的端口(大端格式)。 - **用途**:标识连接的端口号。 ```c __be16 src_port_xlate; __be16 dest_port_xlate; ``` - **含义**:经过 NAT 转换后的源和目的端口号。 - **用途**:实现端口转换(如 PAT)。 --- ### 3. **连接方向匹配信息** ```c struct sfe_ipv4_connection_match *original_match; struct sfe_ipv4_connection_match *reply_match; ``` - **含义**:分别指向原始方向和回复方向的匹配结构体。 - **用途**:用于双向连接的数据流匹配和加速。 ```c struct net_device *original_dev; struct net_device *reply_dev; ``` - **含义**:原始方向和回复方向的数据包来源网络设备。 - **用途**:记录连接的入方向设备,用于转发决策。 --- ### 4. **时间戳与同步** ```c uint64_t last_sync_jiffies; ``` - **含义**:记录上一次同步的时间戳(基于 jiffies)。 - **用途**:用于连接状态同步和老化处理。 ```c unsigned long slowpath_jiffies; ``` - **含义**:记录硬件加速失效后的心跳时间戳。 - **用途**:用于检测连接是否需要重新加速。 --- ### 5. **标记(mark)与扩展标记(extmark)** ```c uint32_t mark; ``` - **含义**:用于标记数据包,常用于策略路由或 QoS。 - **用途**:实现流量分类和策略控制。 ```c #if defined(CONFIG_NF_CONNTRACK_EXTMARK) uint32_t extmark; #endif ``` - **含义**:扩展标记字段。 - **用途**:提供更灵活的数据包标记机制。 --- ### 6. **调试信息** ```c uint32_t debug_read_seq; ``` - **含义**:调试用的序列号。 - **用途**:在调试或 dump 连接信息时用于排序。 ```c struct nf_conntrack *nfct; ``` - **含义**:指向 Netfilter 的连接跟踪结构体。 - **用途**:与 Netfilter 子系统集成,实现连接状态跟踪。 --- ### 7. **分片与转发路径** ```c #ifdef TPLINK_FRAGMENT_OUTPUT struct dst_entry *dst; struct dst_entry *reply_dst; #endif ``` - **含义**:正向和反向的路由缓存(dst_entry)。 - **用途**:用于分片数据包的转发路径选择。 --- ### 8. **协议扩展字段** ```c int sfe_proto; ``` - **含义**:SFE 协议类型标识。 - **用途**:用于区分不同的加速协议(如 IPv4、IPv6、GRE 等)。 --- ### 总结 `struct sfe_ipv4_connection` 是一个用于描述网络连接的核心结构体,它不仅保存了连接的五元组信息(源 IP、目的 IP、协议、源端口、目的端口),还支持: - NAT 地址和端口转换 - 双向连接匹配 - 流量标记与 QoS - 与 Netfilter 的集成 - 硬件加速控制 - 数据包转发路径管理 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值