COMS3200/7201 Assignment 2Due: 25th May 2020, 20:00100 marks total (20% weight for the final grade (100%))Part A (30 marks total)You are asked some questions on packet behaviours in the following network, which depicts three LANs (LAN1, LAN2and LAN3) and a file server (S) connected to the internet.Answer each of the following questions in the associated quiz on blackboard, following the specified instructions. Eachstudent will receive different network details.• All questions will be automatically marked.• Each question follows on from the previous question – i.e.: for each question you can assume the tasks describedin the previous question(s) have been fully completed.• In any column that asks you for a protocol, the following options will be allowed: HTTP, FTP, Secure Shell (SSH),DNS, DHCP, UDP, TCP, ICMP, SNMP, ARP, OSPF, BGP.• In any case where multiple protocols are used, pick the highest-layer protocol(e.g., if SSH was used, you would select it over TCP, even though SSH packets use TCP as a transport layer protocol).• In any column that asks you for MAC address use upper case, two-digit hex format(e.g., AB:CD:EF:01:10:20 09:08:07:AA:BB:CC)• In any column that asks you for IP address use the dotted decimal format (e.g. 1.2.3.4 255.255.0.0).• Assume and only use 255.255.255.255 as the broadcast IP address of all the LANs depicted in this network.• Assume that the broadcast MAC address of all the LANs is FF:FF:FF:FF:FF:FF.• Assume all forwarding tables in the switches and routers are up to date.2Answer the following questions based on the network diagram and customised questions shown to you onBlackboard. Each student’s diagram and question values will be different for each submission.1. Suppose Host A has just joined the network and does not currently have an IP address. Complete the followingtable describing the four packets that will be transmitted through the network upon this event (in the order theywere sent), assuming that all requests succeed, and that Host A ends up with the IP address 4001 (i.e. customisedinformation will be given here.)Table 1.Protocol Opcode Src MAC addr Dst MAC addr Src/Sender IPv4 addr Dst/Target IPv4 addr2. Now suppose the Host A wants to send a standard DNS query to D2. The Host A has already gotten the IPv4addresses of D2 and its gateway router from D1. R1’s ARP table contains the IP and MAC addresses of all hosts inthe network, and all other ARP tables are empty. Complete the following table describing the first four packetsthat will be transmitted through the network upon this event, assuming that there are no other ongoingcommunications.Table 2.Protocol Opcode Src MAC addr Dst MAC addr Src/Sender IPv4 addr Dst/Target IPv4 addr3. The Host A now wants to establish a HTTP connection with a server (S) (file server). You may assume that theHost A knows S’s IP address and that all ARP tables contain all required information to transmit any packet.Complete the following table describing the packets that are sent to transmit Host A’s request to initialise theconnection, assuming the request is being sent from TCP port 4001 and the next available port number in R1’sNAT table is 5001. Give the TCP flags as an 8-bit binary number representing the CWR to FIN flags.Table 3.Protocol TCP Flags Src TCP port Dst TCP port Src/Sender IPv4 addr Dst/Target IPv4 addrTCPTCP34. Suppose in addition to the connection described in (3), the Host B’s port 3200 is also currently connected to S.What are the contents of the NAT table in R1 while these connections remain alive? (if a new port is required, useport).Table 4.LAN IP LAN Port WAN IP WAN Port5. Suppose Host B sent a packet with destination IP address 255.255.255.0 and destination MAC addressFF:FF:FF:FF:FF:FF. What network devices (hosts, servers, routers, switches) in the above diagram would receivethis packet?6. Suppose S sends a packet with the destination IP address 192.168.1.2. What network devices (hosts, servers,routers, switches) in the above diagram would receive this packet?Part B (70 marks)In this part of the assignment you will be required to implement the network layer for a host running on a virtual IPnetwork. You should be familiar with the typical TCP/IP stack, where Ethernet is used as a link-layer protocol and IPv4used as a network layer protocol. The protocols we will be using will be virtual - that is, network layer addresses won’tactually correspond to physical interfaces. To do this, the network stack will be redefined to that shown in the tablebelow.TCP/IP Stack Protocols Virtual StackNetwork LayerTransport layer UDPNetwork layer Link layer IPv4Link Layer EthernetFigure 1.As described in Figure 1, UDP will be used as your virtual network’s link layer, and you will be required to implementa virtualisation of IPv4 on top of this UDP-based link layer. Each UDP socket will correspond to a link layer interface,and localhost UDP port numbers will be used as the link layer addressing system of this virtual network.In other words, your program is the simulation of a host on a virtual network running on your computer. UDP portnumbers will be used as “MAC addresses”. Your program should only connect to localhost, i.e. all actual packetsshould transmit across localhost.By the end of this assignment, your implemented host program should be able to:• Accept simple user commands through a basic command line interface (CLI)4• Send and receive messages across this virtual network layer• Handle fragmentation of virtual IP packetsProgram InvocationYour program should be able to be invoked from a UNIX command line as follows. It is expected that any Pythonprograms can run with version 3.6, and any Java programs can run with version 8. The IP-addr and LL-addr parameterscorrespond to the IPv4 address in CIDR notation (indicating the client’s subnet) and link layer address (UDP portnumber) of your host program respectively.Python python3 NetworkSim.py IP-addr LL-addrC/C++ make./NetworkSim IP-addr LL-addrJava makejava NetworkSim IP-addr LL-addrIMPORTANT: As the assignment is auto marked, it is important that the filenames and command line syntax exactly matchesthe specification. Specification adherence is critical for passing.Your Task1.1 Command Line Interface (5 marks)To start with, you should implement a basic command line interface that will allow the user to supply basic informationabout the network. Your CLI should prompt users with a single > character, followed by a space. For the rest of theassignment we define anything wrapped in square brackets as a parameter or field that needs replacing (NOT as anoptional parameter). The CLI should persistently prompt the user for another command until the program isterminated. For full marks in this section your CLI needs to accommodate the following commands:• gw set [IP-addr]: set the gateway IP address of the subnet the client is a part of to [IP-addr] (overridingany existing gateway address)• gw get: print the currently stored gateway IP address to stdout, or None if no gateway address has beenspecified• arp set [IP-addr] [LL-addr]: insert a mapping from [IP-addr] to [LL-addr] in the host’s ARP table(overriding any existing entries for [IP-addr])• arp get [IP-addr]: print the currently stored link layer address mapped to [IP-addr] to stdout, or None ifno mapping exists• exit: terminate the programError-handling of user input is optional - you won’t receive any marks for this, but you can choose to implement itprovided it doesn’t impact on the rest of the assignment.51.2 Sending Messages (15 marks)To receive marks in this section, your CLI should be able to handle the following additional command:• msg [IP-addr] [payload]: send a virtual IPv4 packet to [IP-addr] with the given payload (which willbe supplied as a string)Any packets sent should have a meaningful identifier and a protocol number of 0. You may assume the that all payloadswill be less than or equal to the MTU of the network’s links, but the DF flag should still be set to 0. Your COMS3200/7201作业代写、代做java程序语言作业、Python,c++课程设计作业代写 代做数据库SQL|代program shouldsupport any IP address, regardless of whether it is a part of your subnet or not. The subnet mask can be extracted fromthe client’s IP in CIDR notation. When a packet is sent to an IP address outside of the subnet range, it should be sent tothe gateway address.If your program needs to send a packet to the gateway address and no gateway address has been specified, yourprogram should print No gateway found to stdout. If no required address mapping can be found in the host’s ARP table,your program should print No ARP entry found to stdout.1.3 Receiving Messages (15 marks)In addition to sending packets, your program should be able to receive them from other hosts. When your programreceives an IPv4 packet with the protocol indicator set to 0, it should print the payload of that packet to stdout, in thebelow format ([IP-addr] should be replaced with the sender’s IPv4 address and [message] should be replaced with thestring encoding of the payload):Message received from [IP-addr]: [message]Note that there is only a single space after the colon. When your program receives an IPv4 packet with a non-zeroprotocol number, it should print the following message to stdout ([proto-num] should be the hexadecimalrepresentation of the protocol formatted as 0x??):Message received from [IP-addr] with protocol [proto-num]You can assume all packets sent to your program are valid IPv4 packets. You should be able to receive messages at anytime without blocking the CLI, and any messages should be printed cleanly (without any CLI prompts or responsesdisrupting the message contents). Remember to backspace the current prompt (the > character) before printing theoutput.Hint: The escape character for backspace is “\b”. For example, use print(‘\b’) to backspace a previously printedcharacter in Python.1.4 IP Fragmentation (15 marks)To receive marks in this section your program should be able to handle IP fragmentation. Your CLI should support thefollowing extra commands:• mtu set [value]: set the MTU of the network’s links as the specified [value]• mtu get: print the currently stored MTU (the default MTU should be 1500)Virtual packets that are longer than the specified MTU (or the default MTU if none has been specified) should befragmented before transmission. The length of a virtual packet is equal to the length of the IPv4 header added to thelength of the IPv4 payload (i.e. you don’t need to consider the length of the non-virtual headers). You can assume thevalue of the MTU will never be smaller than 100.Your program should also be able to receive packets that have been fragmented (and display them as a single message).61.5 Handling packet loss (20 marks)To receive marks in this section your program should be able to handle packet losses. Your CLI should support thefollowing extra commands:• frto set [value]: set the FRTO ( Fragment Reassembly TimeOut) of the network to the specified [value]• frto get: print the currently stored FRTO (the default FRTO should be 5)When fragmented packets are received these should be held in memory until all fragments for the given identificationfield (Id) have arrived, or until FRTO expires. Each Id should have its own FRTO timer, which starts with the arrival ofa new packet Id. Once the FRTO expires, all fragments related to the FRTO should be discarded and a packet with aprotocol number of 114 and the identification field set to Id should be returned to the sender.When sending messages, you should keep a collection of fragmented packets for a maximum of 3 x FRTO (i.e. 3 timesFRTO time), and resend the fragments related to the Id when you get a packet with the protocol number 114. Changingthe FRTO value (using frto set) does not affect any existing timers in operation.While printing non-zero protocol numbers remains unchanged, when the protocol number is 114, and the fragmentsbeing requested for are available (valid and not expired), your program should print the following message to stdoutinstead. ([fragmentation-Id] should be the hexadecimal representation of the identification field as 0x?)Message-Resend received from [IP-addr] for id [fragmentation-Id]Fragments older than 3 x FRTO are expired and should be deleted. If you get a packet with protocol 114 for an Id thatis expired or unknown, these should be ignored, and the following message printed to stdout.Message-Resend received from [IP-addr] for id [fragmentation-Id] BAD7Example CLI outputpython3 NetworkSim.py 192.168.1.1/24 1024> gw getNone> gw set 192.168.1.30> gw get192.168.1.30> msg 192.168.1.2 helloNo ARP entry found> arp get 192.168.1.2None> arp set 192.168.1.2 2222> arp get 192.168.1.22222> msg 192.168.1.2 hello> mtu get1500> mtu set 1600> mtu get1600Message received from 192.168.1.2: hello there, thank you for your messageMessage received from 192.168.1.3 with protocol 0x06> frto get5> frto set 3> frto get3Message-Resend received from 192.168.1.6 for id 0x00a4Message-Resend received from 192.168.1.7 for id 0x00a5 BAD> exitPacket FormattingYour IPv4 packets don’t need to contain meaningful values for the differentiated services code point (DSCP)/ExplicitCongestion Notification (ECN) fields, nor are you required to compute a correct checksum. You can assume packetswill never contain any options and subsequently that the Internet Header Length (IHL) will always be 5. The TTL fieldshould contain some meaningful value (i.e. to allow the packet to reach its destination).Tips for Success• Revisit the lectures and labs on the internet layer of the TCP/IP stack (in particular the lectures on IPv4).• Make sure you fully understand the requirements of this assignment before commencing work.• Ensure you always exercise good thread safety if using threads to implement concurrency.• Frequently test your code on MOSS.• Ensure your base functionality is working (such as the CLI) before attempting the more difficult tasks.• Start early and ask any questions you might have early.8Library Restrictions• The only communication libraries you may use are standard socket libraries which open UDP sockets.• You can’t use any libraries that aren’t considered standard for your language (i.e. if you have to download alibrary to use it would be considered as non-standard).• If you are unsure about whether you may use a certain library, please ask the course staff on Piazza.SubmissionSubmit all files necessary to run your program. At a minimum, you should submit a file named NetworkSim.py,NetworkSim.c, NetworkSim.cpp or NetworkSim.java. If you submit a C/C++ or Java program, you shouldalso submit a makefile to compile your code into a binary named NetworkSim or a .class file namedNetworkSim.class.IMPORTANT: If you do not adhere to this (e.g. submitting a C/C++/Java program without a Makefile, or a .class fileinstead of a .java file), you will receive 0 for this part of the assignment. Do not submit executables.MarkingYour code will be automatically marked on a UNIX machine, so it is essential that your program’s behaviour isexactly as specified above. Your program should complete all tasks within a reasonable time frame (for example asingle packet should not take more than one second to construct and send) - there will be timeouts on all tests and itis your responsibility to make sure your code is not overly inefficient. It is expected that you will receive a small sampleof tests and a basic RUSH2 client program before the submission deadline.There are no marks for coding style, however you may lose marks in relevant sections for poor management ofconcurrency.Academic MisconductStudents are reminded of the University’s policy on student misconduct, including plagiarism. See the course profileand the School web page http://www.itee.uq.edu.au/itee-student-misconduct-including-plagiarism.Late Submission and ExtensionsPlease view the ECP for policies on late submissions and extensions as well as updates based on COVID-19 situation.Version History12/05/2020 Initial release 1.0转自:http://www.6daixie.com/contents/13/5146.html