First request for Okta authentication taking a lot of time - spring-boot

I am using Okta authorisation server for securing spring boot app.
Have configured the below 3 property
okta.oauth2.issuer={URI}
okta.oauth2.client-secret={SECRET}
okta.oauth2.client-id={CLIENTID}
Have protected the endpoint using the below code in Spring boot.
#Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
Okta.configureResourceServer401ResponseBody(http);
return http
.csrf(spec -> spec.disable())
.authorizeExchange().pathMatchers("/api/**").permitAll()
.anyExchange().authenticated().and()
.oauth2Login()
.and()
.oauth2ResourceServer()
.jwt().and().and().build();
}
However when I issue the first request to any protected endpoint by passing bearer token it takes a lot of time almost 1min. The subsequent request taken Milliseconds.
From the log I can see the DNS resolution (io.netty.resolver.dns.DnsNameResolver) in the first request are taking a lot of time almost 40 Seconds. The application is of type Web in Okta.
The application is running on Netty server.
Any suggestion to fix this?
I was able to debug and find that on windows 10, JDK 11 the Netty DnsQueryContext takes 5 seconds to resolve DNS whereas the same in macOS or linux happens in milliseconds.
I tried to disable Netty as default server and use tomcat but even then the Netty DNS resolver starts when a incoming request is sent. I need to have Netty on my class path for WebClient to work.
It looks like a issue with Netty as I was able to reproduce the issue with the below code on windows but the same code works fine on macOS.
#SpringBootApplication
public class GqlApplicationStarter {
public static void main(String[] args) throws UnknownHostException, ExecutionException, InterruptedException {
// SpringApplication.run(GqlApplicationStarter.class, args);
NioEventLoopGroup group = new NioEventLoopGroup(1);
DnsNameResolver resolver = new DnsNameResolverBuilder(group.next())
.channelFactory(NioDatagramChannel::new)
.optResourceEnabled(false)
.build();
try {
System.out.println("2" + resolver.resolveAll("dev-542348.okta.com").get());
}
finally {
resolver.close();
group.shutdownGracefully();
}
}
Below are the logs from Windows.
13:11:27.823 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[53282: /10.150.1.252:53], DefaultDnsQuestion(dev-542348.okta.com. IN
A) 13:11:27.830 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.maxCapacityPerThread: 4096 13:11:27.831 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.ratio: 8 13:11:27.831 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.chunkSize: 32
13:11:27.831 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.blocking: false 13:11:27.834 [nioEventLoopGroup-2-1] DEBUG io.netty.buffer.AbstractByteBuf -
-Dio.netty.buffer.checkAccessible: true 13:11:27.834 [nioEventLoopGroup-2-1] DEBUG io.netty.buffer.AbstractByteBuf -
-Dio.netty.buffer.checkBounds: true 13:11:27.834 [nioEventLoopGroup-2-1] DEBUG
io.netty.util.ResourceLeakDetectorFactory - Loaded default
ResourceLeakDetector: io.netty.util.ResourceLeakDetector#14896267
13:11:32.859 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[10561: /10.202.1.252:53], DefaultDnsQuestion(dev-542348.okta.com. IN
A) 13:11:37.868 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[40341: /10.180.1.20:53], DefaultDnsQuestion(dev-542348.okta.com. IN
A) 13:11:42.880 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[10043: /10.180.1.201:53], DefaultDnsQuestion(dev-542348.okta.com. IN
A) 13:11:47.892 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[28012: /10.180.1.202:53], DefaultDnsQuestion(dev-542348.okta.com. IN
A) 13:11:52.898 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[8689: /180.235.155.185:53], DefaultDnsQuestion(dev-542348.okta.com.
IN A) 13:11:53.045 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsNameResolver - [id: 0xc4d4fa95] RECEIVED: UDP
[8689: /180.235.155.185:53], DatagramDnsResponse(from:
/180.235.155.185:53, to: /0.0.0.0:56937, 8689, QUERY(0), Refused(5),
RD) DefaultDnsQuestion(dev-542348.okta.com. IN A) 13:11:53.045
[nioEventLoopGroup-2-1] DEBUG io.netty.resolver.dns.DnsQueryContext -
[id: 0xc4d4fa95] WRITE: UDP, [43413: /192.168.1.1:53],
DefaultDnsQuestion(dev-542348.okta.com. IN A) 13:11:53.171
[nioEventLoopGroup-2-1] DEBUG io.netty.resolver.dns.DnsNameResolver -
[id: 0xc4d4fa95] RECEIVED: UDP [43413: /192.168.1.1:53],
DatagramDnsResponse(from: /192.168.1.1:53, to: /0.0.0.0:56937, 43413,
QUERY(0), NoError(0), RD RA) DefaultDnsQuestion(dev-542348.okta.com.
IN A) DefaultDnsRawRecord(dev-542348.okta.com. 300 IN CNAME 25B)
DefaultDnsRawRecord(ok11-crtrs.tng.okta.com. 202 IN CNAME 66B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41957 IN
NS 23B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41957 IN NS
25B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41957 IN NS 21B)
DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41957 IN NS 22B)
13:11:53.175 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[61505: /10.150.1.252:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:11:58.185 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[46866: /10.202.1.252:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:03.187 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[39078: /10.180.1.20:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:08.196 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[50281: /10.180.1.201:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:13.208 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[53416: /10.180.1.202:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:18.214 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[19383: /180.235.155.185:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:18.320 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsNameResolver - [id: 0xc4d4fa95] RECEIVED: UDP
[19383: /180.235.155.185:53], DatagramDnsResponse(from:
/180.235.155.185:53, to: /0.0.0.0:56937, 19383, QUERY(0), Refused(5),
RD)
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:18.320 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0xc4d4fa95] WRITE: UDP,
[39446: /192.168.1.1:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:12:18.367 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsNameResolver - [id: 0xc4d4fa95] RECEIVED: UDP
[39446: /192.168.1.1:53], DatagramDnsResponse(from: /192.168.1.1:53,
to: /0.0.0.0:56937, 39446, QUERY(0), NoError(0), RD RA)
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
34 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
34 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
34 IN A 4B) 2[dev-542348.okta.com/3.15.36.194,
dev-542348.okta.com/3.15.36.192, dev-542348.okta.com/3.15.36.193]
And below are the logs from MACOS
13:23:20.937 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.maxCapacityPerThread: 4096 13:23:20.937 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.ratio: 8 13:23:20.937 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.chunkSize: 32
13:23:20.937 [nioEventLoopGroup-2-1] DEBUG io.netty.util.Recycler -
-Dio.netty.recycler.blocking: false 13:23:20.941 [nioEventLoopGroup-2-1] DEBUG io.netty.buffer.AbstractByteBuf -
-Dio.netty.buffer.checkAccessible: true 13:23:20.941 [nioEventLoopGroup-2-1] DEBUG io.netty.buffer.AbstractByteBuf -
-Dio.netty.buffer.checkBounds: true 13:23:20.941 [nioEventLoopGroup-2-1] DEBUG
io.netty.util.ResourceLeakDetectorFactory - Loaded default
ResourceLeakDetector: io.netty.util.ResourceLeakDetector#41e61236
13:23:21.046 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsNameResolver - [id: 0x0ea5f4b3] RECEIVED: UDP
[52950: /192.168.1.1:53], DatagramDnsResponse(from: /192.168.1.1:53,
to: /0.0.0.0:49776, 52950, QUERY(0), NoError(0), RD RA)
DefaultDnsQuestion(dev-542348.okta.com. IN A)
DefaultDnsRawRecord(dev-542348.okta.com. 300 IN CNAME 25B)
DefaultDnsRawRecord(ok11-crtrs.tng.okta.com. 217 IN CNAME 66B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN
NS 23B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS
25B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS 21B)
DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS 22B)
13:23:21.048 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsQueryContext - [id: 0x0ea5f4b3] WRITE: UDP,
[2623: /192.168.1.1:53],
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A) 13:23:21.084 [nioEventLoopGroup-2-1] DEBUG
io.netty.resolver.dns.DnsNameResolver - [id: 0x0ea5f4b3] RECEIVED: UDP
[2623: /192.168.1.1:53], DatagramDnsResponse(from: /192.168.1.1:53,
to: /0.0.0.0:49776, 2623, QUERY(0), NoError(0), RD RA)
DefaultDnsQuestion(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
IN A)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B)
DefaultDnsRawRecord(ok11-crtr-tls12-nlb-7429507134c4aa04.elb.us-east-2.amazonaws.com.
60 IN A 4B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN
NS 23B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS
25B) DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS 21B)
DefaultDnsRawRecord(elb.us-east-2.amazonaws.com. 41273 IN NS 22B)
2[dev-542348.okta.com/3.15.36.192, dev-542348.okta.com/3.15.36.194,
dev-542348.okta.com/3.15.36.193] 13:23:23.184 [nioEventLoopGroup-2-1]
DEBUG io.netty.buffer.PoolThreadCache - Freed 8 thread-local buffer(s)
from thread: nioEventLoopGroup-2-1
As the reactor-netty code is also giving the same issue with windows but working fine on MACOS this looks like an issue with Netty.
Any suggestion to fix this

Related

Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response

I' trying to connect from raspberry 3 B to a Modbus device (sensor temperature) using a serial connection using a USB RS485 converter .This is my code:
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.constants import Defaults
Defaults.RetryOnEmpty = True
import time
import logging
FORMAT = ('%(asctime)-15s %(threadName)-15s '
'%(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger()
log.setLevel(logging.DEBUG)
def run_sync_client():
while True:
#try:
client = ModbusClient(method='rtu', port='/dev/ttyUSB0', timeout=9, baudrate=9600, parity='N', stopbits=1, bytesize=8,reset_socket=False) # Implementation of the SHT31 as a modbus serial client
if client.connect():
print("connected")
print ("begin reading")
#for i in range(0 ,100):
request = client.read_holding_registers(address=0 , count=2, unit=4)
if request.isError():
print(request)
else:
print("Read OK! " + str(request.registers[1]))
time.sleep(1)
print(request)
result = request.registers
print(result)
temp= BinaryPayloadDecoder.fromRegisters(result, Endian.little, wordorder=Endian.little )
temperature= temp.decode_16bit_int()
print( temperature)
time.sleep(4)
# except:
#print("An exception occurred")
client.close()
while True:
if __name__ == "__main__":
run_sync_client()
The output in the console is:
connected
begin reading
2022-02-24 14:56:37,901 MainThread DEBUG transaction :139 Current transaction state - IDLE
2022-02-24 14:56:37,902 MainThread DEBUG transaction :144 Running transaction 1
2022-02-24 14:56:37,904 MainThread DEBUG transaction :273 SEND: 0x4 0x3 0x0 0x1 0x0 0x2 0x95 0x9e
2022-02-24 14:56:37,905 MainThread DEBUG sync :76 New Transaction state 'SENDING'
2022-02-24 14:56:37,906 MainThread DEBUG transaction :287 Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
2022-02-24 14:56:38,068 MainThread DEBUG transaction :375 Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
2022-02-24 14:56:38,069 MainThread DEBUG transaction :297 RECV: 0x4 0x3 0x2 0x17 0x58 0x2c 0x2e 0x3f 0x88
2022-02-24 14:56:38,071 MainThread DEBUG rtu_framer :237 Frame check failed, ignoring!!
2022-02-24 14:56:38,072 MainThread DEBUG rtu_framer :119 Resetting frame - Current Frame in buffer - 0x4 0x3 0x2 0x17 0x58 0x2c 0x2e 0x3f 0x88
2022-02-24 14:56:38,073 MainThread DEBUG transaction :465 Getting transaction 4
2022-02-24 14:56:38,074 MainThread DEBUG transaction :224 Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
I would love to have a little help understanding the error I'm getting. Thanks

How to make a reproduction of a bug for OkHttp

I need to reproduce a bug with OkHttp so I can file a bug or ask a question on StackOverflow.
What is the simplest way to do this without a lot of setup?
I've read https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/minimal-reproducible-example but I'm still stuck? Help me!
Make a Kotlin script in Intellij, place it outside any source folders and make sure it ends with .main.kts filename.
example.main.kts
#!/usr/bin/env kotlin
#file:Repository("https://repo1.maven.org/maven2/")
#file:DependsOn("com.squareup.okhttp3:okhttp:4.9.0")
#file:CompilerOptions("-jvm-target", "1.8")
import okhttp3.OkHttpClient
import okhttp3.Request
val client = OkHttpClient()
val request = Request.Builder()
.url("https://raw.github.com/square/okhttp/master/README.md")
.build()
val body = client.newCall(request).execute().use {
it.body!!.string()
}
println(body)
The #! line means it will run like a shell script also
$ ./example.main.kts
OkHttp
======
See the [project website][okhttp] for documentation and APIs.
...
If you need to see events (connection, request, response, caching) then use the EventListener.
https://square.github.io/okhttp/events/
In Gradle add a dependency on com.squareup.okhttp3:logging-interceptor:4.9.1
val client = OkHttpClient.Builder()
.eventListenerFactory(LoggingEventListener.Factory())
.build()
[0 ms] callStart: Request{method=GET, url=https://httpbin.org/get}
[11 ms] proxySelectStart: https://httpbin.org/
[12 ms] proxySelectEnd: [DIRECT]
[12 ms] dnsStart: httpbin.org
[55 ms] dnsEnd: [httpbin.org/54.147.165.197, httpbin.org/34.231.30.52, httpbin.org/54.91.118.50, httpbin.org/18.214.80.1, httpbin.org/54.166.163.67, httpbin.org/34.199.75.4]
[62 ms] connectStart: httpbin.org/54.147.165.197:443 DIRECT
[176 ms] secureConnectStart
[747 ms] secureConnectEnd: Handshake{tlsVersion=TLS_1_2 cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 peerCertificates=[CN=httpbin.org, CN=Amazon, OU=Server CA 1B, O=Amazon, C=US, CN=Amazon Root CA 1, O=Amazon, C=US] localCertificates=[]}
[765 ms] connectEnd: h2
[767 ms] connectionAcquired: Connection{httpbin.org:443, proxy=DIRECT hostAddress=httpbin.org/54.147.165.197:443 cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=h2}
[775 ms] requestHeadersStart
[783 ms] requestHeadersEnd
[993 ms] responseHeadersStart
[994 ms] responseHeadersEnd: Response{protocol=h2, code=200, message=, url=https://httpbin.org/get}
[999 ms] responseBodyStart
[999 ms] responseBodyEnd: byteCount=267
[999 ms] connectionReleased
[1000 ms] callEnd
[0 ms] callStart: Request{method=GET, url=https://httpbin.org/get}
[1 ms] connectionAcquired: Connection{httpbin.org:443, proxy=DIRECT hostAddress=httpbin.org/54.147.165.197:443 cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=h2}
[1 ms] requestHeadersStart
[1 ms] requestHeadersEnd
[98 ms] responseHeadersStart
[99 ms] responseHeadersEnd: Response{protocol=h2, code=200, message=, url=https://httpbin.org/get}
[99 ms] responseBodyStart
[99 ms] responseBodyEnd: byteCount=267
[99 ms] connectionReleased
[99 ms] callEnd
If you need to see HTTP/2 Frames https://square.github.io/okhttp/debug_logging/
[2021-02-27 11:49:39] >> CONNECTION 505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
[2021-02-27 11:49:39] >> 0x00000000 6 SETTINGS
[2021-02-27 11:49:39] >> 0x00000000 4 WINDOW_UPDATE
[2021-02-27 11:49:39] << 0x00000000 18 SETTINGS
[2021-02-27 11:49:39] << 0x00000000 4 WINDOW_UPDATE
[2021-02-27 11:49:39] >> 0x00000003 33 HEADERS END_STREAM|END_HEADERS
[2021-02-27 11:49:39] >> 0x00000000 0 SETTINGS ACK
[2021-02-27 11:49:39] << 0x00000000 0 SETTINGS ACK
[2021-02-27 11:49:39] << 0x00000003 113 HEADERS END_HEADERS
[2021-02-27 11:49:39] << 0x00000003 267 DATA
[2021-02-27 11:49:39] << 0x00000003 0 DATA END_STREAM
Follow up request
[2021-02-27 11:49:39] >> 0x00000005 10 HEADERS END_STREAM|END_HEADERS
[2021-02-27 11:49:39] << 0x00000005 113 HEADERS END_HEADERS
[2021-02-27 11:49:39] << 0x00000005 267 DATA
[2021-02-27 11:49:39] << 0x00000005 0 DATA END_STREAM
To create an Android instrumentation test run on device or the emulator, use a test like.
https://github.com/square/okhttp/blob/master/regression-test/src/androidTest/java/okhttp/regression/compare/OkHttpClientTest.java
#RunWith(AndroidJUnit4.class)
public class OkHttpClientTest {
#Test public void get() throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://google.com/robots.txt")
.build();
try (Response response = client.newCall(request).execute()) {
assertEquals(200, response.code());
assertEquals(Protocol.HTTP_2, response.protocol());
}
}
}
Steps to run https://github.com/square/okhttp/tree/master/regression-test
If you need to see network traffic via Wireshark for a JVM client (JSSE and TLSv1.2) https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/kt/WiresharkExample.kt
Copy WireSharkKeyLoggerListener to your test code to use in development.
This logs TLSv1.2 on a JVM (OpenJDK 11+) without any additional code. For TLSv1.3 an existing external tool is required.
Steps to run in your own code
In your main method WireSharkListenerFactory.register()
Create Listener factory val eventListenerFactory = WireSharkListenerFactory( logFile = File("/tmp/key.log"), tlsVersions = tlsVersions, launch = launch)
Register with client.eventListenerFactory(eventListenerFactory)
Launch wireshark if not done externally val process = eventListenerFactory.launchWireShark()
Capturing on 'Wi-Fi: en0'
Frame 20: 110 bytes on wire (880 bits), 110 bytes captured (880 bits) on interface en0, id 0
Ethernet II, Src: Google_fc:86:a2 (28:bd:89:fc:86:a2), Dst: Apple_6b:3b:e5 (f0:18:98:6b:3b:e5)
Internet Protocol Version 4, Src: 104.244.42.130, Dst: 192.168.86.23
Transmission Control Protocol, Src Port: 443, Dst Port: 57669, Seq: 3531, Ack: 383, Len: 44
Transport Layer Security
TLSv1.2 Record Layer: Application Data Protocol: http2
Content Type: Application Data (23)
Version: TLS 1.2 (0x0303)
Length: 39
Encrypted Application Data: cfb509e24e2ca451923820e45c3943fa521e1f3f1a821fe3468c0a7294e1d07c0ab7ab90…
[Application Data Protocol: http2]
HyperText Transfer Protocol 2
Stream: SETTINGS, Stream ID: 0, Length 6
Length: 6
Type: SETTINGS (4)
Flags: 0x00
0000 000. = Unused: 0x00
.... ...0 = ACK: False
0... .... .... .... .... .... .... .... = Reserved: 0x0
.000 0000 0000 0000 0000 0000 0000 0000 = Stream Identifier: 0
Settings - Initial Windows size : 65536
Settings Identifier: Initial Windows size (4)
Initial Windows Size: 65536
...
HyperText Transfer Protocol 2
Stream: HEADERS, Stream ID: 3, Length 53, GET /robots.txt?s=tw
Length: 53
Type: HEADERS (1)
Flags: 0x05, End Headers, End Stream
00.0 ..0. = Unused: 0x00
..0. .... = Priority: False
.... 0... = Padded: False
.... .1.. = End Headers: True
.... ...1 = End Stream: True
0... .... .... .... .... .... .... .... = Reserved: 0x0
.000 0000 0000 0000 0000 0000 0000 0011 = Stream Identifier: 3
[Pad Length: 0]
Header Block Fragment: 82048c62c3c674a174f94ff88813e3418b1d665d3e0c9496c5c87a7f8750839bd9ab7a91…
[Header Length: 166]
[Header Count: 6]
Header: :method: GET
Name Length: 7
...
You will need to point Wireshark at your key log file
Use a MITM debugging proxy, these give you user friendly tools to observe traffic.
https://medium.com/#ievgeniitkachenko/different-ways-to-debug-https-requests-in-an-android-emulator-cbf4e0c8ce17
https://hackupstate.medium.com/using-charles-proxy-to-debug-android-ssl-traffic-e61fc38760f7

add_timer causes kernel stack dump for multiple PCI boards

We are using FPGA cards with PCI express drivers to move data around with DMA engines. This all works fine for a single card in a machine, however with two cards it fails. As an initial investigation, I have narrowed an error down to the add_timer function that is used to set up the polling mechanism. When insmod adds the driver modules, a stack trace is produced as the poll_timer routine is the same for both instances. The code has been reduced to
static int dat_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct timer_list * timer = &poll_timer;
int i;
/* Start polling routine */
log_normal(KERN_INFO "DEBUG ADD TIMER: Starting poll routine with %x\n", pdev);
init_timer(timer);
// random number added so that expires value is different for both instances of timer
get_random_bytes(&i, 1);
timer->expires=jiffies+HZ+i;
timer->data=(unsigned long) pdev;
timer->function = poll_routine;
log_verbose("DEBUG ADD TIMER: Timer expires %x\n", timer->expires);
log_verbose("DEBUG ADD TIMER: Timer data %x\n", timer->data);
log_verbose("DEBUG ADD TIMER: Timer function %x\n", timer->function);
// ***** THIS IS WHERE STACK TRACE OCCURS (WHEN CALLED FOR SECOND TIME)
add_timer(timer);
log_verbose("DEBUG ADD TIMER: Value of HZ is %d\n", HZ);
log_verbose("DEBUG ADD TIMER: End of probe\n");
return 0;
}
the stack trace produces
list_add corruption. prev->next should be next (ffffffff81f76228), but was (null). (prev=ffffffffa050a3c0).
and
list_add double add: new=ffffffffa050a3c0, prev=ffffffffa050a3c0, next=ffffffff81f76228.
Looking at the printk statements, it is clear that the add_timer is trying to add the same routine to the linked list. Is this correct?
DEBUG ADD TIMER: Timer expires fffd9cd3
DEBUG ADD TIMER: Timer data 6c0ac000
DEBUG ADD TIMER: Timer function **a0508150**
DEBUG ADD TIMER: Value of HZ is 1000
DEBUG ADD TIMER: End of probe
DEBUG ADD TIMER: Starting poll routine with 6c0ad000
DEBUG ADD TIMER: Timer expires fffd9c7d
DEBUG ADD TIMER: Timer data 6c0ad000
DEBUG ADD TIMER: Timer function **a0508150**
So my question(s) is(are), how should I configure the timer for multiple instantations of the same driver? (Assuming that is what is happening when multiple boards are inserted into the machine).
full stack trace
DEBUG ADD TIMER: Inserting driver into kernel.
DEBUG ADD TIMER: Starting poll routine with 6c0ac000
DEBUG ADD TIMER: Timer expires fffd9cd3
DEBUG ADD TIMER: Timer data 6c0ac000
DEBUG ADD TIMER: Timer function a0508150
DEBUG ADD TIMER: Value of HZ is 1000
DEBUG ADD TIMER: End of probe
DEBUG ADD TIMER: Starting poll routine with 6c0ad000
DEBUG ADD TIMER: Timer expires fffd9c7d
DEBUG ADD TIMER: Timer data 6c0ad000
DEBUG ADD TIMER: Timer function a0508150
------------[ cut here ]------------
WARNING: CPU: 0 PID: 2201 at lib/list_debug.c:33 __list_add+0xa0/0xd0()
list_add corruption. prev->next should be next (ffffffff81f76228), but was (null). (prev=ffffffffa050a3c0).
Modules linked in: xdma_v7(POE+) xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw intel_rapl iosf_mbi x86_pkg_temp_thermal coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_controller crc32c_intel eeepc_wmi ghash_clmulni_intel asus_wmi ftdi_sio iTCO_wdt snd_hda_codec sparse_keymap raid0 iTCO_vendor_support
snd_hda_core rfkill sb_edac ipmi_ssif video mxm_wmi edac_core snd_hwdep mei_me snd_seq snd_seq_device ipmi_msghandler snd_pcm mei acpi_pad tpm_infineon lpc_ich mfd_core snd_timer tpm_tis shpchp tpm snd soundcore i2c_i801 wmi nfsd auth_rpcgss nfs_acl lockd grace sunrpc ast drm_kms_helper ttm drm igb serio_raw ptp pps_core dca i2c_algo_bit
CPU: 0 PID: 2201 Comm: insmod Tainted: P OE 4.1.8-100.fc21.x86_64 #1
Hardware name: ASUSTeK COMPUTER INC. Z10PE-D8 WS/Z10PE-D8 WS, BIOS 1001 03/17/2015
0000000000000000 00000000ec73155d ffff880457123928 ffffffff81792065
0000000000000000 ffff880457123980 ffff880457123968 ffffffff810a163a
0000000000000246 ffffffffa050a3c0 ffffffff81f76228 ffffffffa050a3c0
Call Trace:
[<ffffffff81792065>] dump_stack+0x45/0x57
[<ffffffff810a163a>] warn_slowpath_common+0x8a/0xc0
[<ffffffff810a16c5>] warn_slowpath_fmt+0x55/0x70
[<ffffffff810f8250>] ? vprintk_emit+0x3b0/0x560
[<ffffffff813c7c30>] __list_add+0xa0/0xd0
[<ffffffff81108412>] __internal_add_timer+0xb2/0x130
[<ffffffff811084bf>] internal_add_timer+0x2f/0xb0
[<ffffffff8110a1ca>] mod_timer+0x12a/0x210
[<ffffffff8110a2c8>] add_timer+0x18/0x30
[<ffffffffa050810f>] dat_probe+0xbf/0x100 [xdma_v7]
[<ffffffff813f6da5>] local_pci_probe+0x45/0xa0
[<ffffffff812a8da2>] ? sysfs_do_create_link_sd.isra.2+0x72/0xc0
[<ffffffff813f8109>] pci_device_probe+0xf9/0x150
[<ffffffff814e7e59>] driver_probe_device+0x209/0x4b0
[<ffffffff814e81db>] __driver_attach+0x9b/0xa0
[<ffffffff814e8140>] ? __device_attach+0x40/0x40
[<ffffffff814e5973>] bus_for_each_dev+0x73/0xc0
[<ffffffff814e772e>] driver_attach+0x1e/0x20
[<ffffffff814e72e0>] bus_add_driver+0x180/0x250
[<ffffffffa000a000>] ? 0xffffffffa000a000
[<ffffffff814e89d4>] driver_register+0x64/0xf0
[<ffffffff813f662c>] __pci_register_driver+0x4c/0x50
[<ffffffffa000a02c>] dat_init+0x2c/0x1000 [xdma_v7]
[<ffffffff81002148>] do_one_initcall+0xd8/0x210
[<ffffffff812094f9>] ? kmem_cache_alloc_trace+0x1a9/0x230
[<ffffffff817911bc>] ? do_init_module+0x28/0x1cc
[<ffffffff817911f5>] do_init_module+0x61/0x1cc
[<ffffffff811270bb>] load_module+0x20db/0x2550
[<ffffffff81122990>] ? store_uevent+0x70/0x70
[<ffffffff8122e860>] ? kernel_read+0x50/0x80
[<ffffffff81127766>] SyS_finit_module+0xa6/0xe0
[<ffffffff8179892e>] system_call_fastpath+0x12/0x71
---[ end trace 340e5d7ba2d89081 ]---
------------[ cut here ]------------
WARNING: CPU: 0 PID: 2201 at lib/list_debug.c:36 __list_add+0xcb/0xd0()
list_add double add: new=ffffffffa050a3c0, prev=ffffffffa050a3c0, next=ffffffff81f76228.
Modules linked in: xdma_v7(POE+) xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw intel_rapl iosf_mbi x86_pkg_temp_thermal coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_controller crc32c_intel eeepc_wmi ghash_clmulni_intel asus_wmi ftdi_sio iTCO_wdt snd_hda_codec sparse_keymap raid0 iTCO_vendor_support
snd_hda_core rfkill sb_edac ipmi_ssif video mxm_wmi edac_core snd_hwdep mei_me snd_seq snd_seq_device ipmi_msghandler snd_pcm mei acpi_pad tpm_infineon lpc_ich mfd_core snd_timer tpm_tis shpchp tpm snd soundcore i2c_i801 wmi nfsd auth_rpcgss nfs_acl lockd grace sunrpc ast drm_kms_helper ttm drm igb serio_raw ptp pps_core dca i2c_algo_bit
CPU: 0 PID: 2201 Comm: insmod Tainted: P W OE 4.1.8-100.fc21.x86_64 #1
Hardware name: ASUSTeK COMPUTER INC. Z10PE-D8 WS/Z10PE-D8 WS, BIOS 1001 03/17/2015
0000000000000000 00000000ec73155d ffff880457123928 ffffffff81792065
0000000000000000 ffff880457123980 ffff880457123968 ffffffff810a163a
0000000000000246 ffffffffa050a3c0 ffffffff81f76228 ffffffffa050a3c0
Call Trace:
[<ffffffff81792065>] dump_stack+0x45/0x57
[<ffffffff810a163a>] warn_slowpath_common+0x8a/0xc0
[<ffffffff810a16c5>] warn_slowpath_fmt+0x55/0x70
[<ffffffff810f8250>] ? vprintk_emit+0x3b0/0x560
[<ffffffff813c7c5b>] __list_add+0xcb/0xd0
[<ffffffff81108412>] __internal_add_timer+0xb2/0x130
[<ffffffff811084bf>] internal_add_timer+0x2f/0xb0
[<ffffffff8110a1ca>] mod_timer+0x12a/0x210
[<ffffffff8110a2c8>] add_timer+0x18/0x30
[<ffffffffa050810f>] dat_probe+0xbf/0x100 [xdma_v7]
[<ffffffff813f6da5>] local_pci_probe+0x45/0xa0
[<ffffffff812a8da2>] ? sysfs_do_create_link_sd.isra.2+0x72/0xc0
[<ffffffff813f8109>] pci_device_probe+0xf9/0x150
[<ffffffff814e7e59>] driver_probe_device+0x209/0x4b0
[<ffffffff814e81db>] __driver_attach+0x9b/0xa0
[<ffffffff814e8140>] ? __device_attach+0x40/0x40
[<ffffffff814e5973>] bus_for_each_dev+0x73/0xc0
[<ffffffff814e772e>] driver_attach+0x1e/0x20
[<ffffffff814e72e0>] bus_add_driver+0x180/0x250
[<ffffffffa000a000>] ? 0xffffffffa000a000
[<ffffffff814e89d4>] driver_register+0x64/0xf0
[<ffffffff813f662c>] __pci_register_driver+0x4c/0x50
[<ffffffffa000a02c>] dat_init+0x2c/0x1000 [xdma_v7]
[<ffffffff81002148>] do_one_initcall+0xd8/0x210
[<ffffffff812094f9>] ? kmem_cache_alloc_trace+0x1a9/0x230
[<ffffffff817911bc>] ? do_init_module+0x28/0x1cc
[<ffffffff817911f5>] do_init_module+0x61/0x1cc
[<ffffffff811270bb>] load_module+0x20db/0x2550
[<ffffffff81122990>] ? store_uevent+0x70/0x70
[<ffffffff8122e860>] ? kernel_read+0x50/0x80
[<ffffffff81127766>] SyS_finit_module+0xa6/0xe0
[<ffffffff8179892e>] system_call_fastpath+0x12/0x71
---[ end trace 340e5d7ba2d89082 ]---
DEBUG ADD TIMER: Value of HZ is 1000
DEBUG ADD TIMER: End of probe
The problem is that the second call to dat_probe is clobbering the poll_timer variable that was initialized and queued by the first call to dat_probe. You are clobbering the pointers in the kernel's timer list.
You need to get rid of the poll_timer variable and give each device its own dynamically allocated private data structure containing its own struct timer_list member. Call pci_set_drvdata to set the private data pointer for the PCI device. The other PCI driver functions can call pci_get_drvdata to retrieve that pointer.

DB2 10.1 FP4 DB2START gives error

I installed DB2 10.1 FP4 on Windows server 2012 R2 successfully.
When I try to start database using db2start I am getting below error.
DB2 : The service has returned a service-specific error code.
SQL1042C An unexpected system error occurred. SQLSTATE=58004
db2diag.log has below error.
2015-05-14-16.34.51.630000+540 I95881F1126 LEVEL: Error
PID : 4728 TID : 4996 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
HOSTNAME: <Machine name>
EDUID : 4996 EDUNAME: db2sysc
FUNCTION: DB2 Common, Cryptography, cryptDynamicLoadGSKitCrypto, probe:998
MESSAGE : ECF=0x90000076=-1879048074=ECF_LIB_CANNOT_LOAD
Cannot load the specified library
DATA #1 : unsigned integer, 4 bytes
70
DATA #2 : String, 48 bytes
D:\PROGRA~1\IBM\SQLLIB\bin\icc64\gsk8iccs_64.dll
CALLSTCK:
[0] 0x00007FF93D9642A4 pdOSSeLoggingCallback + 0x134
[1] 0x00007FF93EF1033E ossLog + 0x15E
[2] 0x00007FF93EF1023B ossLog + 0x5B
[3] 0x00007FF91D8E75ED cryptDynamicLoadGSKitCrypto + 0x65D
[4] 0x00007FF91D8E6724 cryptContextRealInit + 0x144
[5] 0x00007FF91D8E6337 cryptContextInit + 0x117
[6] 0x00007FF91C9002E5 sqloRunInstance + 0x1C5
[7] 0x00007FF691442700 0x00007FF691442700 + 0x0
[8] 0x00007FF691441974 0x00007FF691441974 + 0x0
[9] 0x00007FF946B516AD BaseThreadInitThunk + 0xD
[10] 0x00007FF946D04629 RtlUserThreadStart + 0x1D
2015-05-14-16.34.51.834000+540 I97009F922 LEVEL: Error
PID : 4728 TID : 4996 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
HOSTNAME: <Machine name>
EDUID : 4996 EDUNAME: db2sysc
FUNCTION: DB2 Common, Cryptography, cryptContextInit, probe:105
MESSAGE : ECF=0x90000076=-1879048074=ECF_LIB_CANNOT_LOAD
Cannot load the specified library
DATA #1 : Hex integer, 4 bytes
0x90000076
CALLSTCK:
[0] 0x00007FF93D9642A4 pdOSSeLoggingCallback + 0x134
[1] 0x00007FF93EF1033E ossLog + 0x15E
[2] 0x00007FF93EF1023B ossLog + 0x5B
[3] 0x00007FF91D8E63D5 cryptContextInit + 0x1B5
[4] 0x00007FF91C9002E5 sqloRunInstance + 0x1C5
[5] 0x00007FF691442700 0x00007FF691442700 + 0x0
[6] 0x00007FF691441974 0x00007FF691441974 + 0x0
[7] 0x00007FF946B516AD BaseThreadInitThunk + 0xD
[8] 0x00007FF946D04629 RtlUserThreadStart + 0x1D
2015-05-14-16.34.51.834000+540 I97933F426 LEVEL: Severe
PID : 4728 TID : 4996 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
HOSTNAME: <Machine name>
EDUID : 4996 EDUNAME: db2sysc
FUNCTION: DB2 UDB, oper system services, sqloRunInstance, probe:50
MESSAGE : ECF=0x90000076=-1879048074=ECF_LIB_CANNOT_LOAD
Cannot load the specified library
2015-05-14-16.34.51.834000+540 I98361F529 LEVEL: Severe
PID : 4728 TID : 4996 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000
HOSTNAME: <Machine name>
EDUID : 4996 EDUNAME: db2sysc
FUNCTION: DB2 UDB, base sys utilities, DB2main, probe:2263
MESSAGE : SQL1042C An unexpected system error occurred.
Any help is appreciate.

TinyOS/nesC Receive.receive event is signalled periodically but processed only once

I'm currently working with implementation of AODV protocol for TinyOS and I'm seeing weird behaviour when network layer is signalling application about received message.
Below are relevant pieces of application and AODV library code + some debug output to show what is going on.
Test application
Configuration
configuration BasicTestAppC{
}
implementation{
components MainC, BasicTestC, AODV, LedsC;
BasicTestC.Boot->MainC.Boot;
BasicTestC.SplitControl->AODV.SplitControl;
BasicTestC.AMSend->AODV.AMSend[1];
BasicTestC.Receive->AODV.Receive[1];
...
}
Implementation
#include "BasicTest.h"
module BasicTestC {
uses {
interface Boot;
interface SplitControl;
interface Timer<TMilli> as MilliTimer;
interface AMSend;
interface Receive;
interface Leds;
interface Packet;
}
}
implementation {
message_t pkt;
message_t * p_pkt;
uint16_t src = 0x0007;
uint16_t dest = 0x000A;
uint16_t ctr = 0;
test_msg* test_pkt;
test_msg* rcv_pkt;
...
//Send counter value to node 10 on every timer tick
event void MilliTimer.fired() {
call Leds.led0Toggle();
ctr = ctr + 1;
test_pkt = (test_msg*)(call Packet.getPayload(p_pkt, sizeof (test_msg)));
test_pkt->counter = ctr;
call AMSend.send(dest, p_pkt, sizeof(test_msg));
}
event void AMSend.sendDone(message_t * bufPtr, error_t error) {
test_pkt = (test_msg*)(call Packet.getPayload(p_pkt, sizeof (test_msg)));
dbg("APPS", "%s\t APPS: sendDone!! (error=%d) ctr=%u\n", sim_time_string(), error, test_pkt->counter);
}
event message_t* Receive.receive(message_t * bufPtr, void * payload, uint8_t len) {
rcv_pkt = (test_msg * ) payload;
dbg("APPS", "%s\t APPS: receive!! %u\n", sim_time_string(), rcv_pkt->counter);
return bufPtr;
}
}
AODV module
Processing receive event from AMReceiverC component:
event message_t* SubReceive.receive( message_t* p_msg, void* payload, uint8_t len ) {
uint8_t i;
aodv_msg_hdr* aodv_hdr = (aodv_msg_hdr*)(p_msg->data);
test_msg_y* tmp;
uint16_t ctr;
dbg("AODV", "%s\t AODV: SubReceive.receive() dest: %d src:%d\n", sim_time_string(), aodv_hdr->dest, aodv_hdr->src);
if( aodv_hdr->dest == call AMPacket.address() ) {
for( i=0;i<len;i++ ) {
p_app_msg_->data[i] = aodv_hdr->data[i];
}
tmp = (test_msg_y*) p_app_msg_->data;
ctr = tmp->counter;
//Send signal to application layer
p_msg = signal Receive.receive[aodv_hdr->app]( p_app_msg_, p_app_msg_->data, len - AODV_MSG_HEADER_LEN );
dbg("AODV", "%s\t AODV: SubReceive.receive() delivered to upper layer - %u\n", sim_time_string(), ctr);
} else {
am_addr_t nexthop = get_next_hop( aodv_hdr->dest );
dbg("AODV", "%s\t AODV: SubReceive.receive() deliver to next hop:%x\n", sim_time_string(), nexthop);
/* If there is a next-hop for the destination of the message,
the message will be forwarded to the next-hop. */
if (nexthop != INVALID_NODE_ID) {
forwardMSG( p_msg, nexthop, len );
}
}
return p_msg;
}
Debug output
DEBUG (7): 0:0:2.006653503 APPS: sendDone!! (error=0) ctr=2
DEBUG (10): 0:0:2.019577622 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:2.019577622 AODV: SubReceive.receive() delivered to upper layer - 2
DEBUG (10): 0:0:2.019577622 APPS: receive!! 2
DEBUG (7): 0:0:3.010407143 APPS: sendDone!! (error=0) ctr=3
DEBUG (10): 0:0:3.021820651 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:3.021820651 AODV: SubReceive.receive() delivered to upper layer - 3
DEBUG (7): 0:0:4.005264961 APPS: sendDone!! (error=0) ctr=4
DEBUG (10): 0:0:4.023239710 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:4.023239710 AODV: SubReceive.receive() delivered to upper layer - 4
DEBUG (7): 0:0:5.010010417 APPS: sendDone!! (error=0) ctr=5
DEBUG (10): 0:0:5.024780838 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:5.024780838 AODV: SubReceive.receive() delivered to upper layer - 5
DEBUG (7): 0:0:6.003983230 APPS: sendDone!! (error=0) ctr=6
DEBUG (10): 0:0:6.010147745 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:6.010147745 AODV: SubReceive.receive() delivered to upper layer - 6
DEBUG (7): 0:0:7.008331960 APPS: sendDone!! (error=0) ctr=7
DEBUG (10): 0:0:7.020187970 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:7.020187970 AODV: SubReceive.receive() delivered to upper layer - 7
DEBUG (7): 0:0:8.004013748 APPS: sendDone!! (error=0) ctr=8
DEBUG (10): 0:0:8.013474142 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:8.013474142 AODV: SubReceive.receive() delivered to upper layer - 8
DEBUG (7): 0:0:9.009140671 APPS: sendDone!! (error=0) ctr=9
DEBUG (10): 0:0:9.020233746 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:9.020233746 AODV: SubReceive.receive() delivered to upper layer - 9
DEBUG (7): 0:0:10.010391884 APPS: sendDone!! (error=0) ctr=10
DEBUG (10): 0:0:10.018341667 AODV: SubReceive.receive() dest: 10 src:7
DEBUG (10): 0:0:10.018341667 AODV: SubReceive.receive() delivered to upper layer - 10
As you can see - receive event at the application layer is triggered/executed only once. All following messages reach destination node but don't get above network layer.
Any thoughts as to what might be going on here?
Problem was in following line:
p_msg = signal Receive.receive[aodv_hdr->app]( p_app_msg_, p_app_msg_->data, len - AODV_MSG_HEADER_LEN );
Documentation on Receive.receive suggests that it should not reuse receive message buffer and most common thing to do is to return same pointer that was passed to it as a first argument.
The problem with it is - if user application follows guidelines when implementing Receive.receive event handler, it will return pointer to the message buffer (the first argument). However first argument that is passed to Receive.receive in the line above is p_app_msg_, which means that after first message was received, p_msg is not pointing to the original message buffer any more.
Still considering what the best way to fix this is, but at the moment I just don't assign result of Receive.receive back to p_msg and avoid reusing receive message buffer in application code.

Resources