Question: Please create with PYTHON You will be creating a program extractIP.py which will read from a file called wireShark.txt and extract all the ip addresses
Please create with PYTHON
You will be creating a program extractIP.py which will read from a file called wireShark.txt and extract all the ip addresses which can be of the format:
1,2 or 3 digits. 1, 2 or 3 digits.1, 2, or 3 digits. 1,2,3 digits Here are some examples of valid IPv4 addresses:
10.0.0.1, 12.123.123.123, 126.255.255.254, 191.255.255.254, 192.168.1.1, 239.255.255.255
And you will output them to another file called IPAddresses.txt , one per line, listing source and destination.
Example:
Source Destination
12.123.123.123 123.123.123.123
Requirements:
- You will read from a file called wireShark.txt which will be located in the same directory as your code
- You will write to a file called IPAddresses.txt which will be located in the same directory as your code
- All files will be opened and closed correctly.
- You will not use regex to parse the file. Instead, you will check the characters individually
- Your loops will be structured correctly.
- You will use one or more functions which will take a parameter or more, and return a value
- You will use lists
- You will use the split function
- You will write a function called CheckLine(currentLine) which will check if currentline is of the format:
No. Time Source Destination Protocol Length Info
Once you have identified this particular line, you will know that the following line has the IP addresses for source and destination in the second and third elements.
1 0.000000 192.168.1.180 239.255.255.250 SSDP 372 NOTIFY * HTTP/1.1
- Your functions and main code will be in separate sections of your program.
- Your IP addresses will be formatted in IPv4 format, i.e. 1, 2 or 3 digits .1, 2 or 3 digits.1,2 or 3 digits. 1,2,3 digits
- It is ok to reuse the code you wrote for past homework including homework 4.
Example:
File wireShark.txt was opened.
File IPAddress.txt was opened.
File IPAddress.txt was closed.
File wireShark.txt was closed.
wireShark.txt should contain the following IP Addresses:
Source Destination
192.168.1.180 239.255.255.250
192.168.1.51 146.20.112.65
192.168.1.51 146.20.112.65
146.20.112.65 192.168.1.51
146.20.112.65 192.168.1.51
146.20.112.65 192.168.1.51
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
