! Overview: In this assignment, we will use Python to perform various networking-related tasks, including ultimately...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
! Overview: In this assignment, we will use Python to perform various networking-related tasks, including ultimately obtaining the system's Routing Table and comparing it to a user-entered IPv4 address. Submissions: In the Google from, submit Tasks: Follow the guidelines and best practices from previous assignments with a Python programming component. Feel free to reuse code from previous assignments, in particular the one on socket programming. Assignment07.py (Python code) Assignment07.txt (console output). [1] Write a function execute_command(cmd) to execute a windows shell command ("cmd"). See https://stackoverflow.com/questions/14894993/running-window s-shell-commands-with-python [2] Define a function get_routing_table by using the function from the previous step to run "route print" and then parsing the output into a table (2-D list). [3] Prompt the user to enter an IPv4 address in dotted-decimal notation. If the IP address is 0 or empty, this is our cue to quit. Otherwise proceed to ment stop Program Source Code (.cpp, java, .py) * 1 Add file Program Output (.txt) * 1 Add file A copy of your responses will be emailed to the address you provided. 1 Submit Never submit passwords through Google Forms. [4] Define a function validate_address() to validate the address in two ways: reCAPTCHA Call your own function to check that the entered IP address is valid, that is, it consists of four decimal numbers, each between 0 and 255, and separated by dots (periods). Call code from socket package to validate it. See https://stackoverflow.com/questions/319279/how-to-vali date-ip-address-in-python [5] Define a function get_binary_address() to find the binary equivalent of an IP address in dotted decimal notation and use it on the inputted IP address. Clear form [6] Define a function bitwise_and() to do the "bitwise-AND" of two bit-strings. You may either do it by iterating over the characters of the bit-strings, or use binary arithmetic. (See https://wiki.python.org/moin/BitwiseOperators) [7] Define a function get_classful_address_type() to dmetermine its class A thru E. If it is class D or E, tell the user that D is for multicast or E is reserved, and return to step [2]. You can determine the class either directly from the dotted decimal notation or from the leading bits of the binary equivalent. (See https://en.wikipedia.org/wiki/Classful network#Classful addres sing_definition) [8] Define a function get_next_hop() to loop through the rows of the routing table from step [2] and determine the "Next Hop" for the user-inputted address. To determine which row is determinant, use the following algorithm: octets [9] Compare the Next Hop to that provided by Python: from pyroute2 import IPRoute Do a bitwise-AND of the network mask with the destination IP address and see if you have a match with "Network Destination", the first column. Mathematically, this can be expressed at N = D & M where D is the Destination IP address, M is the (network) Mask, and N is the (destination) Network. Use the Metric column to decide between multiple matches (lowest value of Metric gets priority) If you have multiple matches and the Metric column is the same for all, then use the "Longest Prefix Match" to decide between ties, that is the one with more non-zero bits in the Mask. [9] Compare the Next Hop to that provided by Python: from pyroute2 import IPRoute with IPRoute () as ipr: print (ipr.route('get', dst-ipAddress) [10] Output the following information: The original inputted IP (destination) address in dotted-decimal notation The equivalent 32-bit address in binary notation The Class A, B, C, D, or E (the next two bullets apply only to classes A, B, C) The chosen Next Hop for that destination address How that address was chosen - match alone, metric, or longest-prefix match [11] Repeat steps [3] thru [10] until the user enters nothing or just 0 Try your program on the following inputs. If you get tired of typing them in, you can instead read them in from an input file. abc.def.ghi.jkl # not decimal 111-111-111-111 # not dotted 613.613.613.613 # format correct but numbers out of range 123.123.123 # valid numbers but only three - 225.225.225.225 # valid address but class D 241.242.243.244 # valid address but class E 127.0.0.1 # valid loopback address 52.3.73.91 # valid 216.239.63.255 # valid an address for amazon - an address for google ! Overview: In this assignment, we will use Python to perform various networking-related tasks, including ultimately obtaining the system's Routing Table and comparing it to a user-entered IPv4 address. Submissions: In the Google from, submit Tasks: Follow the guidelines and best practices from previous assignments with a Python programming component. Feel free to reuse code from previous assignments, in particular the one on socket programming. Assignment07.py (Python code) Assignment07.txt (console output). [1] Write a function execute_command(cmd) to execute a windows shell command ("cmd"). See https://stackoverflow.com/questions/14894993/running-window s-shell-commands-with-python [2] Define a function get_routing_table by using the function from the previous step to run "route print" and then parsing the output into a table (2-D list). [3] Prompt the user to enter an IPv4 address in dotted-decimal notation. If the IP address is 0 or empty, this is our cue to quit. Otherwise proceed to ment stop Program Source Code (.cpp, java, .py) * 1 Add file Program Output (.txt) * 1 Add file A copy of your responses will be emailed to the address you provided. 1 Submit Never submit passwords through Google Forms. [4] Define a function validate_address() to validate the address in two ways: reCAPTCHA Call your own function to check that the entered IP address is valid, that is, it consists of four decimal numbers, each between 0 and 255, and separated by dots (periods). Call code from socket package to validate it. See https://stackoverflow.com/questions/319279/how-to-vali date-ip-address-in-python [5] Define a function get_binary_address() to find the binary equivalent of an IP address in dotted decimal notation and use it on the inputted IP address. Clear form [6] Define a function bitwise_and() to do the "bitwise-AND" of two bit-strings. You may either do it by iterating over the characters of the bit-strings, or use binary arithmetic. (See https://wiki.python.org/moin/BitwiseOperators) [7] Define a function get_classful_address_type() to dmetermine its class A thru E. If it is class D or E, tell the user that D is for multicast or E is reserved, and return to step [2]. You can determine the class either directly from the dotted decimal notation or from the leading bits of the binary equivalent. (See https://en.wikipedia.org/wiki/Classful network#Classful addres sing_definition) [8] Define a function get_next_hop() to loop through the rows of the routing table from step [2] and determine the "Next Hop" for the user-inputted address. To determine which row is determinant, use the following algorithm: octets [9] Compare the Next Hop to that provided by Python: from pyroute2 import IPRoute Do a bitwise-AND of the network mask with the destination IP address and see if you have a match with "Network Destination", the first column. Mathematically, this can be expressed at N = D & M where D is the Destination IP address, M is the (network) Mask, and N is the (destination) Network. Use the Metric column to decide between multiple matches (lowest value of Metric gets priority) If you have multiple matches and the Metric column is the same for all, then use the "Longest Prefix Match" to decide between ties, that is the one with more non-zero bits in the Mask. [9] Compare the Next Hop to that provided by Python: from pyroute2 import IPRoute with IPRoute () as ipr: print (ipr.route('get', dst-ipAddress) [10] Output the following information: The original inputted IP (destination) address in dotted-decimal notation The equivalent 32-bit address in binary notation The Class A, B, C, D, or E (the next two bullets apply only to classes A, B, C) The chosen Next Hop for that destination address How that address was chosen - match alone, metric, or longest-prefix match [11] Repeat steps [3] thru [10] until the user enters nothing or just 0 Try your program on the following inputs. If you get tired of typing them in, you can instead read them in from an input file. abc.def.ghi.jkl # not decimal 111-111-111-111 # not dotted 613.613.613.613 # format correct but numbers out of range 123.123.123 # valid numbers but only three - 225.225.225.225 # valid address but class D 241.242.243.244 # valid address but class E 127.0.0.1 # valid loopback address 52.3.73.91 # valid 216.239.63.255 # valid an address for amazon - an address for google
Expert Answer:
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these algorithms questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
Some managers and union officials also refer to the collective agreement as what? Multiple Choice The real boss The rule book The bible The guiding framework Strategic doctrine
-
If air resistance can be ignored, how does the acceleration of a ball that has been tossed straight upward compare with its acceleration if simply dropped?
-
Seawater containing 3.50 wt% salt passes through a series of 10 evaporators. Roughly equal quantities of water are vaporized in each of the 10 units and then condensed and combined to obtain a...
-
What are the effects of air infiltration in condensers ?
-
Acrimony Limited has the following balances in its general ledger on 31 December 20X8 (in thousands of Canadian dollars): Required: Prepare, in good form, a statement of income and comprehensive...
-
An investment of $21700 is accumulated at 5.24% compounded quarterly for three and one-half years. At that time the interest rate is changed to 6.12% compounded monthly. How much is the investment...
-
A partially completed worksheet for At Home Pet Grooming Service, a firm that grooms pets at the owner's home, follows. INSTRUCTIONS 1. Record balances as of December 31 in the ledger accounts. 2....
-
Sort the sequence of numbers < 8,2,4,9,6> by performing the following algorithm. You can repeat several times as needed. (20P) Partition (A,p,q) // A[p,..., q] x+ A[q] i+q for j q 1 to p do if A[j] x...
-
PLEASE PROVIDE WORKING C# Code with output if you answer. Design an archive system to store novels. A novel can have many pages. Within a page, there can be several columns and frames. A column can...
-
Using the website www.sec.gov. and the most recent 10K SEC filings made by Dell Computer( DELL), and looking at the balance sheet, what is the book value of debt and the book value of equity. Is this...
-
A business had the following amounts of assets and liabilities at the beginning and end of a recent year: Beginning of the year Assets $ 84,000 End of the year 126,000 Liabilities $36,000 55,000...
-
Research various organizational issues that IKEA has faced and examine how changes in managerial competency positively or negatively impacted organizational effectiveness. Analyze the specific...
-
Why are the four premises of culture as a field of forces important to know? What do these premises illustrate to us about culture?
-
Pastas R Us, Inc. is a fast-casual restaurant chain specializing in noodle-based dishes, soups, and salads. Since its inception, the business development team has favored opening new restaurants in...
-
Drainee purchases direct materials each month. Its payment history shows that 65% is paid in the month of purchase with the remaining balance paid the month after purchase. Prepare a cash payment...
-
Multiple Choice Question 1 Raw materials and merchandise inventories are included in (a) Expenses (b) Fixed assets (c) Cash (d) Current assets (e) None of these 2 According to IAS 2, inventories are...
-
Based in India, Infosys Technologies Limited (Infosys) is a global technology services firm that defines, designs and delivers information technology-enabled business solutions to its clients. The...
-
JSC Aeroflot Russian Airlines (Aeroflot) was formed as a joint stock company following a government decree in 1992. The 1992 decree conferred all the rights and obligations of Aeroflot Soviet...
-
(a) Consider the flash separation process shown in Figure 7.1. If using ASPEN PLUS, solve all three cases using the MIXER, FLASH2, FSPLIT, and PUMP modules and the RK-SOAVE option set for...
-
As discussed in Example 6.7, toluene \(\left(\mathrm{C}_{7} \mathrm{H}_{8} ight)\) is to be converted thermally to benzene \(\left(\mathrm{C}_{6} \mathrm{H}_{6} ight)\) in a hydrodealkylation...
-
As discussed in Example 6.7, the following stream at \(100^{\circ} \mathrm{F}\) and 484 psia is to be separated by two distillation columns into the Products \(1-3\) in the following table. Two...
Study smarter with the SolutionInn App