Check and Cast error on Omnet++ with INet - casting

I'm trying to send an Udp message from a WirelessHost (Host1) to a StandardHost (Host3) through an AP and a Router, but I get this error message when i run the simulation (i called my network "poi"):
check_and_cast(): Cannot cast 'inet::physicallayer::INoise*' to type
'const inet::physicallayer::NarrowbandNoiseBase *' -- in module
(inet::physicallayer::Ieee80211Radio) poi.router.wlan[0].radio
(id=80), during network initialization
I started using omnet++ with Inet a few days ago, and based my code on tutorials and documentation, but i can't find a solution to this error. Any experience or solution ?
Thank you
This is the .ned code, without import:
network poi {
parameters:
#display("bgb=514,316;bgg=100,1,grey95");
#figure[title](type=label; pos=0,-1; anchor=sw; color=darkblue);
#figure[rcvdPkText](type=indicatorText; pos=380,20; anchor=w; font=,18; textFormat="packets received: %g"; initialValue=0);
#statistic[packetReceived](source=host3.app[0].packetReceived; record=figure(count); targetFigure=rcvdPkText);
submodules:
host1: WirelessHost {
#display("p=403,224");
numWlanInterfaces = 1;
numApps = 1;
}
router: Router {
#display("p=193,224");
numWlanInterfaces = 2;
numEthInterfaces = 2;
numApps = 4;
}
accessPoint: AccessPoint {
#display("p=303,217;r=2000");
}
host3: StandardHost {
#display("p=73,224");
numEthInterfaces = 1;
numApps = 1;
}
integratedCanvasVisualizer: IntegratedCanvasVisualizer {
#display("p=379,57");
}
configurator: Ipv4NetworkConfigurator {
#display("p=104,35");
}
unitDiskRadioMedium: UnitDiskRadioMedium {
#display("p=216,100;r=10000");
}
connections:
accessPoint.ethg++ <--> Eth10G { #display("ls=,0"); } <--> router.ethg[0];
router.ethg[1] <--> Eth10G { #display("ls=,0"); } <--> host3.ethg[0];
}
and the .ini file:
[General]
network = poi
*.host*.ipv4.arp.typename = "GlobalArp"
*.router.ipv4.arp.typename = "GlobalArp"
*.router.app[*].typename = "UdpBasicApp"
*.host1.app[0].typename = "UdpBasicApp"
*.host1.app[0].destAddresses = "accessPoint"
*.host1.app[0].messageLength = 500B
*.host1.app[0].sendInterval = uniform(1ms,10ms)
*.host1.app[0].packetName = "UDPData"
*.host1.wlan[*].radio.radioMediumModule = "unitDiskRadioMedium"
*.router.wlan[*].radio.radioMediumModule = "unitDiskRadioMedium"
*.accessPoint.wlan[*].radio.radioMediumModule = "unitDiskRadioMedium"
*.host*.wlan[*].radio.receiver.ignoreInterference = true
*.host3.app[*].typename = "UdpBasicApp"
*.host*.wlan[0].typename = "AckingWirelessInterface"
*.host*.wlan[0].mac.useAck = false
*.host*.wlan[0].mac.fullDuplex = true
*.host*.wlan[0].radio.transmitter.communicationRange = 500m
*.host*.wlan[0].mac.headerLength = 1B
*.host*.**.bitrate = 1Gbps

Add to your ini file:
**.wlan[*].radio.typename = "UnitDiskRadio"
Besides this you can set unassigned parameters in ini, for example:
**.app[0].destPort = 4000
**.app[0].messageLength= 100B
**.app[0].sendInterval= 1s
**.transmitter.communicationRange = 500m

Related

Sending messages and roadside to roadside (R2R) communication in Veins

I'm new in Omnet Veins. I try to create my own application. So first of all, I have done this in the existing TraciDemo11p files (I have just kept the files name and modify the code).
In the first step, I want to make all nodes sending a HelloMsg (a new packet that I have created .msg .h and .cc).
To well understand how messages are exchanged between nodes, I launched the simulation and all is well, but I cannot realize if the messages are received by nodes or not.
This is a screenshot of what I have:
enter image description here
I followed the transmission of the message between the application, mac and phy layers. I can see that the message is successfully transmitted by node1 for example. But does the message on node[0] "packet was not detected by the card. power was under sensitivity threshold" mean that the packet was not received by node[0]?. If it is the case, how can I fix that? Also, I cannot find the source file of this message (apparently, in PhyLayer80211p.cc or BasehyLayer.cc but I cannot find it).
In the second step, I want to use two RSUs. Nodes broadcast a helloMessage and then each RSU will repeat the received signal. To clarify more, this exactly what I have:
First of all. I add another RSU to the veins example as follows:
##########################################################
# RSU SETTINGS #
# #
# #
##########################################################
*.rsu[0].mobility.x = 6490
*.rsu[0].mobility.y = 1000
*.rsu[0].mobility.z = 3
*.rsu[1].mobility.x = 7491
*.rsu[1].mobility.y = 1000
*.rsu[1].mobility.z = 3
*.rsu[*].applType = "TraCIDemoRSU11p"
*.rsu[*].appl.headerLength = 80 bit
*.rsu[*].appl.sendBeacons = false
*.rsu[*].appl.dataOnSch = false
*.rsu[*].appl.beaconInterval = 1s
*.rsu[*].appl.beaconUserPriority = 7
*.rsu[*].appl.dataUserPriority = 5
Also, I made two maxInterferenceDistance, one of the nodes and the other for the RSUs:
##########################################################
# 11p specific parameters #
# #
# NIC-Settings #
##########################################################
*.connectionManager.sendDirect = true
*.connectionManager.maxInterfDist = 1000m #2600m
*.connectionManager.drawMaxIntfDist = false #false
*.connectionManager.maxInterfDistNodes = 300m
*.connectionManager.drawMaxIntfDistNodes = false
*.**.nic.mac1609_4.useServiceChannel = false
*.**.nic.mac1609_4.txPower = 20mW
*.**.nic.mac1609_4.bitrate = 6Mbps
*.**.nic.phy80211p.sensitivity = -89dBm
*.**.nic.phy80211p.useThermalNoise = true
*.**.nic.phy80211p.thermalNoise = -110dBm
*.**.nic.phy80211p.decider = xmldoc("config.xml")
*.**.nic.phy80211p.analogueModels = xmldoc("config.xml")
*.**.nic.phy80211p.usePropagationDelay = true
*.**.nic.phy80211p.antenna = xmldoc("antenna.xml", "/root/Antenna[#id='monopole']")
To make the transmission range of RSU different on that of nodes, I made this change in the isInRange function of the baseConnectionMannager:
bool BaseConnectionManager::isInRange(BaseConnectionManager::NicEntries::mapped_type pFromNic, BaseConnectionManager::NicEntries::mapped_type pToNic)
{
double dDistance = 0.0;
if ((pFromNic->hostId == 7) || (pFromNic->hostId == 8)) {
EV<<"RSU In range from: "<<pFromNic->getName()<<" "<<pFromNic->hostId<<" to: "<<pToNic->getName()<<" "<<pToNic->hostId<<"\n";
if(useTorus) {
dDistance = sqrTorusDist(pFromNic->pos, pToNic->pos, *playgroundSize);
} else {
dDistance = pFromNic->pos.sqrdist(pToNic->pos);
}
return (dDistance <= maxDistSquared);
} else {
if(useTorus) {
dDistance = sqrTorusDist(pFromNic->pos, pToNic->pos, *playgroundSize);
} else {
dDistance = pFromNic->pos.sqrdist(pToNic->pos);
}
return (dDistance <= maxDistSquaredNodes);
}
}
Where node IDs 7 and 8 are the RSUs in the scenario I run.
In addition, I have the TraciDemo11p (for nodes) and TraciDemoRSU11p (for RSUs) modified as follow:
- In the TraciDemo11p, nodes when enter the network broadcast a Hello message to all their neighbors. The code is:
void TraCIDemo11p::initialize(int stage) {
BaseWaveApplLayer::initialize(stage);
if (stage == 0) {
HelloMsg *msg = createMsg();
SendHello(msg);
}
}
HelloMsg* TraCIDemo11p::createMsg() {
int source_id = myId;
double t0 = 0;
int port = 0;
char msgName[20];
sprintf(msgName, "send Hello from %d at %f from gate %d",source_id, t0, port);
HelloMsg* msg = new HelloMsg(msgName);
populateWSM(msg);
return msg;
}
void TraCIDemo11p::SendHello(HelloMsg* msg) {
findHost()->getDisplayString().updateWith("r=16,green");
msg->setSource_id(myId);
cMessage* mm = dynamic_cast<cMessage*>(msg);
scheduleAt(simTime() + 10 + uniform(0.01, 0.02), mm);
}
void TraCIDemo11p::handleSelfMsg(cMessage* msg) {
if (dynamic_cast<HelloMsg*>(msg)) {
HelloMsg* recv = dynamic_cast<HelloMsg*>(msg);
ASSERT(recv);
int sender = recv->getSource_id();
if (sender == myId) {
EV <<myId <<" broadcasting Hello Message \n";
recv->setT0(SIMTIME_DBL(simTime()));
sendDown(recv->dup());
}
}
else {
BaseWaveApplLayer::handleSelfMsg(msg);
}
}
void TraCIDemo11p::onHelloMsg(HelloMsg* hmsg) {
if ((hmsg->getSource_id() == 7) || (hmsg->getSource_id() == 8)) {
EV <<"Node: "<<myId<<" receiving HelloMsg from rsu: "<<hmsg->getSource_id()<<"\n";
} else {
EV <<"Node: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<"\n";
NBneighbors++;
neighbors.push_back(hmsg->getSource_id());
EV <<"Node: "<<myId<<" neighbors list: ";
list<int>::iterator it = neighbors.begin();
while (it != neighbors.end()) {
EV <<*it<<" ";
it++;
}
}
}
void TraCIDemo11p::handlePositionUpdate(cObject* obj) {
BaseWaveApplLayer::handlePositionUpdate(obj);
}
On the other hand, RSUs just repeat the message they received from nodes. So, I have on the TraciDemoRSU11p:
void TraCIDemoRSU11p::onHelloMsg(HelloMsg* hmsg) {
if ((hmsg->getSource_id() != 7) && (hmsg->getSource_id() != 8))
{
EV <<"RSU: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<" at: "<<SIMTIME_DBL(simTime())<<" \n";
//HelloMsg *msg = createMsg();
//SendHello(msg);
hmsg->setSenderAddress(myId);
hmsg->setSource_id(myId);
sendDelayedDown(hmsg->dup(), 2 + uniform(0.01,0.2));
}
else {
EV<<"Successful connection between RSUs \n";
EV <<"RSU: "<<myId<<" receiving HelloMsg "<<hmsg->getKind()<<" from node: "<<hmsg->getSource_id()<<"\n";
}
}
After the execution of this code, I can see:
a few numbers of vehicles receiving the hello message from their neighbors.
also, just a few messages were received by the two RSUs.
Each RSUs repeats the signal it receives, but there is no communication between the two RSU, which are supposed in the transmission of one another.
And always I have a lot of this message "packet was not detected by the card. power was under sensitivity threshold" printed on my screen.
Is there any problem in the transmission range or it is a question of interference? Also, I would like to mention that in the analysis there is no packet loss.
Thanks in advance.
Please help.

Asmx Web Service Basic Authentication in Asp.net Core Web Application

I created a Asmx Web service and host it in IIS, in MVC, I could call it from below code:
BasicWebService.WebService1 client = new BasicWebService.WebService1();
client.Credentials = new System.Net.NetworkCredential("user", "pwd","domain");
string result = client.HelloWorld();
But, I failed to mark it work under Asp.net Core.
Here is the code what I have tried.
ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient(ServiceReference1.WebService1SoapClient.EndpointConfiguration.WebService1Soap);
client.ClientCredentials.UserName.UserName = "xx";
client.ClientCredentials.UserName.Password = "xx";
//string USER = "xx";
//string PASSWORD = "xx";
//string Domain = "xx";
//NetworkCredential netCredential = new NetworkCredential(USER, PASSWORD,Domain);
////client.Credentials = new System.Net.NetworkCredential("xx", "xx", "xx");
//client.ClientCredentials.Windows.ClientCredential = netCredential;// netCredential.GetCredential(new Uri("http://localhost/WCFBasicSecurity/WebService1.asmx"), "Basic");
ServiceReference1.HelloWorldResponse result =client.HelloWorldAsync().Result;
Got solution from GitHub, thanks for the suggestion from hongdai. Modify the generated reference.cs with below:
public WebService1SoapClient(EndpointConfiguration endpointConfiguration) :
base(WebService1SoapClient.GetBindingForEndpoint(endpointConfiguration), WebService1SoapClient.GetEndpointAddress(endpointConfiguration))
{
this.Endpoint.Name = endpointConfiguration.ToString();
this.ChannelFactory.Credentials.UserName.UserName = "xx\xx";
this.ChannelFactory.Credentials.UserName.Password = "xxxx";
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.WebService1Soap))
{
//Transport Security
System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.Transport);
result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Basic;
result.MaxBufferSize = int.MaxValue;
result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
result.MaxReceivedMessageSize = int.MaxValue;
result.AllowCookies = true;
return result;
}
if ((endpointConfiguration == EndpointConfiguration.WebService1Soap12))
{
System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
textBindingElement.MessageVersion = System.ServiceModel.Channels.MessageVersion.CreateVersion(System.ServiceModel.EnvelopeVersion.Soap12, System.ServiceModel.Channels.AddressingVersion.None);
result.Elements.Add(textBindingElement);
System.ServiceModel.Channels.HttpTransportBindingElement httpBindingElement = new System.ServiceModel.Channels.HttpTransportBindingElement();
httpBindingElement.AllowCookies = true;
httpBindingElement.MaxBufferSize = int.MaxValue;
httpBindingElement.MaxReceivedMessageSize = int.MaxValue;
result.Elements.Add(httpBindingElement);
return result;
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
{
if ((endpointConfiguration == EndpointConfiguration.WebService1Soap))
{
return new System.ServiceModel.EndpointAddress("https://localhost/WCFBasicSecurity/WebService1.asmx");
//return new System.ServiceModel.EndpointAddress("http://localhost/WCFBasicSecurity/WebService1.asmx");
}
if ((endpointConfiguration == EndpointConfiguration.WebService1Soap12))
{
return new System.ServiceModel.EndpointAddress("http://localhost/WCFBasicSecurity/WebService1.asmx");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
Reference:https://github.com/dotnet/wcf/issues/1812

How can I combine my customize module with Omnet++INET's simple module

As all the simple modules' behavior like 80211 mac layer has been defined in the INET module. If I want to add a customize layer between mac layer and network layer to handle network coding. How can I combine the customize module and INET's simple module ?
To add a new module between network layer and MAC layer I suggest creating a modified host in a new project. For OMNeT++ 4.6 and INET 3.2.4 do the following:
Create a new OMNeT++ empty project with src and simulation directories.
In the new project open Properties | Project References and select inet.
Right click on src and select New | Simple module. Call it DummyLayer.ned.
Open DummyLayer.ned and add:
#namespace(inet);
import inet.linklayer.contract.INic;
simple DummyLayer like INic {
parameters:
#display("i=block/buffer");
// here you can add others parameter
gates:
input ifIn;
output ifOut;
input upperLayerIn;
output upperLayerOut;
}
Modify DummyLayer.h and DummyLayer.cc (this module just passes every message from up and down, as well as increments counters):
// DummyLayer.h
#include <omnetpp.h>
namespace inet {
class DummyLayer: public cSimpleModule {
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
private:
int upNumber;
int downNumber;
};
} //namespace
//----------------------------------------------
// DummyLayer.cc
#include "DummyLayer.h"
namespace inet {
Define_Module(DummyLayer);
void DummyLayer::initialize() {
upNumber = 0;
downNumber = 0;
}
void DummyLayer::handleMessage(cMessage *msg) {
if (msg->arrivedOn("upperLayerIn")) {
send(msg, "ifOut");
downNumber++;
} else if (msg->arrivedOn("ifIn")) {
send(msg, "upperLayerOut");
upNumber++;
} else {
error("Incorrect gate");
}
char buf[128];
sprintf(buf, "up: %d, down: %d", upNumber, downNumber);
getDisplayString().setTagArg("t", 0, buf);
}
} //namespace
Create a new compound module for own host, call it WirelessHostEx.ned:
import inet.common.lifecycle.NodeStatus;
import inet.linklayer.contract.IWiredNic;
import inet.linklayer.contract.IWirelessNic;
import inet.linklayer.loopback.LoopbackInterface;
import inet.mobility.contract.IMobility;
import inet.networklayer.contract.IRoutingTable;
import inet.networklayer.common.InterfaceTable;
import inet.networklayer.contract.INetworkLayer;
import inet.power.contract.IEnergyStorage;
import inet.power.contract.IEnergyGenerator;
import inet.applications.contract.IPingApp;
import inet.applications.contract.ISCTPApp;
import inet.applications.contract.ITCPApp;
import inet.applications.contract.IUDPApp;
import inet.transportlayer.contract.ISCTP;
import inet.transportlayer.contract.ITCP;
import inet.transportlayer.contract.IUDP;
import inet.node.inet.INetworkNode;
module WirelessHostEx like INetworkNode
{
parameters:
#networkNode;
#display("i=device/wifilaptop");
#labels(wireless-node);
bool hasStatus = default(false);
int numExtInterfaces = default(0);
int numRadios = 1;
int numTunInterfaces = default(0);
string mobilityType = default(numRadios > 0 ? "StationaryMobility" : "");
string networkLayerType = default("IPv4NetworkLayer");
string routingTableType = default("IPv4RoutingTable");
bool forwarding = default(true);
bool multicastForwarding = default(false);
string energyStorageType = default("");
string energyGeneratorType = default("");
routingTable.forwarding = forwarding;
routingTable.multicastForwarding = multicastForwarding;
*.interfaceTableModule = default(absPath(".interfaceTable"));
*.routingTableModule = default(routingTableType != "" ? absPath(".routingTable") : "");
*.energySourceModule = default(energyStorageType != "" ? absPath(".energyStorage") : "");
*.mobilityModule = default(mobilityType != "" ? absPath(".mobility") : "");
int numTcpApps = default(0);
int numUdpApps = default(0);
int numPingApps = default(0);
bool hasTcp = default(numTcpApps > 0);
bool hasUdp = default(numUdpApps > 0);
string tcpType = default(firstAvailableOrEmpty("TCP", "TCP_lwIP", "TCP_NSC")); // tcp implementation (e.g. ~TCP, ~TCP_lwIP, ~TCP_NSC) or ~TCPSpoof
string udpType = default(firstAvailableOrEmpty("UDP"));
forwarding = default(false); // disable routing by default
networkLayer.proxyARP = default(false);
gates:
input radioIn[numRadios] #directIn;
inout pppg[] #labels(PPPFrame-conn);
inout ethg[] #labels(EtherFrame-conn);
submodules:
status: NodeStatus if hasStatus {
#display("p=50,50");
}
energyStorage: <energyStorageType> like IEnergyStorage if energyStorageType != "" {
parameters:
#display("p=50,100;i=block/plug;is=s");
}
energyGenerator: <energyGeneratorType> like IEnergyGenerator if energyGeneratorType != "" {
parameters:
#display("p=50,150;i=block/plug;is=s");
}
mobility: <mobilityType> like IMobility if mobilityType != "" {
parameters:
#display("p=53,200");
}
networkLayer: <networkLayerType> like INetworkLayer {
parameters:
#display("p=329,287;q=queue");
}
routingTable: <routingTableType> like IRoutingTable if routingTableType != "" {
parameters:
#display("p=53,250;is=s");
}
interfaceTable: InterfaceTable {
parameters:
#display("p=53,300;is=s");
}
lo0: LoopbackInterface {
#display("p=78,406");
}
wlan[numRadios]: <default("Ieee80211Nic")> like IWirelessNic {
parameters:
#display("p=216,406,row,60;q=queue");
}
eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
parameters:
#display("p=368,406,row,60;q=txQueue");
}
ppp[sizeof(pppg)]: <default("PPPInterface")> like IWiredNic {
parameters:
#display("p=558,406,row,60;q=txQueue");
}
tcpApp[numTcpApps]: <> like ITCPApp {
parameters:
#display("p=147,54,row,60");
}
tcp: <tcpType> like ITCP if hasTcp {
parameters:
#display("p=147,141");
}
udpApp[numUdpApps]: <> like IUDPApp {
parameters:
#display("p=329,54,row,60");
}
udp: <udpType> like IUDP if hasUdp {
parameters:
#display("p=329,141");
}
pingApp[numPingApps]: <default("PingApp")> like IPingApp {
parameters:
#display("p=635,141,row,60");
}
dummy: DummyLayer {
#display("p=273,350");
}
connections allowunconnected:
radioIn[0] --> { #display("m=s"); } --> wlan[0].radioIn;
// the order of connections is important here
wlan[0].upperLayerOut --> dummy.ifIn;
dummy.upperLayerOut --> networkLayer.ifIn++;
wlan[0].upperLayerIn <-- dummy.ifOut;
dummy.upperLayerIn <-- networkLayer.ifOut++;
networkLayer.ifOut++ --> lo0.upperLayerIn;
lo0.upperLayerOut --> networkLayer.ifIn++;
for i=0..sizeof(ethg)-1 {
ethg[i] <--> { #display("m=s"); } <--> eth[i].phys;
eth[i].upperLayerOut --> networkLayer.ifIn++;
eth[i].upperLayerIn <-- networkLayer.ifOut++;
}
for i=0..sizeof(pppg)-1 {
pppg[i] <--> { #display("m=s"); } <--> ppp[i].phys;
ppp[i].upperLayerOut --> networkLayer.ifIn++;
ppp[i].upperLayerIn <-- networkLayer.ifOut++;
}
for i=0..numTcpApps-1 {
tcpApp[i].tcpOut --> tcp.appIn++;
tcpApp[i].tcpIn <-- tcp.appOut++;
}
tcp.ipOut --> networkLayer.transportIn++ if hasTcp;
tcp.ipIn <-- networkLayer.transportOut++ if hasTcp;
for i=0..numUdpApps-1 {
udpApp[i].udpOut --> udp.appIn++;
udpApp[i].udpIn <-- udp.appOut++;
}
udp.ipOut --> networkLayer.transportIn++ if hasUdp;
udp.ipIn <-- networkLayer.transportOut++ if hasUdp;
for i=0..numPingApps-1 {
networkLayer.pingOut++ --> pingApp[i].pingIn;
networkLayer.pingIn++ <-- pingApp[i].pingOut;
}
}
An own host module is necessary because StandardHost from INET creates connection between MAC and network layer automatically and it is not possible to add own module between these layers.
Create a network (for test):
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.physicallayer.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;
import inet.node.wireless.AccessPoint;
network WirelessNetwork {
submodules:
configurator: IPv4NetworkConfigurator {
#display("p=33,81");
}
radioMedium: Ieee80211ScalarRadioMedium {
#display("p=33,30");
}
node0: WirelessHostEx {
#display("p=128,121");
}
node1: WirelessHostEx {
#display("p=384,115");
}
ap: AccessPoint {
#display("p=273,54");
}
}
Modify omnetpp.ini:
[General]
network = WirelessNetwork
// node0 will send ping to node1
**.node0.numPingApps = 1
**.node0.pingApp[0].destAddr = "node1" // using IP address here is allowed too
After starting the simulation one can see that in each host dummyLayer send messages forward.

Getting org.xmlpull.v1.XmlPullParserException for SOAP connection in BlackBerry

I am using ksoap2.jar in my application for webservice call.
While conneting, to the server it is giving the below error when i am testing using Wi-fi or simulator:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null#1:0 in java.io.InputStreamReader#6111a1f1)
And when i am testing using SIM Card, it is throwing this error: java.io.InterruptedIOException: Local connection timed out after ~ 120000
I have written the below code for this webservice connection:
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("UserID", "1");
rpc.addProperty("UserName", "xyz");
rpc.addProperty("ContactNo", "9014567890");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
HttpTransport ht = new HttpTransport(serviceUrl + getConnectionString().trim());
ht.debug = true;
System.out.println("debug true ------- ");
ht.setXmlVersionTag(" version=\"1.0\" encoding=\"UTF-8\"?>");
SoapObject response = null;
try
{
ht.call(soapAction, envelope);
response = (SoapObject )envelope.getResponse();
String resultbody = response.getProperty("updateUserDetailResult").toString();
}
catch(org.xmlpull.v1.XmlPullParserException ex2){
resultLbl.setText(ex2.toString());
}
catch(Exception ex){
String bah = ex.toString();
resultLbl.setText(bah);
}
/**
* Looks through the phone's service book for a carrier provided BIBS network
*
* #return The uid used to connect to that network.
*/
private static String getCarrierBIBSUid()
{
net.rim.device.api.servicebook.ServiceRecord[] records = ServiceBook.getSB().getRecords();
int currentRecord;
for (currentRecord = 0; currentRecord < records.length; currentRecord++)
{
if (records[currentRecord].getCid().toLowerCase().equals("ippp")) {
if (records[currentRecord].getName().toLowerCase().indexOf("bibs") >= 0) {
return records[currentRecord].getUid();
}
}
}
return null;
}
/**
* Getting the connection string based on the connection
* #return
*/
public static String getConnectionString()
{
String connectionString = null;
// Wifi is the preferred transmission method
if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
{
connectionString = ";interface=wifi";
}
// Is the carrier network the only way to connect?
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT)
{
String carrierUid = getCarrierBIBSUid();
if (carrierUid == null)
{
// Has carrier coverage, but not BIBS. So use the carrier's TCP
// network
connectionString = ";deviceside=true";
}
else
{
// otherwise, use the Uid to construct a valid carrier BIBS
// request
connectionString = ";deviceside=false;connectionUID=" + carrierUid + ";ConnectionType=";
}
}
// Check for an MDS connection instead (BlackBerry Enterprise Server)
else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
{
connectionString = ";deviceside=false";
}
// If there is no connection available abort to avoid bugging the user
// unnecssarily.
else if (CoverageInfo.getCoverageStatus() == CoverageInfo.COVERAGE_NONE)
{
}
// In theory, all bases are covered so this shouldn't be reachable.
else
{
connectionString = ";deviceside=true";
}
return connectionString;
}
I am using the preverified ksoap jar file(ksoap2-j2me-core-prev-2.1.2.jar).
I am not getting exactly where it is going wrong. I have searched in the forum but did not get the proper solution.
Thanks.

List of windows users remotely

I would like to know how to retrieve the list of users that are logged onto a Remote machine. I can do it with qwinsta /server:xxxx, but would like to do it in C#.
check out wmi in .net under system.management.
something like:
ConnectionOptions conn = new ConnectionOptions();
conn.Authority = "ntdlmdomain:NAMEOFDOMAIN";
conn.Username = "";
conn.Password = "";
ManagementScope ms = new ManagementScope(#"\\remotecomputer\root\cimv2", conn);
ms.Connect();
ObjectQuery qry = new ObjectQuery("select * from Win32_ComputerSystem");
ManagementObjectSearcher search = new ManagementObjectSearcher(ms, qry);
ManagementObjectCollection return = search.Get();
foreach (ManagementObject rec in return)
{
Console.WriteLine("Logged in user: " + rec["UserName"].ToString());
}
You may not need the ConnectionOptions...
I ended up using the qwinsta /server:server1 command from C# -- it was much easier
thanks Ken
All this checks all 8 servers at the same time -- I put the result in sql server
but you can do what ever you want
query_citrix.bat script
cd C:.......\bin\citrix_boxes
qwinsta -server:servername or ip > servername.txt
string sAppCitrixPath = Application.StartupPath.ToString() + "\\citrix_boxes\\";
//Run Script for current citrix boxes
Process proc = new Process();
ProcessStartInfo si = new ProcessStartInfo();
si.FileName = sAppCitrixPath + "query_citrix.bat";
proc.StartInfo = si;
proc.Start();
proc.WaitForExit();
int exitCode = proc.ExitCode;
proc.Close();
if (exitCode == 0)
{
//Execute update who is on the Citrix_Boxes Currently
DirectoryInfo dic = new DirectoryInfo(sAppCitrixPath);
FileInfo[] fic = dic.GetFiles("*.txt");
for (int i = 0; i < fic.Length; i++)
{
ParseQWinStaServerFile(fic[i].FullName.ToString(), fic[i].Name.ToString().ToUpper().Replace(".TXT",""));
File.Delete(fic[i].FullName.ToString());
}
}
private void ParseQWinStaServerFile(string sLocation,string sServer)
{
using (StreamReader sr = File.OpenText(sLocation))
{
string sRecord = String.Empty;
char[] cSep = new char[] {' '};
bool bFirst = true;
while ((sRecord = sr.ReadLine()) != null)
{
if (bFirst == false)
{
string[] items = sRecord.Split(cSep, StringSplitOptions.RemoveEmptyEntries);
//Make sure all columns are present on the split for valid records
if (sRecord.Substring(19, 1) != " ") // check position of user id to see if it's their
{
//Send the user id and server name where you want to.
//here is your user
id = items[1].ToString().ToLower().Trim()
//here is your server
};
}
else
{
bFirst = false;
}
}
}
}