Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a newbie in networking in java and i know packets may get lost in UDP protocol. I'm looking to make a program which shows the effect of UDP data loss so that the concept becomes clearer. Therefore i want hints for making a program myself which shows data loss using UDP.
You need to write two programs:
A client that sends UDP packets containing a sequence number that it keeps incrementing.
A server program that accepts UDP packets, extracts the sequence number, and checks to see if they any are missing or out of order. If there is no loss or reordering of packets, the server should see the UDP packets in ascending order ... as sent by the client.
Then run the client and server, with the client sending to the server. If packets are missing, that illustrates UDP data loss.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to handle TCP SYN requests from users to denied some invalid requests to web server (Apache) on a CentOS server
How to write an application in C++ or Java or any programming languages?
You can create a netfilter kernel module (in C language), and hook yourself for various packet events such as receiving a packet on a particular interface etc. You will need to check the packet header to figure out whether it is a TCP SYN request, and then decide what to do with it.
https://www.netfilter.org/
You cannot create a user mode C++ or Java program to achieve this.
That being the answer for what you are asking, perhaps a better alternative would be to add rules to the firewall depending on what invalid requests you want to disable.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm wondering what it would take (skills wise) to make a packet capture system that collects the destination of the packets and stores them, so any help would be appreciated!
I'm hoping to do it in Python or Java, if that helps.
What you're trying to develop already exists for many years, and with multiple implementations:
Wireshark
TCPDump.
Both applications can write the packets in the PCAP format. Bear in mind that these applications require root access and privileges as they ask the kernel to fork the incoming packets to your application.
I Think you need something like jpcap and jNetpcap is wrapping in java.
check out below links :
sniff network traffic in java
full example of network sniffing in java
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I understand that Socket-based Communication is independent between programming languages. Which means, a socket program written in Java language can communicate to a program written in C or C++ socket
program. And I've see many similar questions like mine in Stack overflow and I appreciate those answers.
But I didn't get what I'm looking for. Can anyone answer this with example code as JAVA program as a Server and C++ program as Client which runs on different machine and how they communicate?
Thank You :)
Socket communication is basically sending a set of bits (data/packet as you would call at a higher level) from one port to another. Port is nothing but a file/IO stream that can listen to data or send data given the correct address. A valid address is a combination of valid IP address(depending on if you want local or remote communication) and port number.
To answer your question we basically are opening a file, writing or waiting to be written into from another application. So, file open, close, read, write has nothing to do with a programming language. Only thing that varies between different languages are the APIs or interfaces provided to achieve this purpose.
When you open a socket you mention about the protocol you want to use for this communication, it could be TCP/UDP based on the purpose of your application. The protocol decides how the packet/data being sent and received are ordered. Basically, trying to establish a common ground between the 2 parties trying to communicate.
Hope this answer helps!!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am developing a Java application in which I need to pass details of a Socket object to remotely connected computer through a Socket... I tried it by passing the socket object in object output stream. But as "Socket" is not "serializable" it didn't work...
Can anyone help me please? Or tell me whether it is possible or not...
Thank you...
You have the solution at your hand. If you (the server) have 2 opened sockets, one from A and another from B all you have to do is: What is read from A send it to B and what is read from B send it to A. When socket A or socket B is closed (or has an error) you (the server) close both socket and the conversation is over. To deal with this scenario, you need to use select or another non-blocking mechanism to see which socket has data to be read and act accordingly. I would recommended to use a separate thread to do this job, so the server will be free to attend more clients.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
My client program wants to send a huge file to the server and in return the server program returns a double or triple sized file.
My question is, which approach should I use? Either TCP or UDP.
You could utilize FTP (File Transfer Protocol) for your use case.
It is very common and you can use it with java to get or to upload
files to the FTP server.
Also take a look at this question on SO: File upload in Java through FTP
If you still want to implement it yourself, I would recommend using TCP, since it offers you some services:
Ordered data transfer — the destination host rearranges according to sequence number
Retransmission of lost packets — any cumulative stream not acknowledged is retransmitted
Error-free data transfer
http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Data_transfer
This question is too broad, but the answer is probably TCP; if you're needing to transfer a file, TCP provides ordering and retransmission services that UDP doesn't, and there's no reason to reinvent the wheel.
Along those lines, though, why reinvent HTTP? This sounds like a classic case for using a Web server.
UDP programmin but it will be difficult to implement