network-programming

Forgin/Buiilding TCP packets in ANSI C

How do I, without using third-party tools, craft TCP (and even UDP for that matter) packets in ANSI C? I want to be able to set all option flags, source ip address etc. So full control. Haven't found any good text about it online. Or I'm just using the wrong search criteria. ...

how to capture packets in a Windows application that must be installed as non-admin?

Hi, Is it possible to write a Windows app that can capture packets on the PC such that this application can be installed/run as non-admin? If yes, what would be the approach, e.g. which language, which API/Library to use etc (e.g. would it be with the Windows Sockets 2 (Winsock) library?) I've looked at Network Monitor API's however t...

Do I have to enter src and dst mac address in forged packet?

Hi I have started coding a packet injector and read up a bit on what one has to do. One thing I'm wondering though is when I create the IP header the h_source and h_dest fields should contain the mac address of the sender and receiver. Do I have to do this and is there a quick way to find out the mac address of the destination? Let's sa...

building an sk_buff for egress device linux kernel

Long story short, I am trying to build a very bare bones UDP SKB just to get something onto the wire. The scenario is as follows: I have a kernel module loading that (among other things) overrides the memory location of the standard udp_sendmsg function in /net/ipv4/udp.c. From here I would like to construct an skb to the point where ...

Is the received stream from a socket limited to a single send command?

I currently work on a multithreaded application where I receive data using the following (simplified) code: private void BeginReceiveCallback(IAsyncResult ar) { bytesReceived = this.Socket.EndReceive(ar); byte[] receivedData = new byte[bytesReceived]; Array.Copy(buffer, receivedData, bytesReceived); long protocolLength = BitConverter.T...

What do I need to fill in when using IP_HDRINCL

I'm awaiting the arrival of "Linux Network Programming" but in the meantime I thought I'd ask my brothers (and sisters) here for some info. If I have constructed a raw packet structure containing the ethernet header, ip header and tcp/udp/icmp header. What do I actually have to fill in when using the option IP_HDRINCL? At first I thought...

Releasing connection in connectionDidFinishLoading cause bad instruction

According to URL Loading System Programming Guide NSConnection sample code I can release connection in connectionDidFailWithError and connectionDidFinishLoading. However, releasing connection in connectionDidFinishLoading causing objc[19685]: FREED(id): message releaseDelegate sent to freed object=0x3b41630 Program received signal: ...

Packet sniffing in c under window OS

I want to sniff network packets without wincap library, kindly give me some hints or direction so that I can make it possible. ...

How to get MAC address in windows7?

Possible Duplicates: Getting Machines MAC Address Good Solution? How do I get the MAC address of a network card using Delphi? I am using MAC address as hardware id for protection(ofcourse I have encrypted this data) I am using below code to get MAC address on user computer function MacAddress: string; var Lib: Cardinal; F...

Is it possible to implement ping on windows phone 7?

To get the impression of networking capabilities in WP7 I was going to build a simple ping app that would display the result of ICMP ping request to a certain host. However, not only the System.Net.NetworkInformation.Ping class is missing, System.Net.Sockets namespace is missing as well. After a short research I found out that there ar...

Is there a way to get destination mac addres in ANSI C

Is there a way to get the destination MAC address, if the destination IP is known, using ANSI C? I would preferably do it with a system call so the kernel deals with it all and I can take advantage of the ARP cache. I know I can build and send my own ARP request, but then I would not have the caching functionality etc unless I implement ...

Source IP from UDP packet in c under window OS

I want to get the source IP of UDP packet kindly guide me so that I can make it possible. I am working in c under windows platform. ...

What should the destination mac address be set to when sending packet outside of your local network?

If I use arp and arping on machines in my local network I get the mac addresses from them. In the same way I can construct and send a ARP request and collect the response to these machines. This is used since I build raw packets completely from scratchy (to allow spoofing of every possible field, including mac addresses if needed). But, ...

Using WMI to Determine which adapter(s) is connected to the internet

Hi! I am writing a VB Script that uses WMI to determine which adapter is used for internet connectivity? For example - if I have a LAN and a 3G board it needs to tell the user which is connected. I understand that a machine might have >1 internet connection, but for now, let's assume 1. edit: Ok, how can I do this using any command t...

SendToAsync memory leak?

I have a simple .net 3.5sp1 windows application (in C#) that acts as a UDP server. It listens on a port, receives data from an endpoint, and then retransmits what it receives to another endpoint (i.e. a relay, for a live broadcast data stream). What I'm experiencing is after the connection is up for about 20 minutes, it starts to deteri...

How to make perfect client-server communication program using iPhone and C#

Hi, I have built a iPhone application, which capture the voice and streamed to server using NSOutputStream instance. Once the stream stops, iPhone sends a text message as "---end---" to the server and starts to listing on NSOutputStream. When server(built using C#) captured the "---end---" message, it does some processing and write bac...

Getting gateway to use for a given ip in ANSI C

I have looked around like crazy but don't get a real answer. I got one example, but that depended on the individuals own library so not much good. At first I wanted to get the default gateway of an interface, but since different IP's could be routed differently I quickly understood that what I want it get the gateway to use for a given ...

Get ip adresses on a lan with backgroundworker control

I want to get alive or dead ip addresses from a big lan. but it takes so many times. I decided to use backgroundworker here is my code: try { this.Status.Text = "Collecting Information..."; if(this.TxtWorkGroup.Text.Trim() == "") { MessageBox.Show("The Work Group name Should Not be Empty"); return; } ...

Winsock blocking sockets, multithreading deadlock

I have tracked down a deadlock in some code of mine using this reproducer: if( isClient ) { Sender sender; Receiver receiver; ConnectionPtr connection = Connection::create( description ); TEST( connection->connect( )); receiver.start(); Sleep( 100 ); sender.start(); sender.join(); } else { Connectio...

How to specify source port of a UdpPacket?

Hi everybody! I wanted to send UdpPacket to a specific remote host (I already know the public IP and Port). I wanted to use C#'s UdpClient class. static int Main() { UdpClient client = new UdpClient(); IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("1.2.3.4"), 9999); byte[] data = GetData(); client.Send(data,...