云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 中科大高级计算机网络实验报告

中科大高级计算机网络实验报告

  • 62 次阅读
  • 3 次下载
  • 2025/5/24 22:37:01

防火墙实验报告

一.实验过程

1. 编写Python源代码,命名为pyretic_firewall.py。 保存在

~/pyretic/pyretic/examples中。

2. 编写firewall-policies.csv源文件。保存在~/pyretic/pyretic/examples中。 3. 在虚拟机mininet仿真器中创建网络拓扑。 4. 在宿主机中连接虚拟机,运行程序。 5. 运用tcpdump测试实验结果。

二.pyretic_firewall.py源代码及重要代码解释 from pyretic.lib.corelib import * from pyretic.lib.std import * #以上代码引用库函数

# insert the name of the module and policy you want to import from pyretic.examples.pyretic_switch import act_like_switch import os import csv

from csv import DictReader #以上代码引用自己所需的一些模块

policy_file = \os.environ[ 'HOME']

#以上代码为指定引用的文件的路径 #以下代码为main函数 def main():

# start with a policy that doesn't match any packets # 初始化not_allowed变量 not_allowed = none

# and sdd traffic that isn't allowed

# read the firewall-policies.csv #打开.csv文件并读取文件内容 with open(policy_file, \ dictreader = DictReader(csvfile)

#如果d在dictreader中,则添加到not_allowed 中 for d in dictreader:

#对不允许的路由进行匹配

not_allowed = not_allowed +

(match(srcmac=MAC(d['mac_0']))&match(dstmac=MAC(d['mac_1']))) + (match(srcmac=MAC(d['mac_1']))&match(dstmac=MAC(d['mac_0']))) #express allowed traffic in terms of not_allowed - hint use'~' #将不允许的路由取反即为允许路由 allowed = ~not_allowed

# and only send allowed traffic to the mac learning (act_like_switch) logic # 将允许的路由作为pyretic_switch中act_like_switch()的输入 return allowed>>act_like_switch() 三.firewall-policies.csv 文件内容:

四.运行结果截图及结果解释

(1)在虚拟机中运行程序,结果如下所示:

(2)打开Xming,利用Putty远程登录虚拟机:

登录后结果:

(3)创建含有6台Host的网络拓扑,命令及运行结果如下图:

(4)打开6台Host的xterm,结果如图:

(5)在终端4,5,6的xterm中,运行tcpdump:

(6)测试实验结果

① 用h1 ping h4 ,测试结果下图所示,h1 ping h4 失败,说明设置的防火墙生效。

搜索更多关于: 中科大高级计算机网络实验报告 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

防火墙实验报告 一.实验过程 1. 编写Python源代码,命名为pyretic_firewall.py。 保存在~/pyretic/pyretic/examples中。 2. 编写firewall-policies.csv源文件。保存在~/pyretic/pyretic/examples中。 3. 在虚拟机mininet仿真器中创建网络拓扑。 4. 在宿主机中连接虚拟机,运行程序。 5. 运用tcpdump测试实验结果。 二.pyretic_firewall.py源代码及重要代码解释 from pyretic.lib.corelib import * from pyretic.lib.std import * #以上代码引用库函数 # insert the name of the module an

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com