Skip to content

Commit a2f3ae6

Browse files
committed
Update and rename EtherTypeMiner.py to EtherTypeMiner
1 parent df7c114 commit a2f3ae6

File tree

2 files changed

+117
-3
lines changed

2 files changed

+117
-3
lines changed

EtherTypeMiner

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
'''http://standards.ieee.org/develop/regauth/ethertype/eth.txt
2+
this is the etherType text file we are going to use
3+
there are 43 lines, each one has a hex number, I have to convert
4+
all those hex numbers into decimal, and then print them back to the text file
5+
6+
NO way I am going to do that by hand. simple, use python!
7+
'''
8+
9+
10+
11+
>>> f = open('/root/Desktop/project/EtherType','r')
12+
>>> lines = f.readlines()
13+
>>> lines
14+
['0x0800 \t2048 Internet Protocol version 4 (IPv4)\n', '0x0806 \t2054 Address Resolution Protocol (ARP)\n', '0x0842 \tWake-on-LAN[3]\n', '0x22F3 \tIETF TRILL Protocol\n', '0x6003 \tDECnet Phase IV\n', '0x8035 \tReverse Address Resolution Protocol\n', '0x809B \tAppleTalk (Ethertalk)\n', '0x80F3 \tAppleTalk Address Resolution Protocol (AARP)\n', '0x8100 \tVLAN-tagged frame (IEEE 802.1Q) & Shortest Path Bridging IEEE 802.1aq[4]\n', '0x8137 \tIPX\n', '0x8138 \tIPX\n', '0x8204 \tQNX Qnet\n', '0x86DD \tInternet Protocol Version 6 (IPv6)\n', '0x8808 \tEthernet flow control\n', '0x8809 \tSlow Protocols (IEEE 802.3)\n', '0x8819 \tCobraNet\n', '0x8847 \tMPLS unicast\n', '0x8848 \tMPLS multicast\n', '0x8863 \tPPPoE Discovery Stage\n', '0x8864 \tPPPoE Session Stage\n', '0x8870 \tJumbo Frames[2]\n', '0x887B \tHomePlug 1.0 MME\n', '0x888E \tEAP over LAN (IEEE 802.1X)\n', '0x8892 \tPROFINET Protocol\n', '0x889A \tHyperSCSI (SCSI over Ethernet)\n', '0x88A2 \tATA over Ethernet\n', '0x88A4 \tEtherCAT Protocol\n', '0x88A8 \tProvider Bridging (IEEE 802.1ad) & Shortest Path Bridging IEEE 802.1aq[5]\n', '0x88AB \tEthernet Powerlink[citation needed]\n', '0x88CC \tLink Layer Discovery Protocol (LLDP)\n', '0x88CD \tSERCOS III\n', '0x88E1 \tHomePlug AV MME[citation needed]\n', '0x88E3 \tMedia Redundancy Protocol (IEC62439-2)\n', '0x88E5 \tMAC security (IEEE 802.1AE)\n', '0x88F7 \tPrecision Time Protocol (IEEE 1588)\n', '0x8902 \tIEEE 802.1ag Connectivity Fault Management (CFM) Protocol / ITU-T Recommendation Y.1731 (OAM)\n', '0x8906 \tFibre Channel over Ethernet (FCoE)\n', '0x8914 \tFCoE Initialization Protocol\n', '0x8915 \tRDMA over Converged Ethernet (RoCE)\n', '0x892F \tHigh-availability Seamless Redundancy (HSR)\n', '0x9000 \tEthernet Configuration Testing Protocol[6]\n', '0x9100 \tQ-in-Q\n', '0xCAFE \tVeritas Low Latency Transport (LLT)[7] for Veritas Cluster Server\n']
15+
16+
'''now we get the content of the file in python's tuple, the next thing we want to do is extract only the hex numbers'''
17+
18+
>>> for i in lines:
19+
... print i[:7]
20+
...
21+
0x0800
22+
0x0806
23+
0x0842
24+
0x22F3
25+
0x6003
26+
0x8035
27+
0x809B
28+
0x80F3
29+
0x8100
30+
0x8137
31+
0x8138
32+
0x8204
33+
0x86DD
34+
0x8808
35+
0x8809
36+
0x8819
37+
0x8847
38+
0x8848
39+
0x8863
40+
0x8864
41+
0x8870
42+
0x887B
43+
0x888E
44+
0x8892
45+
0x889A
46+
0x88A2
47+
0x88A4
48+
0x88A8
49+
0x88AB
50+
0x88CC
51+
0x88CD
52+
0x88E1
53+
0x88E3
54+
0x88E5
55+
0x88F7
56+
0x8902
57+
0x8906
58+
0x8914
59+
0x8915
60+
0x892F
61+
0x9000
62+
0x9100
63+
0xCAFE
64+
#the next thing we need to do is convert them into integer
65+
66+
for i in lines:
67+
... print int(str(i[:7]),16)
68+
...
69+
2048
70+
2054
71+
2114
72+
8947
73+
24579
74+
32821
75+
32923
76+
33011
77+
33024
78+
33079
79+
33080
80+
33284
81+
34525
82+
34824
83+
34825
84+
34841
85+
34887
86+
34888
87+
34915
88+
34916
89+
34928
90+
34939
91+
34958
92+
34962
93+
34970
94+
34978
95+
34980
96+
34984
97+
34987
98+
35020
99+
35021
100+
35041
101+
35043
102+
35045
103+
35063
104+
35074
105+
35078
106+
35092
107+
35093
108+
35119
109+
36864
110+
37120
111+
51966
112+
113+
#the next thing we need to do is to write this to our file, remmember in the actual code we have 'printed' the results,
114+
#in reality we have to save them to python variables to work with them, but it is a good practice to see them first
115+
#and then do the actual programming
116+
117+

EtherTypeMiner.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)