Framwork下个文件中包含的函数

packet.py

LayersTypes =
{
"L2": ['ether', 'vlan', 'etag', '', 'arp', 'lldp'],
# ipv4_ext_unknown, ipv6_ext_unknown
"L3": ['ipv4', 'ipv4ihl', 'ipv6', 'ipv4_ext', 'ipv6_ext', 'ipv6_ext2', 'ipv6_frag'],
"L4": ['tcp', 'udp', 'frag', 'sctp', 'icmp', 'nofrag'],
"TUNNEL": ['ip', 'gre', 'vxlan', 'nvgre', 'geneve', 'grenat'],
"INNER L2": ['inner_mac', 'inner_vlan'],
# inner_ipv4_unknown, inner_ipv6_unknown
"INNER L3": ['inner_ipv4', 'inner_ipv4_ext', 'inner_ipv6', 'inner_ipv6_ext'],
"INNER L4": ['inner_tcp', 'inner_udp', 'inner_frag', 'inner_sctp', 'inner_icmp', 'inner_nofrag'],
"PAYLOAD": ['raw']
}
# Saved back groud sniff process id
SNIFF_PIDS = {}
# Saved packet generator process id
# used in pktgen or tgen
PKTGEN_PIDS = {}
# default filter for LLDP packet
LLDP_FILTER = {'layer': 'ether', 'config': {'type': 'not lldp'}} class scapy
SCAPY_LAYERS =
'ether': Ether(dst="ff:ff:ff:ff:ff:ff"),
'vlan': Dot1Q(),
'etag': Dot1BR(),
00.__init__(self)
01.assign_pkt(self, pkt)
02.add_layers(self, layers)
03.ether(self, pkt_layer, dst="ff:ff:ff:ff:ff:ff", src="00:00:20:00:00:00", type=None)
04.vlan(self, pkt_layer, vlan, prio=0, type=None)
05.strip_vlan(self, element)
06.etag(self, pkt_layer, ECIDbase=0, prio=0, type=None)
07.strip_etag(self, element)
08.strip_layer2(self, element)
09.strip_layer3(self, element)
10.strip_layer4(self, element)
11.ipv4(self, pkt_layer, frag=0, src="127.0.0.1", proto=None, tos=0, dst="127.0.0.1", chksum=None, len=None, version=4, flags=None, ihl=None, ttl=64, id=1, options=None)
12.ipv6(self, pkt_layer, version=6, tc=0, fl=0, plen=0, nh=0, hlim=64, src="::1", dst="::1")
13.tcp(self, pkt_layer, src=53, dst=53, flags=None, len=None, chksum=None)
14.udp(self, pkt_layer, src=53, dst=53, len=None, chksum=None)
15.sctp(self, pkt_layer, src=53, dst=53, tag=None, len=None, chksum=None)
16.raw(self, pkt_layer, payload=None)
17.gre(self, pkt_layer, proto=None)
18.vxlan(self, pkt_layer, vni=0)
19.read_pcap(self, file)
20.write_pcap(self, file)
21.send_pcap_pkt(self, crb=None, file='', intf='', count=1)
22.print_summary(self)
23.send_pkt(self, intf='', count=1) class Packet
def_packet =
'TIMESYNC': {'layers': ['ether', 'raw'], 'cfgload': False},
'ARP': {'layers': ['ether', 'arp'], 'cfgload': False},
'LLDP': {'layers': ['ether', 'lldp'], 'cfgload': False},
00.__init__(self, **options)
01._load_assign_layers(self)
02.send_pkt(self, crb=None, tx_port='', auto_cfg=True, count=1)
03.check_layer_config(self, layer, config)
04.assign_layers(self, layers=None)
05._load_pkt_layers(self)
06.config_def_layers(self)
07.config_layer(self, layer, config={})
08.config_layers(self, layers=None)
09._config_layer_ether(self, pkt_layer, config):
10._config_layer_mac(self, pkt_layer, config):
11._config_layer_vlan(self, pkt_layer, config):
12._config_layer_etag(self, pkt_layer, config):
13._config_layer_ipv4(self, pkt_layer, config):
14._config_layer_ipv6(self, pkt_layer, config):
15._config_layer_udp(self, pkt_layer, config):
16._config_layer_tcp(self, pkt_layer, config):
17._config_layer_sctp(self, pkt_layer, config):
18._config_layer_gre(self, pkt_layer, config):
19._config_layer_raw(self, pkt_layer, config):
20._config_layer_vxlan(self, pkt_layer, config):
21.strip_layer_element(self, layer, element)
22.strip_element_layer2(self, element)
23.strip_element_layer3(self, element)
24.strip_element_vlan(self, element)
25.strip_element_etag(self, element)
26.strip_element_layer4(self, element) 31.IncreaseIP(addr)
32.IncreaseIPv6(addr)
33.send_packets(intf, pkts=None, interval=0.01)
34.save_packets(pkts=None, filename=None)
35.get_ether_type(eth_type="")
36.get_filter_cmd(filters=[])
37.sniff_packets(intf, count=0, timeout=5, filters=[])
38.load_sniff_pcap(index='')
39.load_sniff_packets(index='')
40.load_pcapfile(filename="")
41.compare_pktload(pkt1=None, pkt2=None, layer="L2")
42.strip_pktload(pkt=None, layer="L2")

pmd_out.py

"""
Module for get all statics value by port in testpmd
"""
pmd_output
01.__init__(self,dut)
02.get_pmd_value(self, prefix, out)
03.set_default_corelist(self)
04.get_pmd_stats(self, portid)
05.get_pmd_cmd(self)
06.start_testpmd(self, cores, param='', eal_param='', socket=0)
07.execute_cmd(self, pmd_cmd, expected='testpmd> ', timeout=TIMEOUT,
alt_session=False)
08.get_output(self, timeout=1)
09.get_value_from_string(self, key_str, regx_str, string)
10.get_detail_from_port_info(self, key_str, regx_str, port)
11.get_port_mac(self, port_id)
12.get_port_connect_socket(self, port_id)
13.get_port_memory_socket(self, port_id)
14.get_port_link_status(self, port_id)
15.get_port_link_speed(self, port_id)
16.get_port_link_duplex(self, port_id)
17.get_port_promiscuous_mode(self, port_id)
18.get_port_allmulticast_mode(self, port_id)
19.check_tx_bytes(self, tx_bytes, exp_bytes = 0)
20.get_port_vlan_offload(self, port_id)
21.quit(self)

ssh.py

'''
Module for create session to host.
Implement(执行) send_expect/copy function upper SSHPexpet module.
'''
class SSHConnection(object):
01.init_log(self, logger):
02.set_history(self, history):
03.send_expect(self, cmds, expected, timeout=15, verify=False):
04.send_command(self, cmds, timeout=1):
05.get_session_before(self, timeout=15):
06.close(self, force=False):
07.isalive(self):
08.check_available(self):
09.copy_file_from(self, src, dst=".", password=''):
10.copy_file_to(self, src, dst="~/", password=''):

pexpect.py

'''
Module handle ssh sessions between tester and DUT.
Implement send_expect function to send command and get output data.
Aslo support transfer files to tester or DUT
'''
class SSHPexpect(object):
@parallel_lock(num=8)
01._connect_host(self, dut_id=0):
02.init_log(self, logger, name):
03.send_expect_base(self, command, expected, timeout):
04.send_expect(self, command, expected, timeout=15, verify=False):
05.send_command(self, command, timeout=1):
06.clean_session(self):
07.get_session_before(self, timeout=15):
08.__flush(self):
09.__prompt(self, command, timeout):
10.__sendline(self, command):
11.get_output_before(self):
12.get_output_all(self):
13.close(self, force=False):
14.isalive(self):
15.copy_file_from(self, src, dst=".", password=''):
16.copy_file_to(self, src, dst="~/", password=''):
17._spawn_scp(self, scp_cmd, password):

dts--framework(二)的更多相关文章

  1. Django Rest Framework(二)

    •基于Django 先创建一个django项目,在项目中创建一些表,用来测试rest framework的各种组件 models.py class UserInfo(models.Model): &q ...

  2. Entity Framework二、 模型优先 ,ObjectContext类

    https://www.cnblogs.com/ejiyuan/archive/2009/05/27/1490786.html 1.ObjectContext 封装.NET Framework和数据库 ...

  3. C# Winform 脱离 Framework (二)

    第一个Method: //启动应用程序 VOID RunApplication(LPTSTR lpFilename, LPTSTR args) { //WinExec(lpFilename, SW_S ...

  4. Play framework(二)

    Play 2.0 的完整演示过程记录 http://www.oschina.net/translate/playframework-20-live-coding-script todolist代码

  5. Entity Framework (二) 查询

    待完善-------------------------------------- ----------- base 关键字用于从派生类中访问基类的成员: 调用基类上已被其他方法重写的方法. 指定创建 ...

  6. 框架应用:Spring framework (二) - AOP技术

    基础概念 线程中的方法栈 java程序虚拟机启动时会载入程序码,虚拟机会为每一条正在运行的线程生成一个方法调用栈,线程以方法运行为执行单位. AOP概念以及目标 AOP是面向切面编程,其实就是在不修改 ...

  7. Entity Framework 二

    本篇主要介绍:创建了实体数据模型,生成了那些文件以及其代表意义 创建实体数据模型 上一篇的最后,我们创建了数据库,现在我们利用数据库来生成我们的实体数据模型,这种形式我们称为数据库优先,后面会介绍代码 ...

  8. entity framework 新手入门篇(1)-建立模型

    entity framework是微软官方免费提供给大家的一套ORM(Object Relational Mapping对象关系映射)解决方案.它不仅可以帮助我们解决数据缓存的问题,还能在最小的开销下 ...

  9. 使用iOS-QR-Code-Encoder 生成二维码

    一:所需类库 iOS-QR-Code-Encoder 官网主页:https://github.com/moqod/iOS-QR-Code-Encoder 导入:QuartzCore.framework ...

  10. 制作通用framework的几点注意

    一.创建framework,调成静态的framework . 二.匹配bitcode 三.增加-ObjC 在BuildSettting ->Linking->Other Linker Fl ...

随机推荐

  1. 移动Web开发与适配笔记

    项目要是适配手机端,想透彻的把相关内容弄清楚,现在总结一下. 一.移动端开发有如下特点: 1.跑在手机端的web 页面就是h5页面 2.具有跨平台性(web 安卓 iOS都适应) 3.基于webvie ...

  2. c# 使用泛型序列化

    static void Serialize<T>(T instance , string fileName) { using(XmlWriter writer = new XmlWrite ...

  3. idea安装激活

    安装激活链接: https://blog.csdn.net/newabcc/article/details/80601933 激活出错链接:(key is invalid 失效) https://bl ...

  4. Swift-取消传统For循环

    1.取消传统的For循环 传统的for,在swift 3.0 被取消 i++/++i在swift 3.0 被取消 i += 1代替 for var i = 0;i<10;i +=1 { } 2. ...

  5. 基于vue-cli 将webpack3 升级到 webpack4 配置

       升级webpack4前 先删除之前的webpack, babel-loader  下载 webpack npm i -D webpack@4 webpack-cli@3 webpack-dev- ...

  6. FAT12格式的引导区实现

    org 07c00h ;================================================ jmp short START nop ; 这个 nop 不可少 ;这个结构将 ...

  7. [MedicalEndoscope]PFC介绍

    PFC的英文全称为“Power Factor Correction”,意思是“功率因数校正”,功率因数指的是有效功率与总耗电量(视在功率)之间的关系,也就是有效功率除以总耗电量(视在功率)的比值. 基 ...

  8. Cookie和Session 简单介绍

    cookie :     1.cookie是存在客户端(浏览器)的进程内存中和客户端所在的机器硬盘上     2.cookie只能能够存储少量文本,大概4K大小     3.cookie是不能在不同浏 ...

  9. Osclass-3.6.1 (Openlogic CentOS 7.2)

    平台: CentOS 类型: 虚拟机镜像 软件包: osclass3.6.1 cms commercial content management ecommerce open-source 服务优惠价 ...

  10. ARM实验5 —— 按键中断实验

    key_int按键中断实验 实验内容: 通过开发板上的按键中断控制led灯进行跑马灯并打印信息. 通过简单事例说明猎户座4412处理器的GIC中断处理的应用,设置key2按键连接的引脚为中断模式,当识 ...