Introductionjava的网络编程,主要是一个FileSender 发送类和一个FileReceiver接收类, 考察了网络编程的基础知识,CRC32 Checksum验证,消息头的封装和解封,数据的传输等等知识RequirementPage 1 of 6Assignment 2IntroductionIn this assignment, you will transfer a file over UDP protocol on top of an unreliable channelthat may either corrupt or drop packets randomly (but always deliver packets in order).Writing Your ProgramsYou are free to write your programs on any platform/IDE that you are familiar with.GradingYour programs will be graded according to their correctness using a grading script.:• [2 points] Programs are compilable on sunfire, program execution follows specifiedJava commands (see sections below).• [1 point] Programs can successfully transfer a file from sender to receiver when channel isperfectly reliable (i.e. no error at all).Page 2 of 6• [1 point] Programs can successfully transfer a file from sender to receiver in the presence ofdata packet corruption.• [1 point] Programs can successfully transfer a file from sender to receiver in the presence ofACK/NAK packet corruption.• [1 point] Programs can successfully transfer a file from sender to receiver in the presence ofdata packet loss.• [1 point] Programs can successfully transfer a file from sender to receiver in the presence ofACK/NAK packet loss.• [1 point] Programs can successfully transfer a file from sender to receiver in the presenceof both packet corruption and packet loss.To conclude a successful file transfer, received file must have identical content as thesent one (use command cmp to check it on sunfire). Your program should work forboth text and binary files, and for both small files and large files (a few MBs).Grading script. doesn’t care what messages your programs print on the screen. It just checksif the received file is exactly the same as the sent one in respective test cases.• [2 points] (Who runs faster?) Time taken for your programs to transfer an enormous file(more than 10MB) in the presence of both packet corruption and packet loss will be noteddown. The fastest batch of student programs will receive 2 marks and slower programs thatare still faster than average will receive 1 mark. JYou may apply the knowledge gained from this or other courses as appropriate. However,since the objective of this assignment is to design a fast network transmission protocol,you are NOT allowed to play tricks (e.g., data compression) to gain unfair advantageover your peers. Please consult the teaching team if you are unsure if certain techniquescan be used or not.A Word of AdviceThis assignment is complex and time-consuming. You are suggested to write programsincrementally and modularly. For example, deal with data packet corruption first, then ACKpacket corruption, then data packet loss, etc. Test your programs after every single majorchange. Take note that partial credit will be awarded even if your programs don’t meet all listedrequirements.Page 3 of 6Overall ArchitectureThere are three programs in this assignment, FileSender, UnreliNET andFileReceiver. Their relationship is illustrated in Figure 1 below. The FileSender andFileReceiver programs implement a file transfer application over UDP protocol. TheUnreliNET program simulates the transmission channel that transmits packets unreliably andrandomly corrupts or loses packets. However, for simplicity, you can assume that this channelalways delivers packets in order.Figure 1: UnreliNet Simulates Unreliable NetworkThe UnreliNET program acts as a proxy between FileSender and FileReceiver.Instead of sending packets directly to FileReceiver, FileSender sends all packets toUnreliNET. UnreliNET may introduce bit errors to packets or lose packets randomly. Itthen forwards packets (if not lost) to FileReceiver. When receiving feedback packets fromFileReceiver, UnreliNET may also corrupt them or lose them with certain probabilitybefore relaying them to FileSender.The UnreliNET program is complete and given. Your task in this assignment is to develop theFileSender and FileReceiver programs so that a file can be successfully transferredfrom sender to receiver in the presence of possible packet corruption and packet loss. Thereceived file should be identical to the file sent. You may need to implement techniques learntin lecture, including sequence number, acknowledgement, timeout and retransmission, toensure that packets are correctly delivered.FileSender ClassThe FileSender program is basically a file uploader that opens a given file and sends itscontent as a sequence of packets to UnreliNet. UnreliNet would then corrupt/losepackets with certain probability before relaying them to the FileReceiver program.To run FileSender on sunfire, type command:java FileSender For example:java FileSender ../test/cny.mp3 localhost 9000 gxfc.mp3sends the file cny.mp3 from directory (relative path) ../test to UnreliNet running inthe same host at port 9000. UnreliNet will then pass the file to your FileReceiverprogram to be stored as gxfc.mp3.UnreliNET FileSender FileReceiverPage 4 of 6(Note: Windows system uses a different file separator ‘’, e.g., .. estcny.mp3)You may assume that during testing, your sender program will be supplied with the correctpath and filename (no more than 100 bytes long). No input validation is needed.UnreliNET ClassThe UnreliNET program simulates an unreliable channel that may corrupt or lose packetswith a certain probability. This program is given and shouldn’t be changed.To run UnreliNET on sunfire, type command:java UnreliNET For example:java UnreliNET 0.3 0.2 0.1 0.05 9000 localhost 9001listens on port 9000 and forwards all received data packets to FileReceiver running on thesame host at port 9001, with 30% chance of packet corruption and 10% chance of packet loss.The UnreliNET program also forwards ACK/NAK packets to FileSender, with 20% packetcorruption rate and 5% packet loss rate.Packet Corruption ProbabilityThe UnreliNET program randomly corrupts or loses data packets and ACK/NAK packetsaccording to the specified parameters P_DATA_CORRUPT, P_ACK_CORRUPT P_ACK_LOSS andP_ACK_LOSS. You can set these values to anything in the range [0, 0.3] during testing (setting atoo large corruption/loss rate may result in a very slow file transmission).If you have trouble getting your code to work, it might be advisable to set them to 0 first fordebugging purposes.FileReceiver ClassThe FileReceiver program receives a file from FileSender (through UnreliNET) andsaves it in the same directory as the FileReceiver program, with a filename specified byFileSender.To run FileReceiver on sunfire, type command:java FileReceiver For example:java FileReceiver 9001listens on port 9001 and dumps the bytes received into a file whose name is given by sender.Page 5 of 6Running All Three ProgramsYou should first launch FileReceiver, followed by UnreliNET in the second window.Finally, launch FileSender in a third window to start data transmission. All programs shouldreceive user input from command-line argument only. Please always test your programs inlocalhost to avoid the interference of network traffic on your programs.The UnreliNET program simulates unreliable communication network and runs infinitely.Once launched, you may reuse it in consecutive tests. To manually terminate it, press + c.The UnreliNET program prints out information that is helpful in debugging your programs.However, we will disable such outputs in speed test.The sender and receiver programs shouldn’t communicate with each other directly – all trafficshould be forwarded by the UnreliNET program. The sender program should terminateproperly (e.g., no exception, no infinite loop) once transmission finishes. However, you mayleave the receiver program running infinitely (i.e., no need for receiver to detect end oftransmission and terminate, but DO remember to close the file output stream at the end).Self-defined Header/Trailer Fields at Application LayerUDP transmission is unreliable. To detect packet corruption or packet loss, you may need toimplement reliability checking and recovery mechanisms at application layer. The followingheader/trailer fields are suggested though you may have your own design: Sequence number ChecksumNote that each packet FileSender sends should contain at most 1000 bytes of applicationdata (inclusive of self-defined header/trailer fields), or UnreliNET program will reject it.Computing ChecksumTo detect bit errors, FileSender should compute checksum for every outgoing packet andembed it in the packet. FileReceiver needs to re-compute checksum to verify the integrityof a received packet.Please refer to Assignment 0 Exercise 3 on how to compute checksum using Java CRC32 class.Timer and Timeout ValueSender may have to maintain a timer for unacknowledged packet. You are suggested to use thesetSoTimeout() method of Java Socket class.You shouldn’t set a timeout value that is larger than 200ms, or your program might be too slowin transmitting data and thus get killed by the grading script.Page 6 of 6Reading/Writing Values to Header/Trailer FieldsThe number of header/trailer fields and the sequence of their appearance in a packet is theagreement between sender and receiver (i.e. an application layer protocol designed by you).As discussed in tutorial 3, to give value to a header field of a 4-byte integer, you may considerByteBuffer class from java.nio package. An example is shown below.At sender side:int length = 1000;// allocate a 4-byte array to store converted integerbyte[] pktLen = ByteBuffer.allocate(4).putInt(length).array();// copy content of pktLen to the beginning of output buffer of pktSystem.arraycopy(pktLen, 0, buffer, 0, pktLen.length);At receiver side:// extract the first 4 bytes of a packet as the integer ‘length’ByteBuffer wrapper = ByteBuffer.wrap(pkt.getData(), 0, 4);int length = wrapper.getInt();本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp