how can I implement IP in IP protocol (IP encapsulation) in c++? - sockets

I want to route my tcp packet from A to B through C.
I am new to network programming and some code samples will be very helpful.
Is there a way to do it through boost library?

how can I implement IP in IP protocol
Read the C++11 standard n3337. IP is not even mentioned there.
So you cannot implement IP in IP in standard hosted C++ code.
However, your device or computer might run some Linux kernel (e.g. on RaspBerryPi). Then you should read Advanced Linux Programming and syscalls(2), proc(5) and ip(7) and iptables(8) and several Linux HowTO-s
Is there a way to do it through boost library?
Did you read the documentation of boost? Did you consider using POCO or Qt libraries ?

Related

Documentation of STM32F3 for Ethernet/TCP-IP

I want to use Ethernet TCP-IP communication between an STM32F3 and a computer.
I am using an ENC28J60 module for this. But all the codes I've tried do not work. Where can I find documentation for this communication?
Resources I've used:
https://github.com/xukai871105/uip_freemodbus_tcp (I changed it to STM32F3 but the communication didn't succeed).
https://github.com/search?q=enc28j60+tcp+stm32

How to Send AT commands to SIM900 while pppd is running

I have a Raspberry pi with SIM900 GSM module. currently i am using ttyUSB0 as pppd but i also want to send AT commands (send/receive SMS) to SIM900 while pppd is active. I was created multiple virtual serial ports (like gsmtty1,gsmtty2 etc) but those are not working with screen/minicom.
While these virtual serial ports might work (assuming you are talking about the kernel's 07.10 multiplexing support), your first attempt should be to use the other serial device, e.g. /dev/ttyUSB1.
This is assuming the modem provides two serial endpoints, which it is not absolutely required to do, but virtual all modems that support USB does, so I would be very surprised if it really only had one.
Notice that the 07.10 multiplexing protocol requires explicit command and implementation support from the modem and is specified in a 3GPP specification which was created in the 90-ties to cater for the lack of multiplexing in the serial interfaces that were in use at that time (RS-232, IrDA, bluetooth).
But it required dedicated driver support on the operating side, and for windows there was no default drivers supplied so you had to install something additional (and I think the quality of those were not so great either) so 07.10 never got any serious momentum. Today USB's native multiple endpoint support have in many ways obsoleted the 07.10 protocol.

Is there a socket wrapper around winsock kernel (WSK, not winsock2)?

I need to upgrade a Windows Kernel Mode Driver from IPV4 to IPV4/IPV6 but the existing kernel mode socket library which uses TDI does not support IPV6.
So I would like to change the socket library to "Winsock Kernel" http://msdn.microsoft.com/en-us/library/windows/hardware/ff571084(v=vs.85).aspx
Note: This is not winsock2.
I started making the necessary modifications to use WSK instead of Kernsock from Storagecraft but there is a lot to consider given that this driver code runs on both windows and linux.
I am wondering if there is a kernel mode socket wrapper around WSK available, preferably with BSD or winsock2 function API signatures. My searches do not yield anything.
Thanks.
I found one UDP code project which seems to provide most of what I need.
I thought I would post it here for anyone else who needs a WSK wrapper.
Project:
https://code.google.com/p/wskudp/
UDP Source:
https://code.google.com/p/wskudp/source/browse/#svn%2Ftrunk%2Fwskudp
TCP Source:
https://code.google.com/p/wskudp/source/browse/#svn%2Ftrunk%2Fwsktcp
Thanks to https://code.google.com/u/x86ddk/ for creating the project.
NOTE: I haven't tested this yet.

How to capture loopback traffic in Windows Server 2008

Setup:
I have client C connecting to server S
Both C and S are on the same machine
In C the server address is hardcoded to 127.0.0.1. Likewise, in S the client address is hardcoded to 127.0.0.1
Problem:
I want to be able to sniff the traffic between the client and the server.
Due to the configuration, I cannot move the client nor the server to different locations (the address are hardcoded)
Installing the loopback interface and using tools like Wireshark+WinPcap doesn't lead anywhere (was actually already known but was worth a try)
RawCap, suggested in another topic, doesn't work. IP 127.0.0.1 is listed, but does not record any traffic.
Using rinetd to route the traffic elsewhere, as suggested here doesn't work (cannot bind on 127.0.0.1)
Not interested in using a HTTP local proxy, such as Fiddler, because I'd like to capture also other protocols
Two commercial tools work, specifically CommView and Local Network Monitor, which means it must be possible to do that ;)
How can I do to capture the traffic?
Any pointer on functions I should use or documentation I should read?
Thanks!
Basically you need to write a TDI filter driver to achieve that... for some pointers see:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff565685%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/hardware/ff563317%28v=VS.85%29.aspx
Another option is to write a WinSock LSP.
BEWARE
Since Windows 8 it is strongly encouraged to use WFP (Windows Filtering Platform) for this sort of thing...
Although it might be more cost-effective to just use/buy an existing solution - esp. if you are not a very experienced driver developer...
Use RawCap, which can solve your concerns, see this

Stun and P2P communication in C#

I'm new to network programming. I want to traverse NAT using Stun. I use the Stun client application defined in code project Stun Client. It returned me a mapped IP and port. But I don't know how to use the IP and port for P2P communication in C#.NET.
Please help me. Any help will be appreciated.
If you're looking for some general background to get you started, look at this related question:
.NET and P2P - writing a P2P messenger
HI all
we found that, we can traverse NAT using vs2010 (.net4.0) . there is a method AllowNATTraversal(bool value). set the value true for NAT Traverse. It uses Ipv6 adsdress for connectivity. You can get Ipv6 global address from teredo server by writing some comands in command prompt.