How to simulate tcp/ip network protocol stack in usermode - tcp

I want to simulate tcp/ip network protocol so that I can debug it and learn how it works.I just want to implement a small part of it,but I don't know how to start,what should I do ?
Any help will be grateful...

Learning NS-2 would be a good start: http://www.isi.edu/nsnam/ns/ . This is a popular simulator that is widely used in research/academics and has a rich collection of TCP congestion protocols.

Related

TinyOS UDP support?

Does TinyOS provide support for the UDP protocol ?
We are trying to create an IP Phone using a Micro-controller and were thinking of installing TinyOS on it.
Any help is appreciated!
TinyOS has an IP stack (6lowPan) called BLIP which supports UDP and TCP although I have never used BLIP personally. See the link HERE for more information. A good point to start would be to look at the UDP-echo application in apps folder of the TinyOS distribution.

Transmitting data rate and Receive Window Size

Nowadays, I am making a project relating to protocol communication between 2 FPGA.
When I read information about TCP/IP ethernet, the window receive which the amount data that computer can accept.
And there are a relationship between Window receive and transmitting data rate.
But in my project, I connect two FPGA by Aurora Protocol (Xilinx) not TCP/IP. I wonder that is there definition as window receive for protocol between 2 FPGA ?
I am not good at about electronics as well as networks.
Thanks
I am not much aware of Aurora Protocol (link level), but it is not directly comparable to TCP/IP which is a higher level protocol. See OSI Model.
The TCP/IP sliding window mechanism helps in providing a reliable transmission by controlling the flow of packets between sender and receiver. The Ethernet which is usually the link layer for TCP/IP has its own flow control mechanisms.
Check the section 3 of this document which might give you some insight.

Is MAC (Media Access Control) considered a protocol?

I am currently learning about networking. I am going through the TCP IP and OSI model and try to pick apart what protocol belongs to which layer. I am a bit confused over Media Access Control. Does it just refer to the hardware id of the network card or is it the name of the protocol responsible for it? I tried to find any RFCs for MAC on IETF to provide some definitions for me, but I couldn't find anything.
"MAC" stands for media access control - it's a sublayer of the data link layer (L2) in the OSI model.
One of the most popular protocols in this layer is Ethernet which covers the physical layer and the data link layer. You can find all about Ethernet at IEEE 802.3 (requires registration but is free).
Another extremely popular L1/L2 protocol stack is WiFi (IEEE 802.11) but that's a lot more complicated and hard to start with.
No, the MAC is not a protocol in that you won't find any 'MAC spec' that you can implement. MACs are typically embedded in hardware devices and expose functionality to send and receive frames to the media that they're controlling.
How they expose that functionality is up to the manufacturer of the MAC. They don't follow any standard protocol. You might find simple SPI interfaces, register-based access, DMA transfer or others.

Designing a WLan Receiver

I plan to model a Complete WLAN receiver for IEEE 802.11 b/g/n PHY Layer for completely detecting all the fields in the Packet.
This experiment is for academic purpose only. I am seeking your guidance, how I can build such a model.
Any ideas / pointers for designing such a receiver would be highly helpful for my studies.
Looking forward to hear some interesting ideas.
Thanks
Kiran
With the new 802.11 framework in Linux you can just put an interface into monitor mode, and then capture frames with libpcap. No need for special hacks. Actually you don't even need any programming skills for some experimentation: just put your wlan0 into monitor mode, and start sniffing around with tcpdump.

Linux TCP stack packet injection

Could i inject packets to Linux TCP stack without modifying the ethernet driver? Could i do this with using a library or sth ?
Thank you,
If by 'inject packets to Linux TCP stack' you mean send some data that the Linux kernel will treat as a frame coming from an Ethernet interface then you can use a 'tap' device. If an IP packet (layer 3) is good enough, then use a 'tun' device.
http://en.wikipedia.org/wiki/TUN/TAP
http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/tuntap.txt
Libnet
Libnet is a generic networking API that provides access to several protocols. It is not designed as a 'all in one' solution to networking. Currently many features that are common in some network protocols are not available with Libnet, such as streaming via TCP/IP. We feel that Libnet should not provide specific features that are possible in other protocols. If we restrict Libnet to the minimal needed to communicate (datagram/packets) then this allows it to support more interfaces.
Otherwise, if you're just wondering about injecting hand-crafted packets into the network, read the man pages and look for online help with raw sockets. Some good places to start are man 7 raw, man packet, and there are some ok tutorials at security-freak.net, though the code there is not written particularly well for my tastes.

Resources