TCP端口测试简法

  1. telnet法
TCP端口开了
$ echo "" | telnet 123.1.2.3 8100
Trying 123.1.2.3...
Connected to 123.1.2.3.
Escape character is '^]'.
Connection closed by foreign host.

TCP端口关了
$ echo "" | telnet 123.1.2.3 8101
Trying 123.1.2.3...
telnet: connect to address 123.1.2.3: Connection refused

如果希望带源地址测试,可以

telnet -b source_ip destanation_ip port
  1. nc法
TCP端口开了
$ nc -nzv 123.1.2.3 7205       
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 123.1.2.3:7205.
Ncat: 0 bytes sent, 0 bytes received in 0.03 seconds.

TCP端口关了
$ nc -nzv 123.1.2.3 7206
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connection timed out.

如果希望带源地址测试,可以

nc -s source_ip -zv destanation_ip port
  1. nmap法
TCP端口开了
$ nmap -Pn -sT 123.1.2.3 -p 8100

Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-29 12:12 CST
Nmap scan report for nothing.attdns.com (123.1.2.3)
Host is up (0.0067s latency).
PORT     STATE SERVICE
8100/tcp open  xprint-server

Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds

TCP端口关了
$ nmap -Pn -sT 123.1.2.3 -p 8101

Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-29 12:12 CST
Nmap scan report for nothing.attdns.com (123.1.2.3)
Host is up.
PORT     STATE    SERVICE
8101/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 2.08 seconds

TCP端口开了啥
$ nmap -Pn -sT 123.1.2.3 -p 8000-8300

Starting Nmap 6.40 ( http://nmap.org ) at 2019-09-29 12:11 CST
Nmap scan report for nothing.attdns.com (123.1.2.3)
Host is up (0.0083s latency).
Not shown: 299 filtered ports
PORT     STATE SERVICE
8081/tcp open  blackice-icecap
8100/tcp open  xprint-server

Nmap done: 1 IP address (1 host up) scanned in 10.00 seconds
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python可以通过以下步骤使用卡诺图化简法: 1. 创建一个truth table,表示布尔函数的输入和输出。 2. 将truth table按照规则(如最短项的贪心法)分组,并将分组的结果标记在卡诺图上。 3. 用卡诺图的分组结果来确定布尔函数的最小项(min terms)和不可简化项(don't care terms)。 4. 使用最小项和不可简化项生成简化后的布尔函数。 以下是一个使用Python代码实现卡诺图化简法的例子: ``` from itertools import combinations # create a truth table (inputs -> output) truth_table = {'000': 0, '001': 0, '010': 0, '011': 1, '100': 1, '101': 1, '110': 0, '111': 0} def generate_groups(minterms, num_vars): groups = [[] for i in range(num_vars + 1)] for minterm in minterms: num_ones = bin(minterm).count('1') groups[num_ones].append(minterm) return groups def combine_groups(groups): new_groups = [] for i, group in enumerate(groups): for j, other_group in enumerate(groups): if i != j: for pair in combinations(group, 2): if pair[0] ^ pair[1] in other_group: new_group = set(group + other_group) new_group.remove(pair[0]) new_group.remove(pair[1]) new_groups.append(sorted(list(new_group))) return new_groups def get_min_terms(group): min_terms = [] for minterm in group: bin_num = bin(minterm)[2:] bin_num = '0' * (3 - len(bin_num)) + bin_num min_terms.append(bin_num) return min_terms def simplify_boolean(minterms, num_vars): groups = generate_groups(minterms, num_vars) while True: new_groups = combine_groups(groups) if len(new_groups) == 0: break groups = groups + new_groups min_terms = [] for group in groups: min_terms += get_min_terms(group) return min_terms print(simplify_boolean([3, 4, 5, 6], 3)) # Output: ['011', '101'] ``` 在这个例子中,我们使用了一个truth table来表示一个布尔函数,并创建了一个函数`simplify_boolean`来实现化简布尔函数的操作。该函数接受一个包含minterms的列表和变量数量,返回最小项的字符串表示形式。我们可以看到,该函数使用卡诺图算法来实现化简操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值