Networking -- Padding of Data - networking

For a homework assignment, I was tasked with creating a "Ping Pong" layer that sits right above the Ethernet stack.
I was able to easily complete the task but when I tested my application over my wireless connection and tried communication with my desktop computer (ethernet) on the same network I found some odd behavior.
It seems like the packet is being padded with information I did not add.
From wireless->ethernet I get something like the following (as a hex output of the data received, taking off the ethernet header, periods are unprintable characters).
3-468...lkin54g......$
0Hl.........*../..2..
When my desktop responds to my laptop (ethernet->wireless) I get something like the following
3-468................
.....................
Is this expected behavior?

Yes. Valid Ethernet frames have a minimum size of 64 bytes (including the Ethernet header and a 4-byte checksum at the end).

When you send packets across the network, the data you are sending is wrapped up into successively larger data structures at each level of the OSI network layer model. When your operating system receives the packets of information, it unwraps the data as it goes up the layers. Reading more about the OSI model could be useful for better understanding.
Here is a picture that illustrates what is going on at each layer, from an ebook.

Related

How to read specific information from a TCP packet

I have a network analyzer written in C that sniffs the packages that transit from a specific network card (something like Wireshark but way simpler)
I have implemented a function where, given the position in memory of the first bit of the packet, shifting my pointer, I can extract information as the IP source and destination. For instance, shifting my pointer from the first bit.
For example, I can read layer 2 moving the pointer of 8 octets to find the MAC destination according to the position described here https://en.wikipedia.org/wiki/Ethernet_frame.
I'm able to do the same thing for the layer 3 and 4 with the TCP protocol (and others) following the table below
Now I would like to read if the packet is using TLS and the port it's using.
For the port, I can't find the position inside the packet.
About the TLS, I've checked with Wireshark and it seems that TLS is always described in the packet with the HEX code 0303 and it's inside the Application layer.
I would like to know if there's a standard encapsulation in the application layer to read information such as Transport Layer Security.
tHANKS

How frames are transfered with OSI or TCP/IP levels

boiz and girlz
I`ve been learning networking for a couple of days, namely about TCP/ip and OSI levels.
And i have a question:
When a frame arives in my LAN from the Internet, it will be decapsulated, so that a router can understand whom he should deliver it to, but doesnt it mean that that frame will no longer contain a Physical level, which wont let it get to its destination? (I can suppose, that after decapsulation that frame will be once again incapsulated on a router, so that it can arrive the destination with Physical level)
As far as i understand, Physical level is a way to transfer frames.
One more thing: "Why does everyone use the 'Packet Loss', when there should be 'Frame Loss(NOT RELATED TO FPS)'?"
//Just want to find out what i`ve missed and missunderstood.
Thanks in advance.
It's called packet loss because it's experienced at the network level (i.e. IP level). What hosts see is just an IP packet disappearing somewhere on the path.
There are actually two way a packet can be lost:
The frame can be lost in transmission at the data link level (for instance, the frame couldn't be transmitted on WiFi successfully because of interference).
The packet could be dropped at the network level (for instance, an IP router is experiencing congestion because the downstream link has insufficient bandwidth).

What happens when ethernet reception buffer is full

I have a quite newbie question : assume that I have two devices communication via Ethernet (TCP/IP) at 100Mbps. In one side, I will be feeding the device with data to transmit. At the other side, I will be consuming the received data. I have the ability to choose the adequate buffer size of both devices.
And now my question is : If data consumption rate from the second device, is slower than data feeding rate at the first one, what will happen then?
I found some, talking about overrun counter.
Is there anything in the ethernet communication indicating that a device is momently busy and can't receive new packets? so I can pause the transmission from the receiver device.
Can some one provide me with a document or documents that explain this issue in detail because I didn't find any.
Thank you by advance
Ethernet protocol runs on MAC controller chip. MAC has two separate RX-ring (for ingress packets) and TX-ring(for egress packets), this means its a full-duplex in nature. RX/TX-rings also have on-chip FIFO but the rings hold PDUs in host memory buffers. I have covered little bit of functionality in one of the related post
Now, congestion can happen but again RX and TX are two different paths and will be due to following conditions
Queue/de-queue of rx-buffers/tx-buffers is NOT fast compared to line rate. This happens when CPU is busy and not honer the interrupts fast enough.
Host memory is slower (ex: DRAM and not SRAM), or not enough memory(due to memory leak)
Intermediate processing of the buffers taking too long.
Now, about the peer device: Back-pressure can be taken care in the a standalone system and when that happens, we usually tail drop the packets. This is agnostics to the peer device, if peer device is slow its that device's problem.
Definition of overrun is: Number of times the receiver hardware was unable to handle received data to a hardware buffer because the input rate exceeded the receiver’s ability to handle the data.
I recommend pick any MAC controller's data-sheet (ex: Intel's ethernet Controller) and you will get all your questions covered. Or if you get to see device-driver for any MAC controller.
TCP/IP is upper layer stack sits inside kernel(this can be in user plane as well), whereas ARPA protocol (ethernet) is inside MAC controller hardware. If you understand this you will understand the difference between router and switches (where there is no TCP/IP stack).

Which network layer is in charge of reassembling fragmented datagrams?

Recently I dug a bit deeper into the matter of network protocols and the OSI model, when noticed, that incoming TCP datagrams (correct me if this is the wrong term) are splitted into several parts, when they exceed a certain size - in this case it's propably my router's MTU. I captured those datagrams using SharpPcap in order to extract some information i am looking for, if you are wondering where I got this information from.
Anyway I was wondering if the reassembly of fragmented packets shouldn't be task of the IP layer, since it definitely provides information to accomplish this (id, fragmentation flags, fragment offset). Furthermore I read, that the TCP layer is to be interpreted as a stream-based protocol. But this actually implies, that it's up to the TCP layer to care about filling the application's buffer the right way, so that the initial piece of information is reconstructed and may be flushed "up" all further layers.
Before I made this observation I actually thought, that the TCP layer should care about reassembling those datagrams, but none of the mentioned layers does...
This leads to the following question(s):
Why are the TCP datagrams I receive not reassembled and what layer SHOULD actually take care about this?
The ip layer handles fragmentation and reassembly, http://en.wikipedia.org/wiki/IP_fragmentation.
When you use a tool like SharpPcap that uses winpcap/airpcap/libpcap, you are receiving the raw datagrams from the device you are capturing on. For many adapters this is an ethernet datagram that then contains an ip frame etc.
This is in contrast to data received after processing by the networking stack, where the reassembly is performed.
So, its expected that you won't get reassembled datagrams from SharpPcap (or many other capture libraries) because the data is being captured at the adapter level, not inside of our as an output of the networking stack that is performing reassembly.
You can perform the reassembly after capture either yourself or using a library that provides this functionality. You could also add such a component to Packet.Net (the packet processing library that SharpPcap is using) to provide this reassembly.

Command to transmit Data over wlan

I am doing some experiment for which I need to collect Data from wlan driver.
I am interested in transmitting IEEE 802.11b Packets with more flexibility in terms of Data Rate, Packet Size etc.
Basically, I will have the laptop as the transmitter and I have built a custom receiver for IEEE 802.11b which would read the packets ( IEEE 802.11b 1/2/5.5 or 11Mbps) .
So, I am looking at some Linux tool which gives the option of setting these parameters while transmitting data.
I am thinking at commands like iwpriv to set the parameters for the wireless driver, and iperf commands to generate Traffic.
I am not sure, how to use them to achieve a Data traffic, say 1Mbps / and 1024 Bytes PSDU (Packet Size).
The receiver is a dedicated hardware ( not a Computer). Any suggestion or idea in this direction would be helpful.
Thanks
Use wireshark or pcap (via perl,python etc) to capture what you want.
You may be better off asking this on Server Fault. I found a couple of packet generators that look like they could do what you need but I'm by no means an expert.
packETH:
you can create and send any ethernet packet [...]
sending sequence of packets
delay between packets, number of packets to send
sending with max speed, approaching the teoretical boundary
change parameters while sending (change IP & mac address, UDP payload, 2 user defined bytes, etc.)
Ostantino:
Modify any field of any protocol (some protocols allow changing packet fields with every packet at run time e.g. changing IP/MAC addresses)
[...]
Configure stream rates, bursts, no. of packets
I found these in the Wireshare Wiki where there are a number of other tools that may help.

Resources