资源简介
计算机网络-自顶向下方法第七版配套资源(包括ppt,课后答案,勘误,wireshark实验等)
代码片段和文件信息
from socket import *
import os
import sys
import struct
import time
import select
import binascii
ICMP_ECHO_REQUEST = 8
def checksum(string):
csum = 0
countTo = (len(string) // 2) * 2
count = 0
while count < countTo:
thisVal = ord(string[count+1]) * 256 + ord(string[count])
csum = csum + thisVal
csum = csum & 0xffffffff
count = count + 2
if countTo < len(string):
csum = csum + ord(string[len(string) - 1])
csum = csum & 0xffffffff
csum = (csum >> 16) + (csum & 0xffff)
csum = csum + (csum >> 16)
answer = ~csum
answer = answer & 0xffff
answer = answer >> 8 | (answer << 8 & 0xff00)
return answer
def receiveOnePing(mySocket ID timeout destAddr):
timeLeft = timeout
while 1:
startedSelect = time.time()
whatReady = select.select([mySocket] [] [] timeLeft)
howLongInSelect = (time.time() - startedSelect)
if whatReady[0] == []: # Timeout
return “Request timed out.“
timeReceived = time.time()
recPacket addr = mySocket.recvfrom(1024)
# Fetch the ICMPHeader from the IP
icmpHeader = recPacket[20:28]
rawTTL = struct.unpack(“s“ bytes([recPacket[8]]))[0]
# binascii -- Convert between binary and ASCII
TTL = int(binascii.hexlify(rawTTL) 16)
icmpType code checksum packetID sequence = struct.unpack(“bbHHh“ icmpHeader)
if packetID == ID:
byte = struct.calcsize(“d“)
timeSent = struct.unpack(“d“ recPacket[28:28 + byte])[0]
return “Reply from %s: bytes=%d time=%f5ms TTL=%d“ % (destAddr len(recPacket) (timeReceived - timeSent)*1000 TTL)
timeLeft = timeLeft - howLongInSelect
if timeLeft <= 0:
return “Request timed out.“
def sendOnePing(mySocket destAddr ID):
# Header is type (8) code (8) checksum (16) id (16) sequence (16)
myChecksum = 0
# Make a dummy header with a 0 checksum
# struct -- Interpret strings as packed binary data
header = struct.pack(“bbHHh“ ICMP_ECHO_REQUEST 0 myChecksum ID 1)
data = struct.pack(“d“ time.time())
# Calculate the checksum on the data and the dummy header.
myChecksum = checksum(str(header + data))
# Get the right checksum and put in the header
if sys.platform == ‘darwin‘:
# Convert 16-bit integers from host to network byte order
myChecksum = htons(myChecksum) & 0xffff
else:
myChecksum = htons(myChecksum)
header = struct.pack(“bbHHh“ ICMP_ECHO_REQUEST 0 myChecksum ID 1)
packet = header + data
mySocket.sendto(packet (destAddr 1)) # AF_INET address must be tuple not str
# Both LISTS and TUPLES consist of a number of objects
# which can be referenced by their position number within the object.
def doOnePing(destAddr timeout):
icmp = getprotobyname(“icmp“)
# SOCK_RAW is a powerful socket type. For more details: http://sock-raw.org/papers/sock_raw
mySocket = socket(AF_INET SOCK_RAW icmp)
myID = os.getpid() & 0xFFFF # Return the current process i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\
文件 222 2016-05-26 16:27 resources\599710134312805_Pythonsol-260138\__MACOSX\._Solutions
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\
文件 120 2016-05-26 16:27 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._.DS_Store
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._IcmpPing
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._ProxyServer
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._SMTPClient
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._StreamingVideo
文件 222 2015-03-16 09:56 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._Traceroute
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._UDPPinger
文件 222 2015-03-09 12:07 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\._Webserver
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\IcmpPing\
文件 222 2015-03-08 16:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\IcmpPing\._IcmpPing.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\ProxyServer\
文件 222 2015-03-07 19:24 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\ProxyServer\._ProxyServer.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\SMTPClient\
文件 222 2015-03-07 20:24 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\SMTPClient\._SMTPClient.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\StreamingVideo\
文件 222 2015-03-09 11:39 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\StreamingVideo\._Client.py
文件 222 2015-03-08 09:39 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\StreamingVideo\._RtpPacket.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\Traceroute\
文件 222 2015-03-16 09:56 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\Traceroute\._Traceroute.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\UDPPinger\
文件 222 2015-03-08 17:08 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\UDPPinger\._UDP_Pinger_Client.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\Webserver\
文件 222 2015-03-06 17:00 resources\599710134312805_Pythonsol-260138\__MACOSX\Solutions\Webserver\._Websever.py
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\Solutions\
文件 6148 2016-05-26 16:27 resources\599710134312805_Pythonsol-260138\Solutions\.DS_Store
目录 0 2018-11-29 22:31 resources\599710134312805_Pythonsol-260138\Solutions\IcmpPing\
文件 3625 2015-03-08 16:31 resources\599710134312805_Pythonsol-260138\Solutions\IcmpPing\IcmpPing.py
............此处省略47个文件信息
相关资源
- Netron-Setup-4.5.0.zip
- Multiple View Geometry in Computer Vision PDF 中
- 著名的.Net界面控件:DotNetBar 14.1.0.0
- 海康CH-HCNetSDKV5.3.6.30sdk_Win32_Win64.zip
- 《嵌入式系统原理与实践--ARM Cortex-
- Network Security:Private Communication in a
- Acunetix Web Vulnerability Scanner 10.0破解版
- ManageEngine_NetFlowAnalyzer_9.0.zip
- ghcms(jb51.net).rar
- pytorch resnet 152 模型参数数据
- bvlc_googlenet.prototxt &synset;_words.txt
- NetApp OnCommand System Manager 3.1.2
- DWGdirect.Net_and_ActiveX_3.3.0.rar
- Introduction to Computer Networks and Cybersec
- ADO.NET数据库应用开发.pdf
- Digital Design and Computer Architecture
- Visual Basic.NET程序设计教程第2版 龚沛
- Computer Vision:A Modern Approach中英双译本
-
Digital Signal Processing - Computer ba
sed - Computer Science An Overview(12th) 无水印
- Computer Networks A Systems Approach(5th) 无
- Internet and World Wide Web How To Program(5
- 缓冲区查询
- WebKit2.NET
- Computer Organization and Architecture 10th-Wi
- cpp-基于MXNetC框架的CPU实时人脸识别
- 劳务派遣网站系统免费版 v3.0.rar
- 基于STM32+W5500, 移植Ethernet文件并基于
- 教学绩效管理系统
-
SuperMap ob
jects .NET 淹没分析
评论
共有 条评论