Raspberry Pi GPRS Connection: Unable to browse after ppp connection is established - raspberry-pi

I have a persistent problem browsing after connecting my GPRS/GSM Module to Raspberry Pi.
I bought the GSM/GPRS Module on amazon at http://www.amazon.com/SainSmart-Small-GPRS-SIM900-Arduino/dp/B00TEUAJMQ/ref=pd_sim_147_4?ie=UTF8&dpID=517DbMGK%2B9L&dpSrc=sims&preST=_AC_UL160_SR160%2C160_&refRID=17HH346MFMXS37D4TX8H.
I have followed the instructions as given on this site
https://learn.adafruit.com/fona-tethering-to-raspberry-pi-or-beaglebone-black?view=all
The results were as expected. I obtained the local and remote IP address needed, i got the DNS addresses too.
Running "ifconfig", i have the result below which clearly shows i can communicate via ppp0.
ppp0 Link encap:Point-to-Point Protocol
inet addr:21.144.145.193 P-t-P:10.64.64.64 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:72 (72.0 B) TX bytes:111 (111.0 B)
The problem now is that i cannot successfully ping any IP address. I keep getting "Networking not reachable" or "unknown host" in case of a url.
More so, the LED light that shows the connection is meant to be blinked twice each second but stops blinking after ppp connection in established.
Please if anyone has a suggestion on what might possibly be causing this, help me out!

Related

Enabling ethernet connection between Teensy 4.1 and intel-NUC

I am trying to establize socket connection between Teensy 4.1 and intel-NUC(Using Ubuntu) directly.
What I tried :
I have connected Teensy 4.1 to my local ethernet switch where my PC and intel-NUC both are connected via ethernet cable. I was able to perform UDP socket communication in between teensy to PC and teensy to NUC both. All works fine.
Problem :
(I am frm electronics background and know very little about networking.)
I dont want to use a switch so I tried to connect Teensy with NUC directly via ethernet cable and the same code doesnt work anymore.
Is it even possible ?
Do I have to make some changes for this to work ?
Teensy is programmed into arduino and in NUC I am using python. Python code I am sharing below.
import socket
UDP_IP = "192.168.10.8" (IP of Teensy)
UDP_PORT = 12345
MESSAGE = b".."
print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s from" % data,end="")
print(addr)
break

Multicast between server and client with or without a router not knowing server IP in advance and possible diferent sub-net

I'm writing in Python software that runs on my Windows (and Linux) PC, while the PC is connected via LAN (with or without a router) to a second device.
The second device sends UDP multicast packets to a known multicast group address and port.
The software in the computer is configured to be part of the same multicast group.
This is working OK as long as both my computer and the server network configuration are on the same sub-net.
Now, most of the times I will don't know the IP of the device in advance and I'll be connecting my computer directly to the server point-to-point. (Imagine the software that comes with IP security cameras that allows you to discover or know the IP of the camera when connecting directly to them with out knowing it in advance and without being in the same sub-net). E.g my computer has IP 169.x.x.x/24 and the server has IP 10.1.1.100 but I do not know the server IP in advance.
For reasons out of my control, the device cannot be configured to be a DHCP server so it cannot assign IP to my computer and cannot use DNS.
How can I receive the UDP multicast packets without raw capture?
This is my current code for the socket configuration that is working when both the computer and the server have the same sub-net. Ex 10.1.1.100/16 and 10.1.1.60/16 but needs to work also as mentioned above.
class MulticastSocket(object):
"""Sends UDP packets to multicast addressses."""
def __init__(self, bind_ip=None):
self._create(bind_ip)
def _create(self, bind_ip):
self.bind_addr = bind_ip
# chosen arbitrary from IANA's Scoped Multicast Range
# https://www.iana.org/assignments/multicast-addresses/multicast-addresses.xhtml#unicast-prefix-based
self.multicast_group = '239.6.2.86'
self.multicast_port = 6286
"""Creates a multicast UDP socket"""
self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
self._sock.settimeout(6)
ttl = 2
self._sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl)
self._sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.bind_addr))
membership_request = struct.pack('4s4s', socket.inet_aton(self.multicast_group),
socket.inet_aton(self.bind_addr))
self._sock.setsockopt(
socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, membership_request)
self._sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if sys.platform == 'linux':
bind_addr = self.multicast_group
else:
bind_addr = self.bind_addr if self.bind_addr else ''
self._sock.bind((bind_addr, self.multicast_port))
def get(self):
"""use to get the socket object to work with the select as select only accept sockets objects"""
return self._sock
def send(self, msg):
return self._sock.sendto(msg, (self.multicast_group, self.multicast_port))
def recv(self, len):
try:
response = self._sock.recvfrom(len)
return response
except socket.timeout:
return "", ""
def close(self):
self._sock.close()

How to send an IP packet to directly connected Peer through broadcast?

let's two machines are directly connected on a Point-to-point link:
A -192.168.4.1/24---------------------------192.168.4.2/24--B
How A can send an IP packet to B through broadcast only ?
if A cooks up the packet with Dest mac = ff:ff:ff:ff:ff:ff and dest ip : 192.168.4.255, Would this make the packet destined to B ? If yes, Can somebody explains how this works ?
I figured out - we can send the packet with dest IP = 192.168.4.255. In addition, set the broadcast privileges on socket using
int on=1;
setsockopt(igmp_sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
It will work.

How to connect through socket to Virtual Machine

I have a java client on Windows and c++ server running on Linux (VM). I'm trying to connect client to the server. But I don't know what IP address I should use.
My Virtual Machine configuration is default, I have NAT network on it.
Here is what I get from ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:97:86:ce
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::8651:2c9d:6683:e4fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:855910 errors:0 dropped:0 overruns:0 frame:0
TX packets:267095 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:940974525 (940.9 MB) TX bytes:24398399 (24.3 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:9710 errors:0 dropped:0 overruns:0 frame:0
TX packets:9710 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:875898 (875.8 KB) TX bytes:875898 (875.8 KB)
And here is what i get from ipconfig:
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Połączenie lokalne* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : home
Link-local IPv6 Address . . . . . : fe80::ddca:c63d:1b9e:6255%14
IPv4 Address. . . . . . . . . . . : 192.168.1.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.254
Ethernet adapter Połączenie sieciowe Bluetooth:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Tunnel adapter Połączenie lokalne* 4:
Connection-specific DNS Suffix . :
IPv6 Address. . . . . . . . . . . : 2001:0:9d38:90d7:10c9:14d5:da7f:e55c
Link-local IPv6 Address . . . . . : fe80::10c9:14d5:da7f:e55c%13
Default Gateway . . . . . . . . . : ::
I tried to connect using:
socket = new Socket("10.0.2.15", 1236);
When Im using client on VM with localhost everything is fine.
So I assume there is a problem with connection between Windows and VM.
you should read https://blogs.oracle.com/scoter/networking-in-virtualbox-v2
Basically, you have to configure the port forwarding. Follow the instructions provided in the link, by the end of the page.
The configuration you shoud use is:
Name: Rule 1 (or any actually)
Protocol: TCP
Host IP: 127.0.0.1
Host Port: 1236
Guest IP: (leave blank)
Guest Port: 1236
The guest port could be any, but must be the same you are using on your server application. Leave the Guest IP blank.
Now, in order to you connect from the host to the guest, you should use in the client application:
socket = new Socket("127.0.0.1", 1236);
If you want to connect from the guest VM to the host machine, using this configuration, you should use in the client application instead:
socket = new Socket("10.0.2.2", 1236);
Alternatively, you could also use the NIC in bridge mode, also explained in the article. But you should configure the router properly.
Btw, don't forget to disable your firewall, or configure it, otherwise it can block the incoming connections.
You can disable ufw using the command:
sudo ufw disable

TCL script cannot configure multicast socket

I'm working with tcl script under ubuntu 12.04, and I'm facing some problem when I try to configure a multicast socket. What I'm trying to do is to forward traffic from some socket to a multicast one, but I don't know why although the multicast socket is created well,apparently; it isn't bound to the multicast group I want to.
This is the script I'm using
#!/bin/sh
# test.tcl \
exec tclsh "$0" ${1+"$#"}
package require udp
set multicastPort "50003"
proc connector {unicastIP multicastIP port {protocol tcp}} {
if { [string equal $protocol "tcp"] } {
socket -server serverTCP -myaddr $unicastIP $port
puts "tcp"
} elseif {[string equal $protocol "udp" ] } {
serverUDP $unicastIP $multicastIP $port
puts "udp"
}
}
proc serverUDP {unicastIP multicastIP port} {
global multicastPort
set socketUDP [udp_open $port]
puts " $unicastIP"
fconfigure $socketUDP -blocking false -translation binary -buffering none -remote [list $unicastIP $port]
#fileevent $socketUDP readable [list gettingData $socketUDP]
set multicastSocket [udp_open $multicastPort]
udp_conf $multicastSocket -ttl 4
fconfigure $multicastSocket -blocking false -translation binary -buffering none -mcastadd $multicastIP -remote [list $multicastIP $port]
fileevent $socketUDP readable [list forwarding $socketUDP $multicastSocket ]
#puts $socketUDP "hello!"
#flush $socketUDP
}
proc forwarding {socketSrc socketDst} {
set data [read -nonewline $socketSrc]
puts "Read data-> $data"
puts -nonewline $socketDst $data
puts "Written data-> [read -nonewline $socketDst]"
}
connector 127.0.0.1 224.0.1.1 50000 udp
vwait forever
However if I run the script and check out the ports in my system, the multicast port is not assigned the proper multicast IP as you can see
~$ netstat -ptnlu
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:50000 0.0.0.0:* 3334/tclsh
udp 0 0 0.0.0.0:50003 0.0.0.0:* 3334/tclsh
Could anyone tell me the reason?
THanks in advance,
Regards!
AFAIK, that is OK. I have a multicast daemon in production using Tcl and its udp package, and netstat and ss tools also show me the socket as listening on the wildcard address.
"The trick" here, I suppose, is that multicasting is one level up the stack: joining a multicast group is not merely opening a socket or an endpoint on the group address but rather sending a very real IGMP "join" message to the local transport segment (Ethernet, in most deployments) and further communicating with the nearby IGMP routers (again, on Ethernet, they're mostly switches).
So, in your case, just fire up tcpdump and see what it dumps when you start your program. A useful call to tcpdump looks something like this:
tcpdump -i eth0 -n 'igmp and host 224.0.1.1'
To observe UDP traffic exchanges use
tcpdump -i eth0 -n 'udp and host 224.0.1.1 and port 50000'