Questions tagged [packets]

Packets refer to network packets. A network packet is a formatted unit of data carried by a packet-switched network.

A network packet is a formatted unit of data carried by a packet-switched network.

A packet consists of control information and user data, which is also known as the payload. Control information provides data for delivering the payload, for example: source and destination network addresses, error detection codes, and sequencing information. Typically, control information is found in packet headers and trailers.

Use this tag for programming questions related to packet creation, packets contents analysis, packet sending and receiving, or other tasks that can be done with network packets.

Source: Wikipedia

374 questions
29
votes
5 answers

If TCP is connection oriented why do packets follow different paths?

According to my knowledge if an internet application has to be designed, we should use either a connection-oriented service or connection-less service, but not both. Internet's connection oriented service is TCP and connection-less service is UDP,…
Assasins
  • 1,483
  • 5
  • 18
  • 21
22
votes
1 answer

TCP packet won't get from Russia to Canada when data starts with '1c'

We have a TCP stream protocol where we prefix our data payload by the size. So the data can be properly decoded when received. Pretty standard stuff. This is working fine for thousands of people. Unfortunately we have at least 4 reported cases of…
Spish
  • 513
  • 3
  • 6
21
votes
7 answers

How bad it is to keep calling malloc() and free()?

I'm sending a text file - client-server breakup the text into packets each of 512 bytes but some packets contain text less than max size so on the servers side when receiving each packet I'm calling malloc() to build a string again , is this a bad…
cap10ibrahim
  • 567
  • 1
  • 5
  • 16
18
votes
3 answers

Network UDP broadcast design?

I am working on a C++ server/.NET client applications couple in which my server (which runs the c++ on linux) broadcasts a message to show it's alive to the whole network and my .NET program listens for packets and parses to get the uptime of the…
Andrei Zisu
  • 3,942
  • 4
  • 18
  • 32
16
votes
7 answers

Object-oriented networking

I've written a number of networking systems and have a good idea of how networking works. However I always end up having a packet receive function which is a giant switch statement. This is beginning to get to me. I'd far rather a nice elegant…
Goz
  • 58,120
  • 22
  • 114
  • 192
12
votes
2 answers

How to calculate packet time from latency and bandwidth

I have a link between a host and a switch. The link has a bandwidth & a latency. How to calculate the time of 2 packets(with size 1KB) to be transferred from Host A to Switch 1? Here's the diagram(I am talking about the first link) Note: I just…
MhdSyrwan
  • 1,441
  • 3
  • 18
  • 25
9
votes
5 answers

Packet loss while receiving UDP broadcast in android device

For receiving UDP broadcast packets from the server to an android device, i used a service class and listen for packets in a thread. It receives the packet successfully. The problem is that if multiple packets are being sent from the server in the…
George Thomas
  • 4,178
  • 4
  • 27
  • 58
8
votes
0 answers

Android: Set up a local VPN, used to intercept packets

I want to intercept packets and get the IP/Port numbers, along with the PID/UID of the connection. Things I'm thinking about and what not below... VpnService: When using the app tPacketCapture, you can clearly see that they start a VpnService. …
Justin Warner
  • 789
  • 2
  • 9
  • 18
7
votes
3 answers

When I send a packet over tcp, it is split into two packets

I am developing an application in C#, using the server-client model, where the server sends a byte array with a bitmap to the client, the client loads it into the screen, sends an "OK" to the server, and the server sends another image, and so…
Joao Oliveira
  • 203
  • 1
  • 5
  • 8
7
votes
4 answers

When do USB Hosts require a zero-length IN packet at the end of a Control Read Transfer?

I am writing code for a USB device. Suppose the USB host starts a control read transfer to read some data from the device, and the amount of data requested (wLength in the Setup Packet) is a multiple of the Endpoint 0 max packet size. Then after…
David Grayson
  • 71,301
  • 23
  • 136
  • 171
7
votes
4 answers

TCP/IP packets and datagrams

Is it true that upon receiving a segment from Transport Layer(TCP) towards Network Layer(IP) the resulting data unit will be a packet. Whereas when receiving a user datagram from Transport Layer(UDP) the resulting data unit will be a datagram?
user1927452
  • 73
  • 1
  • 1
  • 4
6
votes
1 answer

Sending arbitrary (raw) packets

I've seen it asked elsewhere but no one answers it to my satisfaction: how can I receive and send raw packets? By "raw packets", I mean where I have to generate all the headers and data, so that the bytes are completely arbitrary, and I am not…
Seth Carnegie
  • 70,115
  • 19
  • 169
  • 239
6
votes
2 answers

Debian 7.11 - How to capture SMPP all arrived and sent packets by some ports

I'm using following code for capturing incoming and outgoing tcp packets by ports: tcpdump -i any -s 0 -vvv -A port 3727 or port 5016 or port 3724 -w /home/admin/dump1.cap But tcpdump captures only incoming packets, I need incoming and outgoing…
mr.boyfox
  • 12,894
  • 5
  • 51
  • 75
6
votes
1 answer

C code to generate and send a packet

I would like to know about the inbuilt library functions in C to build a complete packet(along with frame) and to send it over a network... Can any one upload the C code which does the above stuff... :)
M.S Balagopal
  • 217
  • 2
  • 3
  • 6
6
votes
1 answer

Having trouble building a Dns Packet in Python

I'm trying to build a dns packet to send over a socket. I don't want to use any libraries because I want direct access to the socket variable that sends it. Whenever I send the DNS packet, wireshark says that it's malformed. What exactly am I doing…
MonkeyBa
  • 85
  • 1
  • 5
1
2 3
24 25