基于嵌入式平台的Linux虚拟网关及隧道程序设计

 2022-02-21 07:02

论文总字数:23756字

摘 要

互联网是当今社会人们沟通的桥梁,为了这个桥梁上的通讯更加高效、安全、便利,虚拟专用网络(VPN)已经开始被越来越广泛地使用,移动终端的漫游技术也随之迅速发展。当设备无线接入互联网时,在终端迅速移动时仍然需保持通信连续,实现不同跨越不同网段之间的漫游。这一功能实现的核心是隧道技术,当移动节点的地址发生改变时,它将数据包通过隧道发送给与它正在通信的结点,以此告知对方自己当前的地址。隧道技术就是用一种协议来封装另一种协议,程序实现就是将IP数据包封装在socket来传输,同时加上一个路由报头,使得数据能通过一般路由过程发送到目的地。

本课题的主要任务是实现一个虚拟网关,并将终端发来的IP业务数据利用隧道方式转发至远端。在接收到的数据包中,首先过滤IP广播数据及IP目的地址是虚拟网关的包后,根据系统解析得到的远端网关地址,通过UDP封装进行转交,同时对来自远端的隧道数据解封装后发送给终端。对于不同的目的IP,远端网关地址可能不同,该地址的获得通过查找映射表获得。

本文在对课题背景,项目意义做了简要分析之后,归纳了课题中所要涉及到的储备知识。其中先对隧道原理和各种隧道协议做了介绍,再逐一地阐述了,套接字函数的使用方法,截取与过滤数据包软件libpcap的接口函数,最后对实现隧道技术的方法进行了实践,通过测试验证了方案的可实行性。

关键词:隧道,封装,VPN,网关,过滤

Linux virtual gateway and tunnel design based on embedded platform

Abstract

Nowadays, the Internet becomes the bridge of communication among people. In order to make the information transmission on this bridge safer and more convenience, virtual private network(VPN) has been widely used nowadays. With the development of the internet, people also raise expectation on terminal roaming. Tunneling technology, as the key technology of terminal roaming, is to keep communication smoothly when the mobile terminals are moving. For example, when the ip address of terminals changed, they would send a data packet to other communication nodes through the tunnel, so that they could get the current address of mobile terminal. Tunneling technology, as the core technology of VPN, is to use a tunneling protocol to encapsulate another protocol. During coding, we just put the IP packet into socket buffer, and add a routing information in its head, so that the data could reach the destination by checking the routing table.

This project intends to realize a virtual gateway, and forward the IP packet from terminal client to terminal sever by using tunneling technology. Among the packet we have received, we should filter the IP broadcast and the packet whose destination IP belong to virtual gateway. According to the result of system analysis, we get the address of gateway, and forward IP packet by UDP protocol. Meanwhile, terminal sends the data to the end of tunnel. Since the different IP address matches the different MAC address, we should create the mapping table for them.

Paper introduces knowledge relates to the background and significance of the project. We demonstrate the tunneling principle and tunneling protocol, then demonstrate the socket, and API of libpcap. At last, design the test program to make sure the tunneling works well.

Key Words:tunnel technology, encapsulation, VPN, gateway, filter

目录

第一章 绪论 5

1.1 引言 5

1.2 课题背景 5

1.3课题目的和内容 6

第二章 隧道技术 7

2.1 隧道原理 7

2.2 VPN与IP隧道 8

2.3 Socket在隧道中的应用 8

2.4 截包与过滤技术 10

第三章 虚拟网关及隧道设计方案分析 11

3.1具体方案 11

3.2 虚拟网关的搭建 11

3.3 截包与过滤方案 12

3.4 隧道的封装与解封 13

第四章 隧道设计方案测试 15

4.1 测试模型的构造 15

4.2处理模块的实现 16

4.2.2 截包和过滤 17

4.2.3 隧道的封装与解封 19

4.2.4 从网关回发的数据处理 21

4.2.5 ARP请求和响应 22

4.3 测试与结论分析 24

4.3.1数据的发送与接收 24

第五章 结论与展望 28

参考文献 29

绪论

引言

信息化时代的当今,网络和数字技术飞速地发展,我们更擅长去挖掘新的信息以及新的技术应用。嵌入式系统作为一项重要的计算机技术,也悄然进入了我们的生活,比如我们使用的移动电话,工业设备等均属于嵌入式系统。

Linux是一个有利于网络开发者的操作系统,为研究者学习网络协议,了解网络架构以及进行一系列的测试仿真提供了极佳的平台。Linux是开源的系统,其中的TCP/IP协议的代码可以被开发者查看。在熟知TCP/IP的协议实现及基本原理后,对实现虚拟网关和隧道设计有极大的帮助。

剩余内容已隐藏,请支付后下载全文,论文总字数:23756字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;