Programming :: How To Send And Receive Packets Using Libpcap

Mar 11, 2011

How can I send and receive packets using libpcap, reply as early as possible.

View 1 Replies


ADVERTISEMENT

Networking :: Send / Receive Multiple Raw Packets In One System Call

Aug 27, 2010

I need to receive a number of raw ethernet packets (say, 100 packets) into a user-mode accessible buffer large enough to hold all the packets. The way I have done this so far is by looping over the recvfrom() system call 100 times, passing an incremented pointer addressing the location in my buffer to store the packet. Is there a way to receive the 100 packets into my buffer with one system call, perhaps by instructing the kernel to DMA the 100 packets into my buffer?

View 1 Replies View Related

Debian Programming :: Cannot Receive UDP Packets

May 11, 2015

I am trying to build a socket to retrieve the ethernet packets from ECU(I do not know much about the ECU). When i run my code on windows there is no problem and the code runs correctly. But when i run my code on Debian it gets stuck at s.recv(1024).

I have already set static ip in /etc/network/interfaces as follows:

Code: Select alliface eth0 inet static
address 160.48.199.91
netmask 255.255.255.0
gateway 160.48.199.254

The simple code is as below:

Code: Select all import socket
    import sys
    HOST = "160.48.199.91"
    port = 30490
    s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP)
    s.bind((HOST, 30490))
    while True:
         data = s.recvfrom(1024)
         print(data)

There is no LAN or Router. When i check netstat -s i see that there are 0 UDP and 0 TCP messages received. But when i check in Wireshark on Debian i could see the displayed UDP packets. Does it mean that the UDP packets are reaching the Raspberry Pi but not received by Debian ? Or are these packets being dropped?

View 4 Replies View Related

Programming :: Send UPD Packets To Neighbor Mac Address?

Sep 26, 2010

I want to send Received UDP Packets to neighbor MAC Address. Anyone can guide me to how to do it?

I can received UDP packets and then forward to unicast address as follow: How can i modify this codes (Maybe Last Line) to send the received packets to destination MAC Address instead of destination IPv6 Address?

Code:
int main(int argc, char ** argv)
{
int s,s1;
struct sockaddr_in6 a,a1;

[Code]....

View 8 Replies View Related

Programming :: Socket C++ / Send And Receive Messages In Server?

Jan 2, 2009

I'm trying implement a small server for a university work, my server is creating, binding and listening but it don't accept any connection, these are the files I'm using in server:

Code:

// Definition of the Socket class
#ifndef SOCKET_H
#define SOCKET_H
#include <sys/types.h>
code....

I've made a client just for test it, but no ones run well, the server is always returning -1 when accept is called!!

What should I do to send and receive messages in this server??

View 3 Replies View Related

Programming :: Send /receive Data Through Serial Port In Fedora?

Dec 27, 2010

I am doing work on serial port. I want to send/receive data to/from Microcontrolar through serial port. But I don't know how to initialize, receive and send data to Serial port. i am new in fedora so i hav'nt any deep concept of fedora.can anyone send me C code , which communicate through serial port in fedora (or atleast help me). I am using Fedora 11.

View 6 Replies View Related

Programming :: Perl - UDP Server Receive / Send Packet To Host

Apr 1, 2010

I have found many examples out on the www for creating udp servers with sockets. The problem I am running into is after I receive the packet from a host I need to be able to send a custom made packet(I'm using RawIP / NetPacket to make my packet) back to this host. The only way to do this is seemingly through the send() function. This function however doesn't appear to allow me to specify which host to send my packet to.

View 2 Replies View Related

Programming :: Plan Of Action For Script Which Is Able To Send / Receive Email

Feb 22, 2010

A bit clumsy subject, but I would like to make a script, which is able to send and receive email messages from CLI. The script should work like this:

1. read user input from stdin(for example a mail address)
2. send mail over SMTP(SSL, port 465) to a mail server
3. mail server sends an automatic response, script should just display this response email sent from mail server over IMAP(port 993)

At the moment I have a fallowing configuration in my Thunderbird:

Code:
IMAP mail.domain.com SSL 993
SMTP mail.domain.com SSL 465

Is it possible with 'mail' utility? Do I need to configure some sort of MTA at first(I use SUSE and I have Sendmail installed by default)? What are the steps, to get this script working?

View 1 Replies View Related

Programming :: Write A Program In C That Can Sniff Packets From Ethernet And Distinguish RTP Packets From Non-RTP Packets?

Aug 30, 2010

i need to write a program in c that can sniff packets from Ethernet and distinguish RTP packets from Non-RTP packets, i have no idea what should i do

View 9 Replies View Related

Networking :: Cannot Receive UDP Multicast Packets From Windows

Dec 10, 2008

I've got an application that compiles in Windows and Linux and is using UDP multicast to communicate. I'm running it on a Windows machine, a Linux machine and a small board (Gumstix) that is running Linux as well. The Windows and Linux machines have no problems sending/receiving packets with each other. The Gumstix and Linux machines have no problems sending/receiving packets with each other. The Gumstix can also send/receive packets with two instances of the application both running on the Gumstix.

But when running on the Gumstix I can send udp multicast packets to Windows, but cannot receive them. (It works if I do point to point with a known IP port#, but not multicast.) I can run tcpdump on the Gumstix and see the packets, but they are not being received on my socket. Here's what tcpdump (running on the Gumstix) outputs when sending the same packet from different sources. Notice the IP header ID and flags (don't fragment) are different when coming from Windows.

WINDOWS to Gumstix
-7:-45:-2.015784 IP (tos 0x0, ttl 15, id 35331, offset 0, flags [none], proto: UDP (17), length: 444) 172.30.42.3.1165 > 239.255.183.180.47028: UDP, length 416

LINUX to GUMSTIX
-7:-43:-38.451991 IP (tos 0x0, ttl 15, id 0, offset 0, flags [DF], proto: UDP (17), length: 444) 172.30.42.13.32771 > 239.255.183.180.47028: UDP, length 416

GUMSTIX to GUMSTIX
-7:-33:-10.955608 IP (tos 0x0, ttl 15, id 0, offset 0, flags [DF], proto: UDP (17), length: 444) 172.30.42.110.1025 > 239.255.183.180.47028: UDP, length 416

I've tried everything I can think of to get this to work but am not getting anywhere. Also I'm pretty inexperienced when it comes to Linux. Anything I could try to be able to receive udp multicast packets from Windows?

View 1 Replies View Related

Networking :: What Happens When Machine Receive Unwanted Packets

Mar 5, 2010

Assume this: Machine A sends a packet to machine B, no application in machine B is waiting for the packet, Now: What happens in kernel? What happens to this packet exactly?

View 6 Replies View Related

Networking :: Broadcast Packets Failed To Receive - Socket Beginner

Feb 24, 2011

I am working on uClinux/almost same as Linux. I am new to socket programming. I have two micro controllers running on same code. Simple run with arguments mean send merged string.
run 1st micro controller (Send): ./Name "anystring"
run 2st micro controller (Recive):/Name

My code is:
int receive() {
// Create socket
int sock_fd;
struct sockaddr_in addr;
char buffer[kBufferSize];
int bytes_received=0;
int addr_len = sizeof(addr);
printf("receive start ");
sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
if ( sock_fd == -1 ) {
printf("receive Create ");
// Error occurred return 0; }
printf("Res Create sucee ");
// Create address from which we want to receive, and bind it
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(kPortNumber);
if ( bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0 ) {
printf("receive bind "); // Error occurred return 0; }
printf("Bind Succeful sucee ");
while ( 1 ) {
// Receive a message, waiting if there's nothing there yet
bytes_received = recvfrom(sock_fd, buffer, kBufferSize-0, 0,
(struct sockaddr*)&addr, &addr_len);
if ( bytes_received < 0 ) { // Error occurred
printf("receive bytes "); return 0; }
printf(" bytes_received succeful ");
printf("Ressocketstring : %s ",buffer);
memset(Ressocketstring,0x00 , sizeof(Ressocketstring));
strcpy(buffer,Ressocketstring); printf("Ressocketstring : %s
",Ressocketstring); printf(" ");
printf("Hello Receive finished");
// Now we have bytes_received bytes of data in buffer. Print it!
fwrite(buffer, sizeof(char), bytes_received, stdout); } }
int transmit(char * data, int length) {
int sock_fds[kMaxSockets];
// Obtain list of all network interfaces
/* struct ifaddrs *addrs;
if ( getifaddrs(&addrs) < 0 ) {
// Error occurred return 0; } */
// Loop through interfaces, selecting those AF_INET devices that support broadcast, but aren't loopback or point-to-point
struct sockaddr_in addr; int number_sockets = 0; struct hostent *he;
/* const struct ifaddrs *cursor = addrs;
while ( cursor != NULL && number_sockets < kMaxSockets ) {
if ( cursor->ifa_addr->sa_family == AF_INET
&& !(cursor->ifa_flags & IFF_LOOPBACK)
&& !(cursor->ifa_flags & IFF_POINTOPOINT)
&& (cursor->ifa_flags & IFF_BROADCAST) ) {
// Create socket*/
sock_fds[number_sockets] = socket(AF_INET, SOCK_DGRAM, 0);
if ( sock_fds[number_sockets] == -1 ) // Error occurred {
printf("Error Create "); return 0; }
he = gethostbyname((char *)BCASTADDRESS) ;
if (he==NULL ) {printf("Error gethostbyname ");
herror("gethostbyname"); printf("Error host "); exit(1);
} printf("Res He ");
// Create address from which we want to send, and bind it
memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET;
addr.sin_addr = *((struct in_addr *)he->h_addr);//((struct sockaddr_in *)cursor->ifa_addr)->sin_addr; addr.sin_port = htons(kPortNumber);
if ( bind(sock_fds[number_sockets], (struct sockaddr*)&addr, sizeof(addr)) < 0 )
{ // Error occurred printf("Error bind "); return 0; }
// Enable broadcast int flag = 1;
if ( setsockopt(sock_fds[number_sockets], SOL_SOCKET, SO_BROADCAST, &flag, sizeof(flag)) != 0 ) // Err occur { printf("Error Enable "); return 0; }
number_sockets =1; printf("Succes 1 "); printf("transmit Create ");
// Initialise broadcast address memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_BROADCAST;
addr.sin_port = htons(kPortNumber);
// Send through each interface int i;
for ( i=0; i<number_sockets; i++ ) {
if ( sendto(sock_fds[i], data, length, 0, (struct sockaddr*)&addr, sizeof(addr)) < 0 )
{ printf("Error Send "); // Error occurred return 0;
} printf("Succes 2 "); } return 1; } void MergeMessage( ) {
memset(socketstring,0x00,sizeof(socketstring));
sprintf(socketstring,"%s@%s@%s@%s@%s@%s@%s@%s@%s@%s@%s
",Tmeg.s1,Tmeg.s2,Tmeg.s3,Tmeg.s4,Tmeg.s5,Tm eg.s6,Tmeg.s7,Tmeg.s8,Tmeg.s9,Tmeg.s10,Tmeg.s11);
printf(" MergeSocketMessage : %s ",socketstring); }
int main (int argc, char** argv) {
int fd=0,bdc=0; struct ifreq ifr; printf("Tsarting man ");
fd = socket(AF_INET, SOCK_DGRAM, 0);
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ-1);
ioctl(fd, SIOCGIFADDR, &ifr); close(fd);
memset(MYIP,'-',sizeof(MYIP));
memset(BCASTADDRESS,'-',sizeof(BCASTADDRESS));
strcpy(MYIP, inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
printf("Etho: %s ,len:%d ", MYIP,strlen(MYIP));
for(bdc=strlen(MYIP);MYIP[bdc-1]!='.';bdc--) {}
strncpy(BCASTADDRESS,MYIP,bdc-1); strcat(BCASTADDRESS,".255");
printf("BCASTADDRESS: %s ,len:%d
", BCASTADDRESS,strlen(BCASTADDRESS));
printf("Initial Broad Cast message "); {
/*s0"0" (id=76)
s1"500" (id=77)s2"100" (id=78)s3"100" (id=78)s4"startVD" (id=79)
s5"lighting" (id=80)s6"reading" (id=81)s7"Anna" (id=82)s8"0" (id=76)
s9"";s10"" (id=64)s11"" (id=64)*/
strcpy(Tmeg.s0,"0"); strcpy(Tmeg.s1,"500");strcpy(Tmeg.s2,"100");strcpy(Tmeg.s3,"100");
strcpy(Tmeg.s4,"startvd");strcpy(Tmeg.s5,"lighting");strcpy(Tmeg.s6,"reading");
strcpy(Tmeg.s7,"anna");strcpy(Tmeg.s8,"0"); }
MergeMessage (Tmeg); if( strlen(argv[1]) ) {
//strcpy(socketstring,Tmeg,sizeof(Tmeg));
if(transmit(socketstring, strlen(socketstring) ) ) {
printf(""%s" transmitted. ", socketstring); } else {
printf("Error occurred: %s ", strerror(errno)); return 1; } }
else { for( ; ; ) {
if ( argc < 2 ) // No argument: Just listen {
printf("Listening... "); if ( !receive() ) {
printf("Error occurred: %s ", strerror(errno)); return 1;
} return 0; } } } printf("Finished "); return 0;
} //////////////// .h file is /////////////
//#define WIN32_LEAN_AND_MEAN// Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <fcntl.h>
#include <netdb.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#define SubLen50
//#include <ifaddrs.h>
#include <errno.h>
char MYIP[20];
char BCASTADDRESS[20];
typedef struct {
char s0[SubLen];
char s1[SubLen];
char s2[SubLen];
char s3[SubLen];
char s4[SubLen];
char s5[SubLen];
char s6[SubLen];
char s7[SubLen];
char s8[SubLen];
char s9[SubLen];
char s10[SubLen];
char s11[SubLen];
}msg_struct;
msg_struct Sendmsg;
msg_struct Tmeg; //Recivemsg;
Boolean pri[6];
char socketstring[SubLen*12];
char Ressocketstring[SubLen*12];
int kBufferSize = (SubLen*12);

View 2 Replies View Related

Networking :: Promiscuous Interface And Iptables To Receive Packets Not Destined To Localhost

Mar 22, 2010

I am trying to do something outlandish with iptables (or so I think!).I have a source sending udp packets to a destination (say dst11). Using port mirroring I am able to get all these packets to a different machine (say dst22). I am able to see these packets on dst22 interface using tcpdump.I want to analyze the packets on dst22. So what I do is put dst22 interface in promiscuous mode (using ifconfig eth0 promisc). This in theory should get the packet through the MAC layer. Now using iptables I am trying to DNAT the packets in nat prerouting to change the packets destination IP to dst22's interface and change the destination port.

View 2 Replies View Related

Ubuntu Networking :: Intermittent Internet Connection - Freezes And Doesn't Receive Few Packets

Mar 31, 2010

I'm having problems with my internet connection; it seems to be working fine then every other click of a page there is no connection, then I click it again a second later and it works. I am using a wired network connection plugged into an addon wireless router.

When I use ping under network tools it seems to be fine, then freezes halfway through and doesn't receive those few packets, giving me a transmission percentage of about 70%.

View 2 Replies View Related

Software :: "cannot Stat `libpcap.so.1.0.0':" Error During Make Of Libpcap 1.0.0 On Fedora 9

Apr 6, 2010

I am trying to install Libpcap version 1.0.0 on Fedora 9. During 'make, i get the following error:

"/usr/bin/install: cannot stat `libpcap.so.1.0.0': No such file or directory

make: *** [install] Error 1"

View 4 Replies View Related

Ubuntu :: Evolution Won't Send Or Receive?

Aug 21, 2010

on ubuntu 8.04 and evolution has stopped sending or receiving when click send/receive button. it flashes something but too fast to read. i have renamed mail folder but no go. i have checked settings but no go. i have reinstalled evoulution from synaptic but no go.

i think i have a corrupt file or something like that.

View 1 Replies View Related

Ubuntu :: Receive Mail But Not Send?

May 29, 2010

I was running Ubuntu 9.04, no problems. I did a new installation of 10.04 and could not send or receive mail (Thunderbird). Both would time out. tried two other mail programs to see if Thunderbird was the problem, but they did the same.So I did dual boot installation, with 9.04 and 10.04. The same: mail OK in 9.04 but not in 0.04. So that seemed to eliminate everything as a problem outside of my computer.One night I remembered that ipv6 could be a cause, and toggled it in Thunderbird. It has been an "almost". I can now receive but not send.For example, the bottom bar will say: "Connecting to smtp.edicionescc.com" and after a while time out.I can ping smtp.edicionescc.com with no problem

Jos鼯textarea></p>
<input type='hidden' name='ID[5]' value='74701' />
<input type='hidden' name='URL[5]' value='http://www.linuxquestions.org/questions/linux-

[code]...

View 1 Replies View Related

General :: Can Send But Can't Receive Mail?

Mar 21, 2011

so I'm really new to using Linux, and I searched the forums, but most people seem to have trouble sending mail, not receiving it. When I send mail from the CLI, it gets delivered fine (from travis@travishoward.net) But when I try to reply or mail to the server, I get this message back:

Code:
----- The following addresses had permanent fatal errors ----- <travis@travishoward.net>
(reason: 554 5.7.1 <travis@travishoward.net>: Relay access denied)

[code]...

View 2 Replies View Related

Server :: Cannot Receive/send Email?

May 2, 2011

I used this tutorial to setup to setup iSpconfig postfix courier:but i cannot send or receive email:

Code:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
B450C72116A 595 Mon May 2 17:33:50 www-data@mail.greensevenstudios.com

[code]...

View 2 Replies View Related

CentOS 5 :: Evolution Receive But Won't Send?

Nov 25, 2009

I have it config'd to send and receive on multiple accounts and they all receive email, but SMTP times out and even sends no matter what account I try to send with. I thought maybe security and dropped the firewall and still won't send. No matter which account I try to send to it says its timing out trying access I have no problems on my Mac so no network problems. For grins I install Thunderbird and setup one account and same thing received but no send. What could it be blocking outgoing email??? I have CentOS 5 with all available updates.

View 3 Replies View Related

Fedora Servers :: Can Send But No Receive Mail?

Jun 24, 2009

I have Linux mail server, It always encounter this problem, when i shut down or restart the server. You cannot receive mail but you can send..i use the following services:

iptables -F
service iptables restart
service sendmail restart

[code]...

View 5 Replies View Related

Fedora :: Send And Receive SMS Via CDMA Connection

Jan 3, 2011

How I can send and receive SMS via CDMA Connection. I have tried Gammu (hangs) and Gnome-Phone-Manager (Can't run on GTK3). Gnokii? Well ... I'd like to hear from someone who has succeeded with it on F14. I don't like having to boot into Windows to check my Phone Credits

View 11 Replies View Related

OpenSUSE :: Can't Send Nor Receive Email To Kmail?

Aug 23, 2010

I need help with my K mail I set everything up correctly but it does not send nor recieve email to my kmail. I however did recieve my email to my windows base email through charter internet but not through K mail can

View 2 Replies View Related

OpenSUSE Network :: Can't Send Or Receive Email

Dec 28, 2009

can't send or recieve E-mail. Running postfix , thunderbird squirrel mail. Thunderbird and squirrelmail connect to server but am unable to send or recieve. recieve connection refuses 111 can't open smtp stream. I seen a post mentioning port 25 : 587 for squirrellmail but I do not have exim.conf to update daemon_smtp_ports= 25 : 587 is this located in another file for suse 11.2?

View 3 Replies View Related

Ubuntu :: Cannot Send Or Receive Email Using Thunderbird

May 28, 2010

I'm having trouble to send and receive e-mail using Thunderbird 3. When I tried setting up new account using the automatic configuration method,the result of scanning pop. and smtp. server returned 'none' with this orange circle. I assume it's the same problem that occurred when I first tried to install Evolution. But oddly,I manage to access the web-mail account provided by the ISP using the same information used to set-up Evolution and Thunderbird 3. Precisely I'm from Malaysia and the ISP is Streamyx.com. PC run on Ubuntu 9.10.And I've heard that the ISP is non-friendly of non standard e-mail applications.

View 4 Replies View Related

Ubuntu :: Thunderbird - Can Receive But Not Send Email

Aug 30, 2010

I have a desktop that has been running Ubuntu for years. Finally I convinced my wife to get rid of windows XP and move to Lucid. I did a clean install of Lucid on her system writing over windows. After the install I installed Thunderbird using Synaptic Version 3.0.6 was installed on her system. On my desktop I am also running Thunderbird 3.0.6 We have several domains and mail servers on those domains.

They all use SMTP First, I installed the ISP email and that works perfectly. She can send and receive using our ISP's mail server. I then set up an email account in Thunderbird using the SMTP email server form one of our domains. She used to be able to send and receive from for one of our domains. She can receive email from that email server, but can not send (I can send and receive from the same domain using Thunderbird) Her SMTP and mine are set up identically:

Server Name: mail.[domain]
Port: 50
Username: [user]@[domain]
Secure Authentication: No
Connection Security: No

She is able to receive email but when she tries to send. the connection in Thunderbird either times out. or gives a password error. The password is correct, because we can use Firefox, and go to the pop and log in.Also, she can receive email direct on her computer and has to log in using her password. So I opened Terminal and tested using:

telnet mail.[domain] 50

I got

Trying [IP address]
Connected to mail.[domain]
Escape character is '^']'.
220 mail.[domain]

This leads me to believe something in Ubuntu is blocking her system from using Thunderbird to send emails through the email server. I've been at this for several days now. I did try totally un-installing Thunderbird using Synaptic. Then manually deleting the .Thunderbird file. Then doing a fresh install of Thunderbird using Synaptic. Still get the same results I am thinking that maybe App Armor is stopping this? Or perhaps some other security issue in Ubuntu like Linux Security Module? Otherwise the installation went flawlessly. We even got Skype working on the first try! Printers installed correctly and perfectly too.

View 8 Replies View Related

Ubuntu :: Evolution Send / Receive Tab Greyed Out

Feb 10, 2011

Running Evolution 2.23.3.1 on a laptop with 8.04 installed. (Running 8.04 for good reasons - please don't query). I've been running perfectly for some time, but today when I booted up and opened Evolution to check my mail, the first sign of something odd was that it didn't ask me to unlock the keyring. Then I noticed that the send/receive was greyed out.

I rebooted several times with no change. I've clicked on Permissions in the File menu, but that doesn't then show any window, which is what I would expect, thinking that something has changed. Other than accepting all the usual update manager's recommended installs, nothing has changed on this laptop for several weeks.

View 2 Replies View Related

Ubuntu :: Send / Receive Not Enabled In Evolution

Jul 8, 2011

I have tried setting up my hotmail account in evolution. I followed the steps from the following link: [URL] at the end it said click send receive, but the button is not enabled for me.

View 3 Replies View Related

Ubuntu :: Send/receive Fax Package Via Modem?

Apr 26, 2009

Ubuntu 8.04 workstation
Gnome desktop

What will be the easy way to send/receive fax via modem? Not hylafax, nor efax nor send2fax (the online fax).

View 2 Replies View Related

Networking :: Can't Send And Receive Mails In Evolution

Apr 24, 2010

I am using ubuntu 9.04. I have configured Evolution on my laptop, but it is not working.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved