Send a single byte through netcat - not first packet - tcp

I have a simple question, how do I send a single byte through netcat ?
This is not the first message, first message is sent by the server to the client. So I cannot pipe echo to netcat.
What can I do ?
Thanks

Related

IPv6 Logo certification Test case v6LC.4.1.12: Validate Packet Too Big

I have asked one question already related what is the purpose of payload in Packet Too Big ICMPv6 message. why_PTB_payload
As per the latest IPv6 logo certification I have came across this test case where a sender send ICMPV6 echo request message to destination having some routers in between and the receiver (destination) received the echo request.
then,
Receiver send ICMPv6 echo reply but got ICMPV6 packet too big message from router in between with wrong/forged echo reply header appending to the (PTB) packet too big message as a payload. (Deliberately sending wrong payload).
Again the ICMPv6 echo request sent by the sender, now the receiver start fragmenting the echo reply because of the above step1 (i.e without validating the PTB payload the Receiver changed it's MTU value).
According to the test case we should not change the MTU on receiving the wrong or forged payload on PTB message (payload will be the original packet that cannot be forwarded due to less Path MTU)
But this look unnecessary work to validate the PTB for echo reply and seems no proper use-case, this test case look invalid to me as we never store the state of echo reply sent by the kernel to validate the PTB in case PTB carry the wrong ICMPv6 reply header on it's payload.
If this is the valid case then I want to know the logic how we can implement this or if not then why this test case is even there at the IPV6 logo certification.
Link to the document containing the test case IPv6LogoCertificationTestCases (Test case number v6LC.4.1.12)

UDP packet bytes read granularity?

I have UDP client and server apps, and custom protocol over UDP.
Each "protocol packet" contains header with size of payload, and payload by itself .
Each "protocol packet" not exceed MTU size, with expectation of lack of fragmentation .
Currently I'm using ASIO library and experiencing some problem:
Time diagram :
client send header (2 bytes) and payload (N < MTU-2 bytes) ------>
server reads only 2 bytes, to be sure about payload size.
server receive header with size of payload
server TRIED to receive N bytes of payload .....
and nothing . Completion handler never occurs .
If client send (for debug purposes) one more packet, server completion handler is fired - what's why I think my async loop of asio is ok .
Also if server tried to read whole transmission 2+N bytes per one read ,
all data received .
So I'm little bit confused . It is possible to read separate bytes of one UDP datagram sequentially by executing _socket.async_receive_from() sequentally.
Will be glad for help,
Thanks in advance .
It is possible to read separate bytes of one UDP datagram sequentially by executing _socket.async_receive_from() sequentally.
If this is a statement it is incorrect, and if it's a question the answer is 'no'. UDP is a datagram protocol.You get the entire datagram or nothing at all. If you read part of it the remainder is discarded.
Possibly you are looking for readv() or recvmsg(), which allow you to scatter-read.

Wireshark anlayse packet data TCP/IP

I'm using wireshark for the first time.
I run a client program that sends a command to server but the server response length is zero. I need to anlayse packets sent back from the server using wire shark in order to understand the problem
How can I see what is the size of data sent in a packet & what is the
data (human readable string) sent to destination using wireshark.
Please guide I'm new to networking and wireshark.
Thank you
I recommend this page for a guide on wireshark: Wireshark guide
I found the solution .Since, I'm using TCP .
Click the packet you want to analyse
See description- goto tcp
Under TCP click on data to see size of data and its value

What network layer handles responding to pings?

I've been learning about TCP and UDP lately, and I know that ping uses ICMP so I'm trying to understand that too. My understanding is that when the command ping google.com is run, your computer sends an echo request ICMP packet over IP to google, and then google responds with an echo reply message.
My question is, when a server responds with that echo reply message, what is actually taking care of that? Is it the operating system? Is it a particular application? Or is it something else entirely?
Its the Kernel module which responds the ICMP requests. The ICMPv4 module is net/ipv4/icmp.c.
The ICMP module defines a table of array on how to handle various ICMP requests with object being icmp_objects, named icmp_pointers which is indexed by ICMP message type.
ICMP control structure:
struct icmp_control {
void (*handler)(struct sk_buff *skb);
short error; /* This ICMP is classed as an error message */
};
static const struct icmp_control icmp_pointers[NR_ICMP_TYPES + 1] = {
...
[ICMP_ECHO] = {
.handler = icmp_echo,
},
...
};
From above struct, when you send a echo request to google.com server the message type will be icmp_echo boiling down to subroutine call icmp_echo() which handles echo (ping) requests (ICMP_ECHO) by sending echo replies (ICMP_ECHOREPLY) with
icmp_reply().
In terms of the TCP/IP reference model it is the Network layer of the protocol stack, which is normally in the kernel.

Building a webserver, client doesn't acknowledge HTTP 200 OK frame

I'm building my own webserver based on a tutorial.
I have found a simple way to initiate a TCP connection and send one segment of http data (the webserver will run on a microcontroller, so it will be very small)
Anyway, the following is the sequence I need to go through:
receive SYN
send SYN,ACK
receive ACK (the connection is now established)
receive ACK with HTTP GET command
send ACK
send FIN,ACK with HTTP data (e.g 200 OK)
receive FIN,ACK <- I don't recieve this packet!
send ACK
Everything works fine until I send my acknowledgement and HTTP 200 OK message.
The client won't send an acknowledgement to those two packages and thus
no webpage is being displayed.
I've added a pcap file of the sequence how I recorded it with wireshark.
Pcap file: http://cl.ly/5f5/httpdump2.pcap
All sequence and acknowledgement numbers are correct, checksum are ok. Flags are also right.
I have no idea what is going wrong.
I think that step 6. should be just FIN, without ACK. What packet from the client are you ACKing at that place? Also I don't see why 4. should be an ACK instead of just a normal data packet - the client ACKed the connection at 3.
This diagram on TCP states might help.
WireShark says (of the FIN packet):
Broken TCP: The acknowledge field is
nonzero while the ACK flag is not set
I don't know for sure that's what's causing your problem, but if WireShark doesn't like that packet, maybe the client doesn't either. So, it should be FIN+ACK, or you should set the acknowledge field to 0.
If that doesn't solve it, you might also try sending the data first, then a separate FIN packet. It's valid to include data with the FIN, but it's more common to send the FIN by itself (as seen in the other pcap trace you posted earlier).
Also, you should probably be setting the PUSH flag in the packet with the 200 OK
Finally, I don't see any retransmission attempts for the FIN packet - is that because you stopped the capture right away?
The IP length field was consequently counting 8 bits too much. I made a mistake in my calculations. Everythings works like a charm now!

Resources