数据的加密与一致性保持.docVIP

  • 14
  • 0
  • 约 5页
  • 2016-10-07 发布于重庆
  • 举报
数据的加密与一致性保持

数据的加密和一致性保持 1.实验原理: 加密是以某种特殊的算法改变原有的信息数据,使得未授权的用户即使获得了已加密的信息,但因不知解密的方法,仍然无法了解信息的内容。加密技术是最常用的安全保密手段,利用技术手段把重要的数据变为乱码(加密)传送,到达目的地后再用相同或不同的手段还原(解密)。加密技术包括两个元素:算法和密钥。算法是将普通的信息或者可以理解的信息与一串数字(密钥) 结合,产生不可理解的密文的步骤,密钥是用来对数据进行编码和解密的一种算法。在安全保密中,可通过适当的钥加密技术和管理机制来保证网络的信息通信安全。 发送者在发送数据前要对数据进行加密(我们可以不用去管具体加密方法),然后取hash值,将加密的数据和hash值传个接受者,接受者使用事先约定好的密钥进行解密。 4.实验步骤 将放入到apps文件夹下。 修改makefile,在OBJ_CC下面加入apps/Security_packet.o 在common/packet.h文件中的packet_t中适当位置(最后倒数第二)加入PT_SECURITY_PACKET;在class p_info中加入name_[PT_SECURITY_PACKET] = security_packet; 在NS_HOME目录下执行make命令重新编译。 5.实验代码 #Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open a trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a finish procedure proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam exit 0 } #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 5Mb 10ms DropTail $ns duplex-link $n1 $n2 5Mb 10ms DropTail $ns duplex-link $n2 $n3 1.5Mb 10ms DropTail $ns duplex-link $n3 $n4 5Mb 10ms DropTail $ns duplex-link $n3 $n5 5Mb 10ms DropTail #Set Queue Size of link (n2-n3) to 100 $ns queue-limit $n2 $n3 100 $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n3 $n4 orient right-up $ns duplex-link-op $n3 $n5 orient right-down #Define a recv function for the class Agent/Security_packet Agent/Security_packet instproc recv {from rtt mess originmess hash} { $self instvar node_ puts node [$node_ id] received packet from \ $from with trip-time $rtt ms - contend: $mess - decrypted $originmess -hash: $hash } #使用新的协议的方法使用attach-agent来关联。 #Create two ping agents and attach them to the nodes n0 and n2 set p0

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档